From: Derrick Brashear Date: Mon, 13 Feb 2012 03:45:59 +0000 (-0500) Subject: libafs: ensure one nat ping connection per srvAddr X-Git-Tag: upstream/1.6.1.pre4^2~51 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fcdd20e389282607616b23f912a22ff5c352ce70;p=packages%2Fo%2Fopenafs.git libafs: ensure one nat ping connection per srvAddr track the natping conn with the srvAddr, ensuring exactly one. Reviewed-on: http://gerrit.openafs.org/6706 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 2378895fc66a19a050f302711f2e18dbbf2e3d6f) Change-Id: I5e74ec3f46f9af335653b6910d2c31c788181c5c Reviewed-on: http://gerrit.openafs.org/6772 Tested-by: BuildBot Reviewed-by: Alistair Ferguson Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs.h b/src/afs/afs.h index cf9345d48..a3c838d9b 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -400,7 +400,8 @@ struct srvAddr { struct srvAddr *next_bkt; /* next item in hash bucket */ struct srvAddr *next_sa; /* another interface on same host */ struct server *server; /* back to parent */ - struct afs_conn *conns; /* All user connections to this server */ + struct afs_conn *conns; /* All user connections to this server */ + struct afs_conn *natping; afs_int32 sa_ip; /* Host addr in network byte order */ u_short sa_iprank; /* indiv ip address priority */ u_short sa_portal; /* port addr in network byte order */ diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index 95baf6c4a..108df40c3 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -310,6 +310,8 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, rx_SetConnSecondsUntilNatPing(tc->id, 0); rx_DestroyConnection(tc->id); AFS_GLOCK(); + if (sap->natping == tc) + sap->natping = NULL; } /* * Stupid hack to determine if using vldb service or file system @@ -336,16 +338,12 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, rx_SetConnIdleDeadTime(tc->id, afs_rx_idledead); /* - * Only do this for the base connection, not per-user. - * Will need to be revisited if/when CB gets security. + * Only do this for one connection */ - if ((isec == 0) && (service != 52) && !(tu->states & UTokensBad) && - (tu->vid == UNDEFVID) && (isrep == 0) -#ifndef UKERNEL /* ukernel runs as just one uid anyway */ - && (tu->uid == 0) -#endif - ) + if ((service != 52) && (sap->natping == NULL)) { + sap->natping = tc; rx_SetConnSecondsUntilNatPing(tc->id, 20); + } tc->forceConnectFS = 0; /* apparently we're appropriately connected now */ if (csec) diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 769f5e178..0bfdce631 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -2072,6 +2072,7 @@ afs_RemoveAllConns(void) tc = ntc; } sa->conns = NULL; + sa->natping = NULL; } } } diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index f101ab8bc..f47121621 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -74,8 +74,18 @@ RemoveUserConns(struct unixuser *au) if (tc->user == au && tc->refCount == 0) { *lc = tc->next; AFS_GUNLOCK(); + rx_SetConnSecondsUntilNatPing(tc->id, 0); rx_DestroyConnection(tc->id); AFS_GLOCK(); + if (tc->srvr->natping == tc) { + struct afs_conn *nc = sa->conns; + if (nc == tc) + nc = *lc; + if (nc && nc->id) { + rx_SetConnSecondsUntilNatPing((nc->id), 20); + tc->srvr->natping = nc; + } + } afs_osi_Free(tc, sizeof(struct afs_conn)); break; /* at most one instance per server */ } /*Found unreferenced connection for user */