Windows: conditionalize cm_Analyze timeLeft on SMB or RDR
[openafs.git] / src / WINNT / afsd / cm_conn.c
index 065d30b..1461775 100644 (file)
@@ -1,13 +1,16 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
+#include <afsconfig.h>
 #include <afs/param.h>
+#include <roken.h>
+
 #include <afs/stds.h>
 
 #include <windows.h>
@@ -35,6 +38,7 @@ unsigned short NatPingInterval = CM_CONN_NATPINGINTERVAL;
 
 afs_uint32 cryptall = 0;
 afs_uint32 cm_anonvldb = 0;
+afs_uint32 rx_pmtu_discovery = 0;
 
 void cm_PutConn(cm_conn_t *connp)
 {
@@ -49,15 +53,15 @@ void cm_InitConn(void)
     DWORD dwValue;
     DWORD dummyLen;
     HKEY parmKey;
-        
+
     if (osi_Once(&once)) {
        lock_InitializeRWLock(&cm_connLock, "connection global lock",
                                LOCK_HIERARCHY_CONN_GLOBAL);
 
         /* keisa - read timeout value for lanmanworkstation  service.
-         * jaltman - as per 
+         * jaltman - as per
          *   http://support.microsoft.com:80/support/kb/articles/Q102/0/67.asp&NoWebContent=1
-         * the SessTimeout is a minimum timeout not a maximum timeout.  Therefore, 
+         * the SessTimeout is a minimum timeout not a maximum timeout.  Therefore,
          * I believe that the default should not be short.  Instead, we should wait until
          * RX times out before reporting a timeout to the SMB client.
          */
@@ -68,14 +72,14 @@ void cm_InitConn(void)
             BOOL extTimeouts = msftSMBRedirectorSupportsExtendedTimeouts();
 
             if (extTimeouts) {
-                /* 
+                /*
                  * The default value is 1000 seconds.  However, this default
-                 * will not apply to "\\AFS" unless "AFS" is listed in 
+                 * will not apply to "\\AFS" unless "AFS" is listed in
                  * ServersWithExtendedSessTimeout which we will add when we
                  * create the ExtendedSessTimeout value in smb_Init()
                  */
                 dummyLen = sizeof(DWORD);
-                code = RegQueryValueEx(parmKey, 
+                code = RegQueryValueEx(parmKey,
                                        LANMAN_WKS_EXT_SESSION_TIMEOUT,
                                         NULL, NULL,
                                         (BYTE *) &dwValue, &dummyLen);
@@ -83,10 +87,10 @@ void cm_InitConn(void)
                     RDRtimeout = dwValue;
                     afsi_log("lanmanworkstation : ExtSessTimeout %u", RDRtimeout);
                 }
-            } 
+            }
             if (!extTimeouts || code != ERROR_SUCCESS) {
                 dummyLen = sizeof(DWORD);
-                code = RegQueryValueEx(parmKey, 
+                code = RegQueryValueEx(parmKey,
                                        LANMAN_WKS_SESSION_TIMEOUT,
                                        NULL, NULL,
                                        (BYTE *) &dwValue, &dummyLen);
@@ -132,28 +136,44 @@ void cm_InitConn(void)
             RegCloseKey(parmKey);
        }
 
-        /* 
-         * If these values were not set via cpp macro or obtained 
+        /*
+         * If these values were not set via cpp macro or obtained
          * from the registry, we use a value that is derived from
          * the smb redirector session timeout (RDRtimeout).
          *
          * The UNIX cache manager uses 120 seconds for the hard dead
          * timeout and 50 seconds for the connection and idle timeouts.
          *
-         * We base our values on those while making sure we leave 
-         * enough time for overhead.  
+         * We base our values on those while making sure we leave
+         * enough time for overhead.
          */
-       if (ConnDeadtimeout == 0) {
-           ConnDeadtimeout = (unsigned short) ((RDRtimeout / 2) < 50 ? (RDRtimeout / 2) : 50);
-            afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
-        }
-       if (HardDeadtimeout == 0) {
-           HardDeadtimeout = (unsigned short) (RDRtimeout > 125 ? 120 : (RDRtimeout - 5));
-            afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
-        }
-       if (IdleDeadtimeout == 0) {
-           IdleDeadtimeout = (unsigned short) ConnDeadtimeout;
-            afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
+        if (smb_Enabled) {
+            afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
+            if (ConnDeadtimeout == 0) {
+                ConnDeadtimeout = (unsigned short) ((RDRtimeout / 2) < 50 ? (RDRtimeout / 2) : 50);
+                afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
+            }
+            if (HardDeadtimeout == 0) {
+                HardDeadtimeout = (unsigned short) (RDRtimeout > 125 ? 120 : (RDRtimeout - 5));
+                afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+            }       
+            if (IdleDeadtimeout == 0) {
+                IdleDeadtimeout = (unsigned short) ConnDeadtimeout;
+                afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
+            }
+        } else {
+            if (ConnDeadtimeout == 0) {
+                ConnDeadtimeout = CM_CONN_IFS_CONNDEADTIME;
+                afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
+            }
+            if (HardDeadtimeout == 0) {
+                HardDeadtimeout = CM_CONN_IFS_HARDDEADTIME;
+                afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
+            }
+            if (IdleDeadtimeout == 0) {
+                IdleDeadtimeout = CM_CONN_IFS_IDLEDEADTIME;
+                afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
+            }
         }
        osi_EndOnce(&once);
     }
@@ -178,13 +198,13 @@ static long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
     }
 
     cellp = cm_FindCellByID(fidp->cell, 0);
-    if (!cellp) 
+    if (!cellp)
         return CM_ERROR_NOSUCHCELL;
 
     code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_CREATE, &volp);
