mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:52:59 +00:00
[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 svn path=/trunk/; revision=66734
This commit is contained in:
parent
4d9ed8332c
commit
7dbea55bd3
1 changed files with 24 additions and 8 deletions
|
@ -134,6 +134,11 @@ BOOLEAN HasPrefix(
|
||||||
A2S(Address), A2S(Prefix)));
|
A2S(Address), A2S(Prefix)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Don't report matches for empty prefixes */
|
||||||
|
if (Length == 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check that initial integral bytes match */
|
/* Check that initial integral bytes match */
|
||||||
while (Length > 8) {
|
while (Length > 8) {
|
||||||
if (*pAddress++ != *pPrefix++)
|
if (*pAddress++ != *pPrefix++)
|
||||||
|
@ -152,37 +157,48 @@ PIP_INTERFACE GetDefaultInterface(VOID)
|
||||||
{
|
{
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
ULONG Index = 0;
|
ULONG Index = 0;
|
||||||
|
ULONG IfStatus;
|
||||||
|
|
||||||
IF_LIST_ITER(CurrentIF);
|
IF_LIST_ITER(CurrentIF);
|
||||||
|
|
||||||
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||||
/* DHCP hack: Always return the adapter without an IP address */
|
/* DHCP hack: Always return the adapter without an IP address */
|
||||||
ForEachInterface(CurrentIF) {
|
ForEachInterface(CurrentIF) {
|
||||||
if (CurrentIF->Context) {
|
if (CurrentIF->Context && AddrIsUnspecified(&CurrentIF->Unicast)) {
|
||||||
if (AddrIsUnspecified(&CurrentIF->Unicast)) {
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) &&
|
||||||
|
(IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) {
|
||||||
return CurrentIF;
|
return CurrentIF;
|
||||||
}
|
}
|
||||||
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||||
}
|
}
|
||||||
} EndFor(CurrentIF);
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
/* Try to continue from the next adapter */
|
/* Try to continue from the next adapter */
|
||||||
ForEachInterface(CurrentIF) {
|
ForEachInterface(CurrentIF) {
|
||||||
if (CurrentIF->Context) {
|
if (CurrentIF->Context && (Index++ == NextDefaultAdapter)) {
|
||||||
if (Index++ == NextDefaultAdapter) {
|
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||||
|
if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) &&
|
||||||
|
(IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) {
|
||||||
NextDefaultAdapter++;
|
NextDefaultAdapter++;
|
||||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
|
||||||
return CurrentIF;
|
return CurrentIF;
|
||||||
}
|
}
|
||||||
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||||
}
|
}
|
||||||
} EndFor(CurrentIF);
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
/* No luck, so we'll choose the first adapter this time */
|
/* No luck, so we'll choose the first adapter this time */
|
||||||
|
Index = 0;
|
||||||
ForEachInterface(CurrentIF) {
|
ForEachInterface(CurrentIF) {
|
||||||
if (CurrentIF->Context) {
|
if (CurrentIF->Context) {
|
||||||
NextDefaultAdapter = 1;
|
Index++;
|
||||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
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);
|
} EndFor(CurrentIF);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue