]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-plug-n-play-network-fix-20070307
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 7 Mar 2007 18:13:25 +0000 (18:13 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 7 Mar 2007 18:13:25 +0000 (18:13 +0000)
Move the detection of which LAN adapter to use from smb_Init to
smb_NetbiosInit so that it is executed after the service is resumed
via a power management event.  Otherwise, when the network comes back
up the service attempts to bind to all LAN adapters instead of just
the loopback or the configured one.

src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/smb.c
src/WINNT/afsd/smb.h

index 0606a2e2717cb26b0a1a4e36922d33051de14490..9caf5f3f1ac594d4d1dd6a96f926c1f96caf02e2 100644 (file)
@@ -76,8 +76,6 @@ char cm_CachePath[MAX_PATH];
 DWORD cm_CachePathLen;
 DWORD cm_ValidateCache = 1;
 
-BOOL isGateway = FALSE;
-
 BOOL reportSessionStartups = FALSE;
 
 cm_initparams_v1 cm_initParams;
@@ -566,7 +564,6 @@ int afsd_InitCM(char **reasonP)
     long code;
     /*int freelanceEnabled;*/
     WSADATA WSAjunk;
-    lana_number_t lanaNum;
     int i;
     char *p, *q; 
     int cm_noIPAddr;         /* number of client network interfaces */
@@ -1079,25 +1076,6 @@ int afsd_InitCM(char **reasonP)
     
     RegCloseKey (parmKey);
 
-    /* Call lanahelper to get Netbios name, lan adapter number and gateway flag */
-    if (SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
-        LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
-
-        if (LANadapter != -1)
-            afsi_log("LAN adapter number %d", LANadapter);
-        else
-            afsi_log("LAN adapter number not determined");
-
-        if (isGateway)
-            afsi_log("Set for gateway service");
-
-        afsi_log("Using >%s< as SMB server name", cm_NetbiosName);
-    } else {
-        /* something went horribly wrong.  We can't proceed without a netbios name */
-        StringCbPrintfA(buf,sizeof(buf),"Netbios name could not be determined: %li", code);
-        osi_panic(buf, __FILE__, __LINE__);
-    }
-
     cacheBlocks = ((afs_uint64)cacheSize * 1024) / CM_CONFIGDEFAULT_BLOCKSIZE;
         
     /* get network related info */
@@ -1321,7 +1299,7 @@ int afsd_InitSMB(char **reasonP, void *aMBfunc)
     /* Do this last so that we don't handle requests before init is done.
      * Here we initialize the SMB listener.
      */
-    smb_Init(afsd_logp, cm_NetbiosName, smb_UseV3, LANadapter, numSvThreads, aMBfunc);
+    smb_Init(afsd_logp, smb_UseV3, numSvThreads, aMBfunc);
     afsi_log("smb_Init complete");
 
     return 0;
index 76c860a52cb44fa0cfd4a8dee3c9c012e3676805..8c877fa7ac45af414d79eb704ab59f3e81d223f7 100644 (file)
@@ -60,6 +60,8 @@ osi_mutex_t  smb_ListenerLock;
 char smb_LANadapter;
 unsigned char smb_sharename[NCBNAMSZ+1] = {0};
 
+BOOL isGateway = FALSE;
+
 /* for debugging */
 long smb_maxObsConcurrentCalls=0;
 long smb_concurrentCalls=0;
@@ -8156,10 +8158,40 @@ int smb_NetbiosInit(void)
     int delname_tried=0;
     int len;
     int lana_found = 0;
+    lana_number_t lanaNum;
 
     /* setup the NCB system */
     ncbp = GetNCB();
 
+    /* Call lanahelper to get Netbios name, lan adapter number and gateway flag */
+    if (SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
+        smb_LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
+
+        if (smb_LANadapter != -1)
+           afsi_log("LAN adapter number %d", smb_LANadapter);
+        else
+           afsi_log("LAN adapter number not determined");
+
+        if (isGateway)
+           afsi_log("Set for gateway service");
+
+        afsi_log("Using >%s< as SMB server name", cm_NetbiosName);
+    } else {
+        /* something went horribly wrong.  We can't proceed without a netbios name */
+        char buf[128];
+        StringCbPrintfA(buf,sizeof(buf),"Netbios name could not be determined: %li", code);
+        osi_panic(buf, __FILE__, __LINE__);
+    }
+
+    /* remember the name */
+    len = (int)strlen(cm_NetbiosName);
+    if (smb_localNamep)
+        free(smb_localNamep);
+    smb_localNamep = malloc(len+1);
+    strcpy(smb_localNamep, cm_NetbiosName);
+    afsi_log("smb_localNamep is >%s<", smb_localNamep);
+
+
     if (smb_LANadapter == -1) {
         ncbp->ncb_command = NCBENUM;
         ncbp->ncb_buffer = (PUCHAR)&lana_list;
@@ -8366,7 +8398,7 @@ void smb_StopListeners(void)
     Sleep(1000);       /* give the listener threads a chance to exit */
 }
 
-void smb_Init(osi_log_t *logp, char *snamep, int useV3, int LANadapt,
+void smb_Init(osi_log_t *logp, int useV3,
               int nThreads
               , void *aMBfunc
   )
@@ -8375,7 +8407,6 @@ void smb_Init(osi_log_t *logp, char *snamep, int useV3, int LANadapt,
     thread_t phandle;
     int lpid;
     INT_PTR i;
-    int len;
     struct tm myTime;
     EVENT_HANDLE retHandle;
     char eventName[MAX_PATH];
@@ -8385,7 +8416,6 @@ void smb_Init(osi_log_t *logp, char *snamep, int useV3, int LANadapt,
     smb_MBfunc = aMBfunc;
 
     smb_useV3 = useV3;
-    smb_LANadapter = LANadapt;
 
     /* Initialize smb_localZero */
     myTime.tm_isdst = -1;              /* compute whether on DST or not */
@@ -8409,12 +8439,6 @@ void smb_Init(osi_log_t *logp, char *snamep, int useV3, int LANadapt,
     /* initialize the remote debugging log */
     smb_logp = logp;
         
-    /* remember the name */
-    len = (int)strlen(snamep);
-    smb_localNamep = malloc(len+1);
-    strcpy(smb_localNamep, snamep);
-    afsi_log("smb_localNamep is >%s<", smb_localNamep);
-
     /* and the global lock */
     lock_InitializeRWLock(&smb_globalLock, "smb global lock");
     lock_InitializeRWLock(&smb_rctLock, "smb refct and tree struct lock");
index 0ea432f69b4dd540dee4af1e36c854318cdc01e8..656408b6f1d23b0f8ae14c34cd4f4337f4f04609 100644 (file)
@@ -510,7 +510,7 @@ typedef struct smb_dispatch {
 
 /* prototypes */
 
-extern void smb_Init(osi_log_t *logp, char *smbNamep, int useV3, int LANadapt,
+extern void smb_Init(osi_log_t *logp, int useV3,
        int nThreads
         , void *aMBfunc
   );