-    if (code) 
+    if (code)
         return code;
-    
+
     *serversppp = cm_GetVolServers(volp, fidp->volume, userp, reqp);
 
     lock_ObtainRead(&cm_volumeLock);
@@ -211,8 +231,8 @@ static long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
  */
 int
 cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
-           struct cm_fid *fidp, 
-           AFSVolSync *volSyncp, 
+           struct cm_fid *fidp,
+           AFSVolSync *volSyncp,
            cm_serverRef_t * serversp,
            cm_callbackRequest_t *cbrp, long errorCode)
 {
@@ -230,6 +250,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
     long code;
     char addr[16]="unknown";
     int forcing_new = 0;
+    int location_updated = 0;
     char *format;
     DWORD msgID;
 
@@ -261,10 +282,13 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
     /* if timeout - check that it did not exceed the HardDead timeout
      * and retry */
-    
+
     /* timeleft - get it from reqp the same way as cm_ConnByMServers does */
     timeUsed = (GetTickCount() - reqp->startTime) / 1000;
-    timeLeft = HardDeadtimeout - timeUsed;
+    if ( reqp->flags & CM_REQ_SOURCE_SMB )
+        timeLeft = HardDeadtimeout - timeUsed;
+    else
+        timeLeft = 0x0FFFFFFF;
 
     /* get a pointer to the cell */
     if (errorCode) {
@@ -278,7 +302,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                 if ( refp->server )
                     cellp = refp->server->cellp;
             }
-        } 
+        }
         if (cellp == NULL && fidp) {
             cellp = cm_FindCellByID(fidp->cell, 0);
         }
@@ -301,15 +325,15 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
         }
     }
 
