- Read the link state from the LAN_ADAPTER context to avoid having to block at DPC level in the send path

svn path=/trunk/; revision=66777
This commit is contained in:
Cameron Gutman 2015-03-18 02:29:28 +00:00
parent 3c9ba55a49
commit b8e34eb9ae
3 changed files with 19 additions and 29 deletions

View file

@ -10,7 +10,6 @@ UINT CountInterfaceAddresses( PIP_INTERFACE Interface );
NTSTATUS GetInterfaceSpeed( PIP_INTERFACE Interface, PUINT Speed );
NTSTATUS GetInterfaceName( PIP_INTERFACE Interface, PCHAR NameBuffer,
UINT NameMaxLen );
NTSTATUS GetInterfaceConnectionStatus( PIP_INTERFACE Interface,
PULONG OperStatus );
VOID GetInterfaceConnectionStatus( PIP_INTERFACE Interface, PULONG OperStatus );
PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address);
PIP_INTERFACE GetDefaultInterface(VOID);

View file

@ -51,11 +51,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
OutData->if_physaddrlen = Interface->AddressLength;
OutData->if_adminstatus = MIB_IF_ADMIN_STATUS_UP;
/* NDIS_HARDWARE_STATUS -> ROUTER_CONNECTION_STATE */
Status = GetInterfaceConnectionStatus( Interface, &OutData->if_operstatus );
/* Not sure what to do here, but not ready seems a safe bet on failure */
if( !NT_SUCCESS(Status) )
OutData->if_operstatus = NdisHardwareStatusNotReady;
GetInterfaceConnectionStatus( Interface, &OutData->if_operstatus );
IFDescr = (PCHAR)&OutData->if_descr[0];

View file

@ -166,10 +166,12 @@ PIP_INTERFACE GetDefaultInterface(VOID)
ForEachInterface(CurrentIF) {
if (CurrentIF->Context && AddrIsUnspecified(&CurrentIF->Unicast)) {
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) &&
(IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) {
GetInterfaceConnectionStatus(CurrentIF, &IfStatus);
if (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL) {
return CurrentIF;
}
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
}
} EndFor(CurrentIF);
@ -178,11 +180,13 @@ PIP_INTERFACE GetDefaultInterface(VOID)
ForEachInterface(CurrentIF) {
if (CurrentIF->Context && (Index++ == NextDefaultAdapter)) {
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) &&
(IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) {
GetInterfaceConnectionStatus(CurrentIF, &IfStatus);
if (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL) {
NextDefaultAdapter++;
return CurrentIF;
}
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
}
} EndFor(CurrentIF);
@ -193,11 +197,13 @@ PIP_INTERFACE GetDefaultInterface(VOID)
if (CurrentIF->Context) {
Index++;
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
if (NT_SUCCESS(GetInterfaceConnectionStatus(CurrentIF, &IfStatus)) &&
(IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL)) {
GetInterfaceConnectionStatus(CurrentIF, &IfStatus);
if (IfStatus == MIB_IF_OPER_STATUS_OPERATIONAL) {
NextDefaultAdapter = Index;
return CurrentIF;
}
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
}
} EndFor(CurrentIF);
@ -245,26 +251,15 @@ PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address)
return NULL;
}
NTSTATUS GetInterfaceConnectionStatus(PIP_INTERFACE Interface, PULONG Result)
VOID GetInterfaceConnectionStatus(PIP_INTERFACE Interface, PULONG Result)
{
NTSTATUS Status;
PLAN_ADAPTER Adapter = Interface->Context;
/* Query OID_GEN_MEDIA_CONNECT_STATUS for connection status information */
Status = TcpipLanGetDwordOid(Interface, OID_GEN_MEDIA_CONNECT_STATUS, Result);
if (!NT_SUCCESS(Status))
return Status;
/* Translate the result into MIB_IF_OPER_STATUS_XXX */
if (*Result == NdisMediaStateConnected)
{
/* Up and running */
/* Loopback has no adapter context */
if (Adapter == NULL || Adapter->State == LAN_STATE_STARTED) {
*Result = MIB_IF_OPER_STATUS_OPERATIONAL;
}
else
{
/* Down */
else {
*Result = MIB_IF_OPER_STATUS_DISCONNECTED;
}
return STATUS_SUCCESS;
}