Author: cgutman Date: Mon Mar 16 00:52:02 2015 New Revision: 66734
URL: http://svn.reactos.org/svn/reactos?rev=66734&view=rev Log: [IP] - Don't select disconnected interfaces as default - Only count prefix matches of non-zero length - Fixes connectivity with multiple NICs when one or more is disconnected
Modified: trunk/reactos/lib/drivers/ip/network/interface.c
Modified: trunk/reactos/lib/drivers/ip/network/interface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/inte... ============================================================================== --- trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] Mon Mar 16 00:52:02 2015 @@ -134,6 +134,11 @@ A2S(Address), A2S(Prefix))); #endif
+ /* Don't report matches for empty prefixes */ + if (Length == 0) { + return FALSE; + } + /* Check that initial integral bytes match */ while (Length > 8) { if (*pAddress++ != *pPrefix++) @@ -152,37 +157,48 @@ { KIRQL OldIrql; ULONG Index = 0; + ULONG IfStatus;
IF_LIST_ITER(CurrentIF);
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql); /* DHCP hack: Always return the adapter without an IP address */ ForEachInterface(CurrentIF) { - if (CurrentIF->Context) { - if (AddrIsUnspecified(&CurrentIF->Unicast)) { - TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); + if (CurrentIF->Context && AddrIsUnspecified(&CurrentIF->Unicast)) { + TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); + if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) && + (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) { return CurrentIF; } + TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql); } } EndFor(CurrentIF);
/* Try to continue from the next adapter */ ForEachInterface(CurrentIF) { - if (CurrentIF->Context) { - if (Index++ == NextDefaultAdapter) { + if (CurrentIF->Context && (Index++ == NextDefaultAdapter)) { + TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); + if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) && + (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) { NextDefaultAdapter++; - TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); return CurrentIF; } + TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql); } } EndFor(CurrentIF);
/* No luck, so we'll choose the first adapter this time */ + Index = 0; ForEachInterface(CurrentIF) { if (CurrentIF->Context) { - NextDefaultAdapter = 1; + Index++; TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); - return CurrentIF; + if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) && + (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) { + NextDefaultAdapter = Index; + return CurrentIF; + } + TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql); } } EndFor(CurrentIF);