-    /* if there is nosuchvolume, then we have a situation in which a 
-     * previously known volume no longer has a set of servers 
+    /* if there is nosuchvolume, then we have a situation in which a
+     * previously known volume no longer has a set of servers
      * associated with it.  Either the volume has moved or
      * the volume has been deleted.  Try to find a new server list
      * until the timeout period expires.
      */
     else if (errorCode == CM_ERROR_NOSUCHVOLUME) {
        osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_NOSUCHVOLUME.");
-        /* 
+        /*
          * The VNOVOL or VL_NOENT error has already been translated
          * to CM_ERROR_NOSUCHVOLUME.  There is nothing for us to do.
          */
@@ -317,7 +341,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
     else if (errorCode == CM_ERROR_ALLDOWN) {
        /* Servers marked DOWN will be restored by the background daemon
-        * thread as they become available.  The volume status is 
+        * thread as they become available.  The volume status is
          * updated as the server state changes.
         */
         if (fidp) {
@@ -332,8 +356,8 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
     }
 
     else if (errorCode == CM_ERROR_ALLOFFLINE) {
-        /* Volume instances marked offline will be restored by the 
-         * background daemon thread as they become available 
+        /* Volume instances marked offline will be restored by the
+         * background daemon thread as they become available
          */
         if (fidp) {
             osi_Log2(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE (FS cell %s vol 0x%x)",
@@ -342,11 +366,15 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
             format = "All servers are offline when accessing cell %s volume %d.";
            LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume);
 
-            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, 
-                                      CM_GETVOL_FLAG_NO_LRU_UPDATE, 
+            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
+                                      CM_GETVOL_FLAG_NO_LRU_UPDATE,
                                       &volp);
             if (code == 0) {
-                if (timeLeft > 7) {
+                /*
+                 * Do not perform a cm_CheckOfflineVolume() if cm_Analyze()
+                 * was called by cm_CheckOfflineVolumeState().
+                 */
+                if (!(reqp->flags & CM_REQ_OFFLINE_VOL_CHK) && timeLeft > 7) {
                     thrd_Sleep(5000);
 
                     /* cm_CheckOfflineVolume() resets the serverRef state */
@@ -365,7 +393,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
         }
     }
     else if (errorCode == CM_ERROR_ALLBUSY) {
-        /* Volumes that are busy cannot be determined to be non-busy 
+        /* Volumes that are busy cannot be determined to be non-busy
          * without actually attempting to access them.
          */
         if (fidp) { /* File Server query */
@@ -375,15 +403,15 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
             format = "All servers are busy when accessing cell %s volume %d.";
            LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume);
 
-            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, 
-                                     CM_GETVOL_FLAG_NO_LRU_UPDATE, 
+            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
+                                     CM_GETVOL_FLAG_NO_LRU_UPDATE,
                                      &volp);
             if (code == 0) {
                 if (timeLeft > 7) {
                     thrd_Sleep(5000);
-                    
+
                     statep = cm_VolumeStateByID(volp, fidp->volume);
-                    if (statep->state != vl_offline && 
+                    if (statep->state != vl_offline &&
                          statep->state != vl_busy &&
                          statep->state != vl_unknown) {
                         retry = 1;
@@ -401,12 +429,11 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                                 continue;
                             if (tsrp->status == srv_busy) {
                                 tsrp->status = srv_not_busy;
-                            }       
+                            }
                         }
                         lock_ReleaseWrite(&cm_serverLock);
                         if (free_svr_list) {
                             cm_FreeServerList(serverspp, 0);
-                            serverspp = NULL;
                             serversp = NULL;
                             free_svr_list = 0;
                         }
@@ -458,11 +485,11 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
         switch ( errorCode ) {
         case VBUSY:
            msgID = MSG_SERVER_REPORTS_VBUSY;
-            format = "Server %s reported busy when accessing volume %d.";
+            format = "Server %s reported busy when accessing volume %d in cell %s.";
             break;
         case VRESTARTING:
            msgID = MSG_SERVER_REPORTS_VRESTARTING;
-            format = "Server %s reported restarting when accessing volume %d.";
+            format = "Server %s reported restarting when accessing volume %d in cell %s.";
             break;
         }
 
@@ -474,8 +501,8 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                    ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
                    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
 
-           osi_Log2(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume);
-           LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume);
+           osi_Log3(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume, cellp->name);
+           LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume, cellp->name);
         }
 
         lock_ObtainWrite(&cm_serverLock);
@@ -486,8 +513,8 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                 tsrp->status = srv_busy;
                 if (fidp) { /* File Server query */
                     lock_ReleaseWrite(&cm_serverLock);
-                    code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, 
-                                             CM_GETVOL_FLAG_NO_LRU_UPDATE, 
+                    code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
+                                             CM_GETVOL_FLAG_NO_LRU_UPDATE,
                                              &volp);
                     if (code == 0)
                         statep = cm_VolumeStateByID(volp, fidp->volume);
@@ -497,7 +524,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
             }
         }
         lock_ReleaseWrite(&cm_serverLock);
-        
+
         if (statep) {
             cm_UpdateVolumeStatus(volp, statep->ID);
             lock_ObtainRead(&cm_volumeLock);
@@ -508,7 +535,6 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
         if (free_svr_list) {
             cm_FreeServerList(serverspp, 0);
-            serverspp = NULL;
             serversp = NULL;
             free_svr_list = 0;
         }
@@ -517,59 +543,94 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
     /* special codes:  missing volumes */
     else if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE ||
-             errorCode == VSALVAGE || errorCode == VNOSERVICE || errorCode == VIO) 
-    {       
+             errorCode == VSALVAGE || errorCode == VNOSERVICE || errorCode == VIO)
+    {
         /* In case of timeout */
         reqp->volumeError = errorCode;
 
         switch ( errorCode ) {
         case VNOVOL:
            msgID = MSG_SERVER_REPORTS_VNOVOL;
-            format = "Server %s reported volume %d as not attached (does not exist).";
+            format = "Server %s reported volume %d in cell %s as not attached (may have been moved or deleted).";
             break;
         case VMOVED:
            msgID = MSG_SERVER_REPORTS_VMOVED;
-            format = "Server %s reported volume %d as moved.";
+            format = "Server %s reported volume %d in cell %s as moved.";
             break;
         case VOFFLINE:
            msgID = MSG_SERVER_REPORTS_VOFFLINE;
-            format = "Server %s reported volume %d as offline.";
+            format = "Server %s reported volume %d in cell %s as offline.";
             break;
         case VSALVAGE:
            msgID = MSG_SERVER_REPORTS_VSALVAGE;
-            format = "Server %s reported volume %d as needs salvage.";
+            format = "Server %s reported volume %d in cell %s as needs salvage.";
             break;
         case VNOSERVICE:
            msgID = MSG_SERVER_REPORTS_VNOSERVICE;
-            format = "Server %s reported volume %d as not in service.";
+            format = "Server %s reported volume %d in cell %s as not in service.";
             break;
         case VIO:
            msgID = MSG_SERVER_REPORTS_VIO;
-            format = "Server %s reported volume %d as temporarily unaccessible.";
+            format = "Server %s reported volume %d in cell %s as temporarily unaccessible.";
             break;
         }
 
-        if (serverp && fidp) {
-            /* Log server being offline for this volume */
-            sprintf(addr, "%d.%d.%d.%d", 
-                   ((serverp->addr.sin_addr.s_addr & 0xff)),
-                   ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
-                   ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
-                   ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); 
+        if (fidp) { /* File Server query */
+            if (serverp) {
+                /* Log server being unavailable for this volume */
+                sprintf(addr, "%d.%d.%d.%d",
+                         ((serverp->addr.sin_addr.s_addr & 0xff)),
+                         ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
+                         ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
+                         ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
+
+                osi_Log3(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume, cellp->name);
+                LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume, cellp->name);
+            }
 
-           osi_Log2(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume);
-           LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume);
-        }
+            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
+                                      CM_GETVOL_FLAG_NO_LRU_UPDATE,
+                                      &volp);
+            if (code == 0)
+                statep = cm_VolumeStateByID(volp, fidp->volume);
 
-        /* 
-         * Mark server offline for this volume or delete the volume
-         * from the server list if it was moved or is not present.
-         */
-        if (!serversp && fidp) {
-            code = cm_GetServerList(fidp, userp, reqp, &serverspp);
-            if (code == 0) {
-                serversp = *serverspp;
-                free_svr_list = 1;
+            if ((errorCode == VMOVED || errorCode == VNOVOL || errorCode == VOFFLINE) &&
+                !(reqp->flags & CM_REQ_VOLUME_UPDATED))
+            {
+                code = cm_ForceUpdateVolume(fidp, userp, reqp);
+                if (code == 0)
+                    location_updated = 1;
+
+                /* Even if the update fails, there might still be another replica */
+
+                reqp->flags |= CM_REQ_VOLUME_UPDATED;
+                osi_Log3(afsd_logp, "cm_Analyze called cm_ForceUpdateVolume cell %u vol %u code 0x%x",
+                        fidp->cell, fidp->volume, code);
+            }
+
+            if (statep) {
+                cm_UpdateVolumeStatus(volp, statep->ID);
+                osi_Log3(afsd_logp, "cm_Analyze NewVolState cell %u vol %u state %u",
+                         fidp->cell, fidp->volume, statep->state);
+            }
+
+            if (volp) {
+                lock_ObtainRead(&cm_volumeLock);
+                cm_PutVolume(volp);
+                lock_ReleaseRead(&cm_volumeLock);
+                volp = NULL;
+            }
+
+            /*
+             * Mark server offline for this volume or delete the volume
+             * from the server list if it was moved or is not present.
+             */
+            if (!serversp || location_updated) {
+                code = cm_GetServerList(fidp, userp, reqp, &serverspp);
+                if (code == 0) {
+                    serversp = *serverspp;
+                    free_svr_list = 1;
+                }
             }
         }
 
@@ -582,70 +643,36 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                      ((tsrp->server->addr.sin_addr.s_addr & 0xff)),
                      ((tsrp->server->addr.sin_addr.s_addr & 0xff00)>> 8),
                      ((tsrp->server->addr.sin_addr.s_addr & 0xff0000)>> 16),
-                     ((tsrp->server->addr.sin_addr.s_addr & 0xff000000)>> 24)); 
+                     ((tsrp->server->addr.sin_addr.s_addr & 0xff000000)>> 24));
 
