]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: Make use of SMB interface a runtime decision
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 3 Sep 2011 22:13:31 +0000 (18:13 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Sun, 4 Sep 2011 15:49:45 +0000 (08:49 -0700)
Add 'smb_Enabled' and 'RDR_Initialized' flag variables.
Default smb_Enabled to true and RDR_Initialized to false.

Add registry value "SMBInterfaceEnabled" to permit disabling
the SMB interface.

If the redirector interface is initialized (a future set of
patchsets will add it) disable the SMB interface at runtime.

Change-Id: I354e121001d942421aa98490b62b710ac175051f
Reviewed-on: http://gerrit.openafs.org/5337
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
src/WINNT/afsd/afsd.h
src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_daemon.c
src/WINNT/afsd/smb.c

index fe932bcd05d25f0667ecb21dc4ea984f96b7ed98..47bfa9ead00e612b6fd1ab40eb3b27a26ebbdef6 100644 (file)
@@ -117,6 +117,10 @@ extern long rx_mtu;
 
 extern HANDLE WaitToTerminate;
 
+extern int RDR_Initialized;
+
+extern afs_uint32 smb_Enabled;
+
 #define DFS_SUPPORT 1
 #define LOG_PACKET 1
 #undef  NOTSERVICE
index edb4c340c989c1e6e22cf814788ce22cb1609788..26f61422436cad71326f9caf4d81ac37d8243e21 100644 (file)
@@ -77,6 +77,7 @@ int cm_logChunkSize;
 int cm_chunkSize;
 
 int smb_UseV3 = 1;
+afs_uint32 smb_Enabled = 1;
 
 int LANadapter;
 
@@ -1497,14 +1498,25 @@ int afsd_InitSMB(char **reasonP, void *aMBfunc)
             smb_AsyncStoreSize = CM_CONFIGDEFAULT_ASYNCSTORESIZE;
         afsi_log("SMBAsyncStoreSize = %d", smb_AsyncStoreSize);
 
+        dummyLen = sizeof(DWORD);
+        code = RegQueryValueEx(parmKey, "SMBInterfaceEnabled", NULL, NULL,
+                                (BYTE *) &dwValue, &dummyLen);
+        if (code == ERROR_SUCCESS)
+            smb_Enabled = dwValue ? 1 : 0;
+        afsi_log("SMBInterfaceEnabled = %d", smb_Enabled);
+
         RegCloseKey (parmKey);
     }
 
+    if ( smb_Enabled ) {
     /* Do this last so that we don't handle requests before init is done.
      * Here we initialize the SMB listener.
      */
     smb_Init(afsd_logp, smb_UseV3, numSvThreads, aMBfunc);
     afsi_log("smb_Init complete");
+    } else {
+        afsi_log("smb_Init skipped");
+    }
 
     return 0;
 }
index 1fb3fd0e68b107cfa7381c31edbbd591bcf83867..873e6d0211697bf6b98f0031d480e048907aa688 100644 (file)
@@ -56,6 +56,7 @@ extern HANDLE afsi_file;
 
 static int powerEventsRegistered = 0;
 extern int powerStateSuspended = 0;
+extern int RDR_Initialized = 0;
 
 static VOID (WINAPI* pRtlCaptureContext)(PCONTEXT ContextRecord) = NULL;
 
@@ -401,7 +402,7 @@ afsd_ServiceControlHandlerEx(
                    /* This is the message delivered once all devices are up */
                     afsi_log("SERVICE_CONTROL_APMRESUMEAUTOMATIC");
                    powerStateSuspended = 0;
-                   if (osVersion.dwMajorVersion >= 6) {
+                   if (smb_Enabled && osVersion.dwMajorVersion >= 6) {
                        smb_SetLanAdapterChangeDetected();
                     }
                     dwRet = NO_ERROR;
@@ -1326,12 +1327,23 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         /* Notify any volume status handlers that the cache manager has started */
         cm_VolStatus_Service_Started();
 
+        /*
+         * Set the default for the SMB interface based upon the state of the
+         * Redirector interface.
+         */
+        smb_Enabled = !RDR_Initialized;
+
         code = afsd_InitSMB(&reason, MessageBox);
-        if (code != 0) {
+        if (smb_Enabled && code != 0) {
             afsi_log("afsd_InitSMB failed: %s (code = %d)", reason, code);
             osi_panic(reason, __FILE__, __LINE__);
         }
 
+        if (!smb_Enabled && !RDR_Initialized) {
+            afsi_log("Neither RDR nor SMB interfaces available");
+            osi_panic(reason, __FILE__, __LINE__);
+        }
+
         /* allow an exit to be called post smb initialization */
         hHookDll = cm_LoadAfsdHookLib();
         if (hHookDll)
index 9f372b68d9132c30bcf524bdcc020c2ee09ec660..06118609455491d8aa26b59870d24127bbb6f116 100644 (file)
@@ -147,17 +147,20 @@ void cm_InitConn(void)
          * 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);
+            }
         }
        osi_EndOnce(&once);
     }
