mirror of
https://git.openafs.org/openafs.git
synced 2025-01-21 00:10:15 +00:00
Windows: No NCBRESET when probing Loopback after start
The Netbios NCBRESET command resets all of the Netbios state associated with the LAN adapter including the name bindings. In response to a detected LAN adapter IP address change, the smb_LanAdapterChange() function is called to determine if any Netbios LAN adapter bindings that were in use or should be in use by afsd_service were altered. As part of the check, lana_GetUncServerNameEx() is called which in turn calls lana_FindLoopback() which in turn issued a lana_IsLoopback() for each LAN adapter with the 'reset adapter' flag set to TRUE. Calling lana_IsLoopback() with 'reset' equal TRUE was fine when lana_GetUncServerNameEx() was only called from smb_Init(), but it is not fine when called after the service is processing calls. By resetting the adapter the binding of the netbios name "AFS" (or "<MACHINE>-AFS") is removed and all outstanding calls are canceled. If the SMB redirector attempts a reconnect during the window before NCBADDNAM is called to re-bind the name, a negative cache entry will be placed in the netbios name lookup table that will prevent the SMB redirector from connecting to the client for several minutes. If the environment is one in which frequent IP address change events are triggered, it is possible that the SMB redirector will never be able to reconnect to the service. This patchset adds a flag, LANA_NETBIOS_NO_RESET, to the lana_GetUncServerEx interface which permits smb_LanAdapterChange() to avoid the undesirable reset. This negative flag was selected in order to avoid changing the current default behavior as the lanahelper library is used by out of tree installers and it is preferred that OpenAFS avoid breaking them unnecessarily. Change-Id: I094af7b342d27c65025235888705af8af1a7d56e Reviewed-on: http://gerrit.openafs.org/3821 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
d12d2c08ee
commit
efe4a20c46
@ -365,7 +365,7 @@ extern "C" LANAINFO * lana_FindLanaByName(const char *LanaName)
|
|||||||
return lanainfo;
|
return lanainfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" lana_number_t lana_FindLoopback(void)
|
extern "C" lana_number_t lana_FindLoopback(BOOL reset)
|
||||||
{
|
{
|
||||||
NCB ncb;
|
NCB ncb;
|
||||||
LANA_ENUM lana_list;
|
LANA_ENUM lana_list;
|
||||||
@ -384,7 +384,7 @@ extern "C" lana_number_t lana_FindLoopback(void)
|
|||||||
return LANA_INVALID;
|
return LANA_INVALID;
|
||||||
}
|
}
|
||||||
for (i = 0; i < lana_list.length; i++) {
|
for (i = 0; i < lana_list.length; i++) {
|
||||||
if (lana_IsLoopback(lana_list.lana[i],TRUE)) {
|
if (lana_IsLoopback(lana_list.lana[i], reset)) {
|
||||||
// Found one, return it.
|
// Found one, return it.
|
||||||
#ifndef NOLOGGING
|
#ifndef NOLOGGING
|
||||||
afsi_log("lana_FindLoopback: Found LAN adapter %d",
|
afsi_log("lana_FindLoopback: Found LAN adapter %d",
|
||||||
@ -528,6 +528,7 @@ extern "C" BOOL lana_IsLoopback(lana_number_t lana, BOOL reset)
|
|||||||
// LANA_NETBIOS_NAME_IN : Use the values of *pLana and *pIsGateway as [in] parameters.
|
// LANA_NETBIOS_NAME_IN : Use the values of *pLana and *pIsGateway as [in] parameters.
|
||||||
// LANA_NETBIOS_NAME_SUFFIX : Only return the suffix of netbios name
|
// LANA_NETBIOS_NAME_SUFFIX : Only return the suffix of netbios name
|
||||||
// LANA_NETBIOS_NAME_FULL : Return full netbios name
|
// LANA_NETBIOS_NAME_FULL : Return full netbios name
|
||||||
|
// LANA_NETBIOS_NO_RESET : Do not reset the netbios adapter state when finding the loopback
|
||||||
extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int * pIsGateway, int flags) {
|
extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int * pIsGateway, int flags) {
|
||||||
HKEY hkConfig;
|
HKEY hkConfig;
|
||||||
DWORD dummyLen;
|
DWORD dummyLen;
|
||||||
@ -610,14 +611,14 @@ extern "C" long lana_GetUncServerNameEx(char *buffer, lana_number_t * pLana, int
|
|||||||
nLana = LANA_INVALID;
|
nLana = LANA_INVALID;
|
||||||
|
|
||||||
if(nLana == LANA_INVALID && !regGateway) {
|
if(nLana == LANA_INVALID && !regGateway) {
|
||||||
nLana = lana_FindLoopback();
|
nLana = lana_FindLoopback(!(flags & LANA_NETBIOS_NO_RESET));
|
||||||
}
|
}
|
||||||
if(nLana != LANA_INVALID)
|
if(nLana != LANA_INVALID)
|
||||||
regLana = nLana;
|
regLana = nLana;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(regNbName[0] &&
|
if(regNbName[0] &&
|
||||||
(regLana >=0 && lana_IsLoopback((lana_number_t) regLana,FALSE)))
|
(regLana >=0 && lana_IsLoopback((lana_number_t) regLana, FALSE)))
|
||||||
{
|
{
|
||||||
strncpy(nbName,regNbName,14);
|
strncpy(nbName,regNbName,14);
|
||||||
nbName[14] = 0;
|
nbName[14] = 0;
|
||||||
|
@ -49,11 +49,13 @@ extern "C" {
|
|||||||
|
|
||||||
#define LANA_NETBIOS_NAME_IN 2
|
#define LANA_NETBIOS_NAME_IN 2
|
||||||
|
|
||||||
|
#define LANA_NETBIOS_NO_RESET 4
|
||||||
|
|
||||||
int lana_GetNameFromGuid(char *Guid, char **Name);
|
int lana_GetNameFromGuid(char *Guid, char **Name);
|
||||||
|
|
||||||
struct LANAINFO * lana_FindLanaByName(const char *LanaName);
|
struct LANAINFO * lana_FindLanaByName(const char *LanaName);
|
||||||
|
|
||||||
lana_number_t lana_FindLoopback(void);
|
lana_number_t lana_FindLoopback(BOOL reset);
|
||||||
|
|
||||||
BOOL lana_OnlyLoopback(void);
|
BOOL lana_OnlyLoopback(void);
|
||||||
|
|
||||||
|
@ -10331,7 +10331,7 @@ void smb_LanAdapterChange(int locked) {
|
|||||||
|
|
||||||
if (!powerStateSuspended &&
|
if (!powerStateSuspended &&
|
||||||
SUCCEEDED(lana_GetUncServerNameEx(NetbiosName, &lanaNum, &bGateway,
|
SUCCEEDED(lana_GetUncServerNameEx(NetbiosName, &lanaNum, &bGateway,
|
||||||
LANA_NETBIOS_NAME_FULL)) &&
|
LANA_NETBIOS_NAME_FULL | LANA_NETBIOS_NO_RESET)) &&
|
||||||
lanaNum != LANA_INVALID && smb_LANadapter != lanaNum) {
|
lanaNum != LANA_INVALID && smb_LANadapter != lanaNum) {
|
||||||
if ( isGateway != bGateway ) {
|
if ( isGateway != bGateway ) {
|
||||||
afsi_log("Lan Adapter Change detected (%d != %d): gateway %d != %d",
|
afsi_log("Lan Adapter Change detected (%d != %d): gateway %d != %d",
|
||||||
@ -10399,7 +10399,10 @@ int smb_NetbiosInit(int locked)
|
|||||||
/* setup the NCB system */
|
/* setup the NCB system */
|
||||||
ncbp = smb_GetNCB();
|
ncbp = smb_GetNCB();
|
||||||
|
|
||||||
/* Call lanahelper to get Netbios name, lan adapter number and gateway flag */
|
/*
|
||||||
|
* Call lanahelper to get Netbios name, lan adapter number and gateway flag
|
||||||
|
* This will reset all of the network adapter's netbios state.
|
||||||
|
*/
|
||||||
if (SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
|
if (SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
|
||||||
smb_LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
|
smb_LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user