-            if (tsrp->server == serverp) {
+            if (cm_ServerEqual(tsrp->server, serverp)) {
                 /* REDIRECT */
                 if (errorCode == VMOVED || errorCode == VNOVOL) {
-                    osi_Log2(afsd_logp, "volume %d not present on server %s", 
+                    osi_Log2(afsd_logp, "volume %d not present on server %s",
                              fidp->volume, osi_LogSaveString(afsd_logp,addr));
                     tsrp->status = srv_deleted;
                     if (fidp)
                         cm_RemoveVolumeFromServer(serverp, fidp->volume);
                 } else {
-                    osi_Log2(afsd_logp, "volume %d instance on server %s marked offline", 
+                    osi_Log2(afsd_logp, "volume %d instance on server %s marked offline",
                              fidp->volume, osi_LogSaveString(afsd_logp,addr));
                     tsrp->status = srv_offline;
                 }
                 /* break; */
             } else {
-                osi_Log3(afsd_logp, "volume %d exists on server %s with status %u", 
+                osi_Log3(afsd_logp, "volume %d exists on server %s with status %u",
                          fidp->volume, osi_LogSaveString(afsd_logp,addr), tsrp->status);
             }
-        }   
+        }
         lock_ReleaseWrite(&cm_serverLock);
 
         /* Free the server list before cm_ForceUpdateVolume is called */
         if (free_svr_list) {
             cm_FreeServerList(serverspp, 0);
-            serverspp = NULL;
             serversp = NULL;
             free_svr_list = 0;
         }
 
-        if (fidp) { /* File Server query */
-            code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, 
-                                      CM_GETVOL_FLAG_NO_LRU_UPDATE, 
-                                      &volp);
-            if (code == 0)
-                statep = cm_VolumeStateByID(volp, fidp->volume);
-
-            if ((errorCode == VMOVED || errorCode == VNOVOL) &&
-                !(reqp->flags & CM_REQ_VOLUME_UPDATED)) 
-            {
-                code = cm_ForceUpdateVolume(fidp, userp, reqp);
-                if (code) 
-                    timeLeft = 0;   /* prevent a retry on failure */
-                else
-                    reqp->flags |= CM_REQ_VOLUME_UPDATED;
-                osi_Log3(afsd_logp, "cm_Analyze called cm_ForceUpdateVolume cell %u vol %u code 0x%x",
-                        fidp->cell, fidp->volume, code);
-            }
-
-            if (statep) {
-                cm_UpdateVolumeStatus(volp, statep->ID);
-                osi_Log3(afsd_logp, "cm_Analyze NewVolState cell %u vol %u state %u", 
-                         fidp->cell, fidp->volume, statep->state);
-            }
-
-            if (volp) {
-                lock_ObtainRead(&cm_volumeLock);
-                cm_PutVolume(volp);
-                lock_ReleaseRead(&cm_volumeLock);
-                volp = NULL;
-            }
-        }
-
         if ( timeLeft > 2 )
             retry = 1;
     } else if ( errorCode == VNOVNODE ) {
@@ -662,11 +689,12 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                    pscp = cm_FindSCacheParent(scp);
 
                lock_ObtainWrite(&scp->rw);
+               scp->flags |= CM_SCACHEFLAG_DELETED;
                lock_ObtainWrite(&cm_scacheLock);
-               cm_RemoveSCacheFromHashTable(scp);
+                cm_AdjustScacheLRU(scp);
+                cm_RemoveSCacheFromHashTable(scp);
                lock_ReleaseWrite(&cm_scacheLock);
                 cm_LockMarkSCacheLost(scp);
-               scp->flags |= CM_SCACHEFLAG_DELETED;
                lock_ReleaseWrite(&scp->rw);
                cm_ReleaseSCache(scp);
 
@@ -690,36 +718,75 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
          * reported idle for longer than idleDeadTime
          * don't mark server as down but don't retry
          * this is to prevent the SMB session from timing out
-         * In addition, we log an event to the event log 
+         * In addition, we log an event to the event log
          */
 
         if (serverp) {
-            sprintf(addr, "%d.%d.%d.%d", 
+            sprintf(addr, "%d.%d.%d.%d",
                     ((serverp->addr.sin_addr.s_addr & 0xff)),
                     ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
                     ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
-                    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24)); 
+                    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
 
             LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_HARD_DEAD_TIME_EXCEEDED, addr);
             osi_Log1(afsd_logp, "cm_Analyze: hardDeadTime or idleDeadtime exceeded addr[%s]",
                      osi_LogSaveString(afsd_logp,addr));
             reqp->tokenIdleErrorServp = serverp;
             reqp->idleError++;
+        }
 