index c103308a03168af0b200df16410099dc3acf2d30..31cdaa0c3b88b02a78c0cb929242eb229dbfb2d6 100644 (file)
@@ -79,7 +79,8 @@ void cm_IpAddrDaemon(long parm)
         Result = NotifyAddrChange(NULL,NULL);
         if (Result == NO_ERROR && daemon_ShutdownFlag == 0) {
             lastIPAddrChange = osi_Time();
-            smb_SetLanAdapterChangeDetected();
+            if (smb_Enabled)
+                smb_SetLanAdapterChangeDetected();
             cm_SetLanAdapterChangeDetected();
             thrd_ResetEvent(cm_IPAddrDaemon_ShutdownEvent);
        }
index 79334c7f22ecf808db18529d0f83d4e7af2d5e69..25016aed569c0c2c0c38c5db636d7cdce0735667 100644 (file)
@@ -10390,6 +10390,9 @@ int smb_NetbiosInit(int locked)
     int lana_found = 0;
     lana_number_t lanaNum;
 
+    if (!smb_Enabled)
+        return 0;
+
     if (!locked)
         lock_ObtainMutex(&smb_StartedLock);
 
@@ -10574,6 +10577,9 @@ void smb_StartListeners(int locked)
     int lpid;
     thread_t phandle;
 
+    if (!smb_Enabled)
+        return;
+
     if (!locked)
         lock_ObtainMutex(&smb_StartedLock);
 
@@ -10614,6 +10620,9 @@ void smb_StartListeners(int locked)
 
 void smb_RestartListeners(int locked)
 {
+    if (!smb_Enabled)
+        return;
+
     if (!locked)
         lock_ObtainMutex(&smb_StartedLock);
 
@@ -10668,6 +10677,9 @@ void smb_StopListeners(int locked)
     NCB *ncbp;
     int lana, l;
 
+    if (!smb_Enabled)
+        return;
+
     if (!locked)
         lock_ObtainMutex(&smb_StartedLock);
 
@@ -10721,6 +10733,9 @@ void smb_Init(osi_log_t *logp, int useV3,
     char eventName[MAX_PATH];
     int startListeners = 0;
 
+    if (!smb_Enabled)
+        return;
+
     smb_MBfunc = aMBfunc;
 
     smb_useV3 = useV3;
@@ -11081,6 +11096,9 @@ void smb_Shutdown(void)
     afs_uint32 i;
     smb_vc_t *vcp;
 
+    if (!smb_Enabled)
+        return;
+
     /*fprintf(stderr, "Entering smb_Shutdown\n");*/
 
     /* setup the NCB system */
@@ -11323,10 +11341,12 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
     WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
 
 
+    if (!smb_Enabled)
+        goto done;
+
     sprintf(output, "begin dumping smb_waitingLockRequest_t\r\n");
     WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
 
-
     for ( wlrp = smb_allWaitingLocks; wlrp; wlrp = (smb_waitingLockRequest_t *) osi_QNext(&wlrp->q)) {
         smb_waitingLock_t *lockp;
 
@@ -11454,6 +11474,7 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
     sprintf(output, "done dumping DEAD smb_vc_t\r\n");
     WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
 
+  done:
     if (lock)
         lock_ReleaseRead(&smb_rctLock);
     return 0;
@@ -11462,6 +11483,10 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
 long smb_IsNetworkStarted(void)
 {
     long rc;
+
+    if (!smb_Enabled)
+        return 0;
+
     lock_ObtainWrite(&smb_globalLock);
     rc = (smb_ListenerState == SMB_LISTENER_STARTED && smbShutdownFlag == 0);
     lock_ReleaseWrite(&smb_globalLock);