-            if (timeLeft > 2) {
-                if (!fidp) { /* vldb */
-                    retry = 1;
-                } else { /* file */
-                    cm_volume_t *volp = cm_GetVolumeByFID(fidp);
-                    if (volp) {
-                        if (fidp->volume == cm_GetROVolumeID(volp))
-                            retry = 1;
-                        cm_PutVolume(volp);
-                    }
+        if (timeLeft > 2) {
+            if (!fidp) { /* vldb */
+                retry = 1;
+            } else { /* file */
+                cm_volume_t *volp = cm_GetVolumeByFID(fidp);
+                if (volp) {
+                    if (fidp->volume == cm_GetROVolumeID(volp))
+                        retry = 1;
+                    cm_PutVolume(volp);
                 }
             }
         }
     }
+    else if (errorCode == RX_MSGSIZE) {
+        /*
+         * RPC failed because a transmitted rx packet
+         * may have grown larger than the path mtu.
+         * Force a retry and the Rx library will try
+         * with a smaller mtu size.
+         */
+
+        if (serverp)
+            sprintf(addr, "%d.%d.%d.%d",
+                    ((serverp->addr.sin_addr.s_addr & 0xff)),
+                    ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
+                    ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
+                    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
+
+        LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_MSGSIZE_EXCEEDED, addr);
+        osi_Log1(afsd_logp, "cm_Analyze: Path MTU may have been exceeded addr[%s]",
+                 osi_LogSaveString(afsd_logp,addr));
+
+        retry = 1;
+    }
+    else if (errorCode == CM_RX_RETRY_BUSY_CALL) {
+        /*
+         * RPC failed because the selected call channel
+         * is currently busy on the server.  Unconditionally
+         * retry the request so an alternate call channel can be used.
+         */
+        if (serverp)
+            sprintf(addr, "%d.%d.%d.%d",
+                    ((serverp->addr.sin_addr.s_addr & 0xff)),
+                    ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
+                    ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
+                    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
+
+        LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_BUSY_CALL_CHANNEL, addr);
+        osi_Log1(afsd_logp, "cm_Analyze: Retry RPC due to busy call channel addr[%s]",
+                 osi_LogSaveString(afsd_logp,addr));
+        retry = 1;
+    }
     else if (errorCode >= -64 && errorCode < 0) {
         /* mark server as down */
         if (serverp)
@@ -731,12 +798,12 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
 
         if (errorCode == RX_CALL_DEAD)
             osi_Log2(afsd_logp, "cm_Analyze: Rx Call Dead addr[%s] forcedNew[%s]",
-                     osi_LogSaveString(afsd_logp,addr), 
+                     osi_LogSaveString(afsd_logp,addr),
                      (reqp->flags & CM_REQ_NEW_CONN_FORCED ? "yes" : "no"));
         else
             osi_Log3(afsd_logp, "cm_Analyze: Rx Misc Error[%d] addr[%s] forcedNew[%s]",
                      errorCode,
-                     osi_LogSaveString(afsd_logp,addr), 
+                     osi_LogSaveString(afsd_logp,addr),
                      (reqp->flags & CM_REQ_NEW_CONN_FORCED ? "yes" : "no"));
 
         if (serverp) {
@@ -744,7 +811,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
             if (errorCode == RX_CALL_DEAD &&
                 (reqp->flags & CM_REQ_NEW_CONN_FORCED)) {
                 if (!(serverp->flags & CM_SERVERFLAG_DOWN)) {
-                    serverp->flags |= CM_SERVERFLAG_DOWN;
+                    _InterlockedOr(&serverp->flags, CM_SERVERFLAG_DOWN);
                     serverp->downTime = time(NULL);
                 }
             } else {
@@ -772,7 +839,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                 free(ucellp->ticketp);
                 ucellp->ticketp = NULL;
             }
-            ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
+            _InterlockedAnd(&ucellp->flags, ~CM_UCELLFLAG_RXKAD);
             ucellp->gen++;
             lock_ReleaseMutex(&userp->mx);
             if ( timeLeft > 2 )
@@ -885,78 +952,78 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
             case VL_INDEXERANGE    : s = "VL_INDEXERANGE";     break;
             case VL_MULTIPADDR     : s = "VL_MULTIPADDR";      break;
             case VL_BADMASK        : s = "VL_BADMASK";         break;
-           case CM_ERROR_NOSUCHCELL        : s = "CM_ERROR_NOSUCHCELL";         break;                         
-           case CM_ERROR_NOSUCHVOLUME      : s = "CM_ERROR_NOSUCHVOLUME";       break;                         
-           case CM_ERROR_TIMEDOUT          : s = "CM_ERROR_TIMEDOUT";           break;                 
-           case CM_ERROR_RETRY             : s = "CM_ERROR_RETRY";              break; 
-           case CM_ERROR_NOACCESS          : s = "CM_ERROR_NOACCESS";           break; 
-           case CM_ERROR_NOSUCHFILE        : s = "CM_ERROR_NOSUCHFILE";         break;                         
-           case CM_ERROR_STOPNOW           : s = "CM_ERROR_STOPNOW";            break;                         
-           case CM_ERROR_TOOBIG            : s = "CM_ERROR_TOOBIG";             break;                                 
-           case CM_ERROR_INVAL             : s = "CM_ERROR_INVAL";              break;                                 
-           case CM_ERROR_BADFD             : s = "CM_ERROR_BADFD";              break;                                 
-           case CM_ERROR_BADFDOP           : s = "CM_ERROR_BADFDOP";            break;                         
-           case CM_ERROR_EXISTS            : s = "CM_ERROR_EXISTS";             break;                                 
-           case CM_ERROR_CROSSDEVLINK      : s = "CM_ERROR_CROSSDEVLINK";       break;                         
-           case CM_ERROR_BADOP             : s = "CM_ERROR_BADOP";              break;                                 
-           case CM_ERROR_BADPASSWORD       : s = "CM_ERROR_BADPASSWORD";        break;         
-           case CM_ERROR_NOTDIR            : s = "CM_ERROR_NOTDIR";             break;                                 
-           case CM_ERROR_ISDIR             : s = "CM_ERROR_ISDIR";              break;                                 
-           case CM_ERROR_READONLY          : s = "CM_ERROR_READONLY";           break;                         
-           case CM_ERROR_WOULDBLOCK        : s = "CM_ERROR_WOULDBLOCK";         break;                         
-           case CM_ERROR_QUOTA             : s = "CM_ERROR_QUOTA";              break;                                 
-           case CM_ERROR_SPACE             : s = "CM_ERROR_SPACE";              break;                                 
-           case CM_ERROR_BADSHARENAME      : s = "CM_ERROR_BADSHARENAME";       break;                         
-           case CM_ERROR_BADTID            : s = "CM_ERROR_BADTID";             break;                                 
-           case CM_ERROR_UNKNOWN           : s = "CM_ERROR_UNKNOWN";            break;                         
-           case CM_ERROR_NOMORETOKENS      : s = "CM_ERROR_NOMORETOKENS";       break;                         
-           case CM_ERROR_NOTEMPTY          : s = "CM_ERROR_NOTEMPTY";           break;                         
-           case CM_ERROR_USESTD            : s = "CM_ERROR_USESTD";             break;                                 
-           case CM_ERROR_REMOTECONN        : s = "CM_ERROR_REMOTECONN";         break;                         
-           case CM_ERROR_ATSYS             : s = "CM_ERROR_ATSYS";              break;                                 
-           case CM_ERROR_NOSUCHPATH        : s = "CM_ERROR_NOSUCHPATH";         break;                         
-           case CM_ERROR_CLOCKSKEW         : s = "CM_ERROR_CLOCKSKEW";          break;                         
-           case CM_ERROR_BADSMB            : s = "CM_ERROR_BADSMB";             break;                                 
-           case CM_ERROR_ALLBUSY           : s = "CM_ERROR_ALLBUSY";            break;                         
-           case CM_ERROR_NOFILES           : s = "CM_ERROR_NOFILES";            break;                         
-           case CM_ERROR_PARTIALWRITE      : s = "CM_ERROR_PARTIALWRITE";       break;                         
-           case CM_ERROR_NOIPC             : s = "CM_ERROR_NOIPC";              break;                                 
-           case CM_ERROR_BADNTFILENAME     : s = "CM_ERROR_BADNTFILENAME";      break;                         
-           case CM_ERROR_BUFFERTOOSMALL    : s = "CM_ERROR_BUFFERTOOSMALL";     break;                         
-           case CM_ERROR_RENAME_IDENTICAL  : s = "CM_ERROR_RENAME_IDENTICAL";   break;                 
-           case CM_ERROR_ALLOFFLINE        : s = "CM_ERROR_ALLOFFLINE";         break;          
-           case CM_ERROR_AMBIGUOUS_FILENAME: s = "CM_ERROR_AMBIGUOUS_FILENAME"; break;  
-           case CM_ERROR_BADLOGONTYPE      : s = "CM_ERROR_BADLOGONTYPE";       break;             
-           case CM_ERROR_GSSCONTINUE       : s = "CM_ERROR_GSSCONTINUE";        break;         
-           case CM_ERROR_TIDIPC            : s = "CM_ERROR_TIDIPC";             break;              
-           case CM_ERROR_TOO_MANY_SYMLINKS : s = "CM_ERROR_TOO_MANY_SYMLINKS";  break;   
-           case CM_ERROR_PATH_NOT_COVERED  : s = "CM_ERROR_PATH_NOT_COVERED";   break;    
-           case CM_ERROR_LOCK_CONFLICT     : s = "CM_ERROR_LOCK_CONFLICT";      break;       
-           case CM_ERROR_SHARING_VIOLATION : s = "CM_ERROR_SHARING_VIOLATION";  break;   
-           case CM_ERROR_ALLDOWN           : s = "CM_ERROR_ALLDOWN";            break;             
-           case CM_ERROR_TOOFEWBUFS        : s = "CM_ERROR_TOOFEWBUFS";         break;                         
-           case CM_ERROR_TOOMANYBUFS       : s = "CM_ERROR_TOOMANYBUFS";        break;                         
+           case CM_ERROR_NOSUCHCELL        : s = "CM_ERROR_NOSUCHCELL";         break;
+           case CM_ERROR_NOSUCHVOLUME      : s = "CM_ERROR_NOSUCHVOLUME";       break;
+           case CM_ERROR_TIMEDOUT          : s = "CM_ERROR_TIMEDOUT";           break;
+           case CM_ERROR_RETRY             : s = "CM_ERROR_RETRY";              break;
+           case CM_ERROR_NOACCESS          : s = "CM_ERROR_NOACCESS";           break;
+           case CM_ERROR_NOSUCHFILE        : s = "CM_ERROR_NOSUCHFILE";         break;
+           case CM_ERROR_STOPNOW           : s = "CM_ERROR_STOPNOW";            break;
+           case CM_ERROR_TOOBIG            : s = "CM_ERROR_TOOBIG";             break;
+           case CM_ERROR_INVAL             : s = "CM_ERROR_INVAL";              break;
+           case CM_ERROR_BADFD             : s = "CM_ERROR_BADFD";              break;
+           case CM_ERROR_BADFDOP           : s = "CM_ERROR_BADFDOP";            break;
+           case CM_ERROR_EXISTS            : s = "CM_ERROR_EXISTS";             break;
+           case CM_ERROR_CROSSDEVLINK      : s = "CM_ERROR_CROSSDEVLINK";       break;
+           case CM_ERROR_BADOP             : s = "CM_ERROR_BADOP";              break;
+           case CM_ERROR_BADPASSWORD       : s = "CM_ERROR_BADPASSWORD";        break;
+           case CM_ERROR_NOTDIR            : s = "CM_ERROR_NOTDIR";             break;
+           case CM_ERROR_ISDIR             : s = "CM_ERROR_ISDIR";              break;
+           case CM_ERROR_READONLY          : s = "CM_ERROR_READONLY";           break;
+           case CM_ERROR_WOULDBLOCK        : s = "CM_ERROR_WOULDBLOCK";         break;
+           case CM_ERROR_QUOTA             : s = "CM_ERROR_QUOTA";              break;
+           case CM_ERROR_SPACE             : s = "CM_ERROR_SPACE";              break;
+           case CM_ERROR_BADSHARENAME      : s = "CM_ERROR_BADSHARENAME";       break;
+           case CM_ERROR_BADTID            : s = "CM_ERROR_BADTID";             break;
+           case CM_ERROR_UNKNOWN           : s = "CM_ERROR_UNKNOWN";            break;
+           case CM_ERROR_NOMORETOKENS      : s = "CM_ERROR_NOMORETOKENS";       break;
+           case CM_ERROR_NOTEMPTY          : s = "CM_ERROR_NOTEMPTY";           break;
+           case CM_ERROR_USESTD            : s = "CM_ERROR_USESTD";             break;
+           case CM_ERROR_REMOTECONN        : s = "CM_ERROR_REMOTECONN";         break;
+           case CM_ERROR_ATSYS             : s = "CM_ERROR_ATSYS";              break;
+           case CM_ERROR_NOSUCHPATH        : s = "CM_ERROR_NOSUCHPATH";         break;
+           case CM_ERROR_CLOCKSKEW         : s = "CM_ERROR_CLOCKSKEW";          break;
+           case CM_ERROR_BADSMB            : s = "CM_ERROR_BADSMB";             break;
+           case CM_ERROR_ALLBUSY           : s = "CM_ERROR_ALLBUSY";            break;
+           case CM_ERROR_NOFILES           : s = "CM_ERROR_NOFILES";            break;
+           case CM_ERROR_PARTIALWRITE      : s = "CM_ERROR_PARTIALWRITE";       break;
+           case CM_ERROR_NOIPC             : s = "CM_ERROR_NOIPC";              break;
+           case CM_ERROR_BADNTFILENAME     : s = "CM_ERROR_BADNTFILENAME";      break;
+           case CM_ERROR_BUFFERTOOSMALL    : s = "CM_ERROR_BUFFERTOOSMALL";     break;
+           case CM_ERROR_RENAME_IDENTICAL  : s = "CM_ERROR_RENAME_IDENTICAL";   break;
+           case CM_ERROR_ALLOFFLINE        : s = "CM_ERROR_ALLOFFLINE";         break;
+           case CM_ERROR_AMBIGUOUS_FILENAME: s = "CM_ERROR_AMBIGUOUS_FILENAME"; break;
+           case CM_ERROR_BADLOGONTYPE      : s = "CM_ERROR_BADLOGONTYPE";       break;
+           case CM_ERROR_GSSCONTINUE       : s = "CM_ERROR_GSSCONTINUE";        break;
+           case CM_ERROR_TIDIPC            : s = "CM_ERROR_TIDIPC";             break;
+           case CM_ERROR_TOO_MANY_SYMLINKS : s = "CM_ERROR_TOO_MANY_SYMLINKS";  break;
+           case CM_ERROR_PATH_NOT_COVERED  : s = "CM_ERROR_PATH_NOT_COVERED";   break;
+           case CM_ERROR_LOCK_CONFLICT     : s = "CM_ERROR_LOCK_CONFLICT";      break;
+           case CM_ERROR_SHARING_VIOLATION : s = "CM_ERROR_SHARING_VIOLATION";  break;
+           case CM_ERROR_ALLDOWN           : s = "CM_ERROR_ALLDOWN";            break;
+           case CM_ERROR_TOOFEWBUFS        : s = "CM_ERROR_TOOFEWBUFS";         break;
+           case CM_ERROR_TOOMANYBUFS       : s = "CM_ERROR_TOOMANYBUFS";        break;
             }
-            osi_Log2(afsd_logp, "cm_Analyze: ignoring error code 0x%x (%s)", 
+            osi_Log2(afsd_logp, "cm_Analyze: ignoring error code 0x%x (%s)",
                      errorCode, s);
             retry = 0;
         }
     }
 
     /* If not allowed to retry, don't */
-    if (!forcing_new && (reqp->flags & CM_REQ_NORETRY))
+    if (!forcing_new && (reqp->flags & CM_REQ_NORETRY) &&
+        (errorCode != RX_MSGSIZE && errorCode != CM_RX_RETRY_BUSY_CALL))
        retry = 0;
     else if (retry && dead_session)
         retry = 0;
 
-  out:
     /* drop this on the way out */
     if (connp)
         cm_PutConn(connp);
 
-    /* 
+    /*
      * clear the volume updated flag if we succeed.
-     * this way the flag will not prevent a subsequent volume 
+     * this way the flag will not prevent a subsequent volume
      * from being updated if necessary.
      */
     if (errorCode == 0)
@@ -988,7 +1055,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
 
 #ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
     timeUsed = (GetTickCount() - reqp->startTime) / 1000;
-        
+
     /* leave 5 seconds margin of safety */
     timeLeft =  ConnDeadtimeout - timeUsed - 5;
     hardTimeLeft = HardDeadtimeout - timeUsed - 5;
@@ -1001,7 +1068,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
 
         tsp = tsrp->server;
         if (reqp->tokenIdleErrorServp) {
-            /* 
+            /*
              * search the list until we find the server
              * that failed last time.  When we find it
              * clear the error, skip it and try the one
@@ -1033,7 +1100,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                         if (timeLeft > ConnDeadtimeout)
                             timeLeft = ConnDeadtimeout;
 
-                        if (hardTimeLeft > HardDeadtimeout) 
+                        if (hardTimeLeft > HardDeadtimeout)
                             hardTimeLeft = HardDeadtimeout;
 
                         lock_ObtainMutex(&(*connpp)->mx);
@@ -1052,12 +1119,12 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
             lock_ObtainRead(&cm_serverLock);
             cm_PutServerNoLock(tsp);
         }
-    }   
+    }
     lock_ReleaseRead(&cm_serverLock);
 
     if (firstError == 0) {
         if (allDown) {
-            firstError = (reqp->tokenError ? reqp->tokenError : 
+            firstError = (reqp->tokenError ? reqp->tokenError :
                           (reqp->idleError ? RX_CALL_TIMEOUT : CM_ERROR_ALLDOWN));
             /*
              * if we experienced either a token error or and idle dead time error
@@ -1096,6 +1163,7 @@ void cm_GCConnections(cm_server_t *serverp)
             cm_PutServer(tcp->serverp);
             cm_ReleaseUser(userp);
             *lcpp = tcp->nextp;
+            rx_SetConnSecondsUntilNatPing(tcp->rxconnp, 0);
             rx_DestroyConnection(tcp->rxconnp);
             lock_FinalizeMutex(&tcp->mx);
             free(tcp);
@@ -1146,7 +1214,7 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
         }
         secObjp = rxkad_NewClientSecurityObject(tcp->cryptlevel,
                                                 &ucellp->sessionKey, ucellp->kvno,
-                                                ucellp->ticketLen, ucellp->ticketp);    
+                                                ucellp->ticketLen, ucellp->ticketp);
     } else {
         /* normal auth */
         secIndex = 0;
@@ -1162,8 +1230,27 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
     rx_SetConnDeadTime(tcp->rxconnp, ConnDeadtimeout);
     rx_SetConnHardDeadTime(tcp->rxconnp, HardDeadtimeout);
     rx_SetConnIdleDeadTime(tcp->rxconnp, IdleDeadtimeout);
-    if (NatPingInterval)
+
+    /*
+     * Register the error to be returned on an idle dead timeout
+     */
+    rx_SetServerConnIdleDeadErr(tcp->rxconnp, RX_CALL_DEAD);
+
+    /*
+     * Let the Rx library know that we can auto-retry if an
+     * RX_MSGSIZE error is returned.
+     */
+    if (rx_pmtu_discovery)
+        rx_SetMsgsizeRetryErr(tcp->rxconnp, RX_MSGSIZE);
+
+    /*
+     * Attempt to limit NAT pings to the anonymous file server connections.
+     * Only file servers implement client callbacks and we only need one ping
+     * to be sent to each server.
+     */
+    if (NatPingInterval && serverp->type == CM_SERVER_FILE && secIndex == 0)
         rx_SetConnSecondsUntilNatPing(tcp->rxconnp, NatPingInterval);
+
     tcp->ucgen = ucellp->gen;
     if (secObjp)
         rxs_Release(secObjp);   /* Decrement the initial refCount */
@@ -1182,16 +1269,16 @@ long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
     lock_ObtainMutex(&userp->mx);
     lock_ObtainRead(&cm_connLock);
     for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
-        if (tcp->userp == userp) 
+        if (tcp->userp == userp)
             break;
     }
-    
+
     /* find ucell structure */
     ucellp = cm_GetUCell(userp, serverp->cellp);
     if (!tcp) {
         lock_ConvertRToW(&cm_connLock);
         for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
-            if (tcp->userp == userp) 
+            if (tcp->userp == userp)
                 break;
         }
         if (tcp) {
@@ -1228,6 +1315,7 @@ long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
             else
                 osi_Log0(afsd_logp, "cm_ConnByServer replace connection due to crypt change");
            tcp->flags &= ~CM_CONN_FLAG_FORCE_NEW;
+            rx_SetConnSecondsUntilNatPing(tcp->rxconnp, 0);
             rx_DestroyConnection(tcp->rxconnp);
             cm_NewRXConnection(tcp, ucellp, serverp);
         }
@@ -1275,13 +1363,13 @@ long cm_ServerAvailable(struct cm_fid *fidp, struct cm_user *userp)
                 allBusy = 0;
             }
         }
-    }   
+    }
     lock_ReleaseRead(&cm_serverLock);
     cm_FreeServerList(serverspp, 0);
 
     if (allDown)
        return 0;
-    else if (allBusy) 
+    else if (allBusy)
        return 0;
     else if (allOffline || (someBusy && someOffline))
        return 0;
@@ -1289,9 +1377,9 @@ long cm_ServerAvailable(struct cm_fid *fidp, struct cm_user *userp)
        return 1;
 }
 
-/* 
+/*
  * The returned cm_conn_t ** object is released in the subsequent call
- * to cm_Analyze().  
+ * to cm_Analyze().
  */
 long cm_ConnFromFID(struct cm_fid *fidp, struct cm_user *userp, cm_req_t *reqp,
                     cm_conn_t **connpp)