According to this osr page:

http://www.osr.com/ddk/network/103ndisx_51pu.htm

NdisMEthIndicateReceive passes an NDIS_HANDLE (Specifically,
MiniportAdapterHandle), rather than the ETH_FILTER structure.  God knows why
this wasn't caught before but it did awfully strange stuff including the
occasional crash, and more importantly, seemingly randomly corrupting the
LAN_ADAPTER and IP_INTERFACE structures in tcpip.sys when we landed in
packet receiving in datalink/lan.c.  Fixed now.

svn path=/trunk/; revision=10276
This commit is contained in:
Art Yerkes 2004-07-24 04:48:01 +00:00
parent b477fd3439
commit a85dce53e9
5 changed files with 57 additions and 19 deletions

View file

@ -7,7 +7,9 @@
* REVISIONS: * REVISIONS:
* CSH 27/08-2000 Created * CSH 27/08-2000 Created
*/ */
#include <roscfg.h>
#include <ne2000.h> #include <ne2000.h>
#include <debug.h>
/* Null-terminated array of ports to probe. This is "semi-risky" (Don Becker). */ /* Null-terminated array of ports to probe. This is "semi-risky" (Don Becker). */
ULONG ProbeAddressList[] = { 0x280, 0x300, 0x320, 0x340, 0x360, 0x380, 0 }; ULONG ProbeAddressList[] = { 0x280, 0x300, 0x320, 0x340, 0x360, 0x380, 0 };
@ -921,6 +923,8 @@ VOID NICIndicatePacket(
#endif #endif
if (IndicateLength >= DRIVER_HEADER_SIZE) { if (IndicateLength >= DRIVER_HEADER_SIZE) {
NDIS_DbgPrint(MAX_TRACE,("Adapter->MiniportAdapterHandle: %x\n",
Adapter->MiniportAdapterHandle));
NdisMEthIndicateReceive(Adapter->MiniportAdapterHandle, NdisMEthIndicateReceive(Adapter->MiniportAdapterHandle,
NULL, NULL,
(PVOID)&Adapter->Lookahead, (PVOID)&Adapter->Lookahead,
@ -974,6 +978,8 @@ VOID NICReadPacket(
/* Skip packet */ /* Skip packet */
Adapter->NextPacket = Adapter->CurrentPage; Adapter->NextPacket = Adapter->CurrentPage;
} else { } else {
NDIS_DbgPrint(MAX_TRACE,("Adapter->MiniportAdapterHandle: %x\n",
Adapter->MiniportAdapterHandle));
NICIndicatePacket(Adapter); NICIndicatePacket(Adapter);
/* Go to the next free buffer in receive ring */ /* Go to the next free buffer in receive ring */
@ -1221,6 +1227,8 @@ VOID HandleReceive(
} else { } else {
NDIS_DbgPrint(MID_TRACE, ("Got a packet in the receive ring.\n")); NDIS_DbgPrint(MID_TRACE, ("Got a packet in the receive ring.\n"));
NDIS_DbgPrint(MAX_TRACE,("Adapter->MiniportAdapterHandle: %x\n",
Adapter->MiniportAdapterHandle));
/* Read packet from receive buffer ring */ /* Read packet from receive buffer ring */
NICReadPacket(Adapter); NICReadPacket(Adapter);
@ -1334,7 +1342,12 @@ VOID STDCALL MiniportHandleInterrupt(
/* Overflow. Handled almost the same way as a receive interrupt */ /* Overflow. Handled almost the same way as a receive interrupt */
Adapter->BufferOverflow = TRUE; Adapter->BufferOverflow = TRUE;
HandleReceive(Adapter); NDIS_DbgPrint(MAX_TRACE,("Adapter->MiniportAdapterHandle: %x\n",
Adapter->MiniportAdapterHandle));
if(Adapter->MiniportAdapterHandle)
HandleReceive(Adapter);
else
NDIS_DbgPrint(MAX_TRACE,("No miniport adapter yet\n"));
Adapter->InterruptStatus &= ~ISR_OVW; Adapter->InterruptStatus &= ~ISR_OVW;
break; break;
@ -1348,8 +1361,13 @@ VOID STDCALL MiniportHandleInterrupt(
case ISR_PRX: case ISR_PRX:
NDIS_DbgPrint(MID_TRACE, ("Receive interrupt.\n")); NDIS_DbgPrint(MID_TRACE, ("Receive interrupt.\n"));
HandleReceive(Adapter); NDIS_DbgPrint(MAX_TRACE,("Adapter->MiniportAdapterHandle: %x\n",
Adapter->MiniportAdapterHandle));
if(Adapter->MiniportAdapterHandle)
HandleReceive(Adapter);
else
NDIS_DbgPrint(MAX_TRACE,("No miniport adapter yet\n"));
Adapter->InterruptStatus &= ~(ISR_PRX | ISR_RXE); Adapter->InterruptStatus &= ~(ISR_PRX | ISR_RXE);
break; break;

View file

@ -7,7 +7,9 @@
* REVISIONS: * REVISIONS:
* CSH 27/08-2000 Created * CSH 27/08-2000 Created
*/ */
#include <roscfg.h>
#include <ne2000.h> #include <ne2000.h>
#include <debug.h>
#ifdef DBG #ifdef DBG
@ -163,7 +165,7 @@ NDIS_STATUS STDCALL MiniportInitialize(
NDIS_STATUS Status; NDIS_STATUS Status;
PNIC_ADAPTER Adapter; PNIC_ADAPTER Adapter;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); NDIS_DbgPrint(MAX_TRACE, ("Called (Adapter %X).\n", MiniportAdapterHandle));
/* Search for 802.3 media which is the only one we support */ /* Search for 802.3 media which is the only one we support */
for (i = 0; i < MediumArraySize; i++) { for (i = 0; i < MediumArraySize; i++) {

View file

@ -18,7 +18,7 @@
#ifdef DBG #ifdef DBG
/* See debug.h for debug/trace constants */ /* See debug.h for debug/trace constants */
DWORD DebugTraceLevel = 0; DWORD DebugTraceLevel = MIN_TRACE;
#endif /* DBG */ #endif /* DBG */

View file

@ -162,7 +162,8 @@ MiniIndicateData(
/* KIRQL OldIrql; */ /* KIRQL OldIrql; */
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
PADAPTER_BINDING AdapterBinding; PADAPTER_BINDING AdapterBinding;
static PVOID ReceiveHandler = 0;
NDIS_DbgPrint(DEBUG_MINIPORT, ("Called. Adapter (0x%X) HeaderBuffer (0x%X) " NDIS_DbgPrint(DEBUG_MINIPORT, ("Called. Adapter (0x%X) HeaderBuffer (0x%X) "
"HeaderBufferSize (0x%X) LookaheadBuffer (0x%X) LookaheadBufferSize (0x%X).\n", "HeaderBufferSize (0x%X) LookaheadBuffer (0x%X) LookaheadBufferSize (0x%X).\n",
Adapter, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize)); Adapter, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize));
@ -225,6 +226,25 @@ MiniIndicateData(
} }
#endif #endif
if( !ReceiveHandler )
ReceiveHandler =
*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler;
ASSERT( ReceiveHandler ==
*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler );
NDIS_DbgPrint
(MID_TRACE,
("XXX (%x) %x %x %x %x %x %x %x XXX\n",
*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler,
AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
MacReceiveContext,
HeaderBuffer,
HeaderBufferSize,
LookaheadBuffer,
LookaheadBufferSize,
PacketSize));
/* call the receive handler */ /* call the receive handler */
(*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)( (*AdapterBinding->ProtocolBinding->Chars.u4.ReceiveHandler)(
AdapterBinding->NdisOpenBlock.ProtocolBindingContext, AdapterBinding->NdisOpenBlock.ProtocolBindingContext,
@ -353,7 +373,7 @@ MiniEthReceiveComplete(
VOID STDCALL VOID STDCALL
MiniEthReceiveIndication( MiniEthReceiveIndication(
IN PETH_FILTER Filter, /* shouldn't be NDIS_HANDLE? */ IN NDIS_HANDLE MiniportAdapter,
IN NDIS_HANDLE MacReceiveContext, IN NDIS_HANDLE MacReceiveContext,
IN PCHAR Address, IN PCHAR Address,
IN PVOID HeaderBuffer, IN PVOID HeaderBuffer,
@ -364,7 +384,7 @@ MiniEthReceiveIndication(
/* /*
* FUNCTION: Receive indication function for Ethernet devices * FUNCTION: Receive indication function for Ethernet devices
* ARGUMENTS: * ARGUMENTS:
* Filter = Pointer to Ethernet filter * MiniportAdapter = Miniport Adapter Handle (PLOGICAL_ADAPTER)
* MacReceiveContext = MAC receive context handle * MacReceiveContext = MAC receive context handle
* Address = Pointer to destination Ethernet address * Address = Pointer to destination Ethernet address
* HeaderBuffer = Pointer to Ethernet header buffer * HeaderBuffer = Pointer to Ethernet header buffer
@ -374,15 +394,13 @@ MiniEthReceiveIndication(
* PacketSize = Total size of received packet * PacketSize = Total size of received packet
*/ */
{ {
if( Filter ) { MiniIndicateData(MiniportAdapter,
MiniIndicateData((PLOGICAL_ADAPTER)Filter->Miniport, MacReceiveContext,
MacReceiveContext, HeaderBuffer,
HeaderBuffer, HeaderBufferSize,
HeaderBufferSize, LookaheadBuffer,
LookaheadBuffer, LookaheadBufferSize,
LookaheadBufferSize, PacketSize);
PacketSize);
}
} }

View file

@ -4452,7 +4452,7 @@ typedef VOID
typedef VOID typedef VOID
(STDCALL *ETH_RCV_INDICATE_HANDLER)( (STDCALL *ETH_RCV_INDICATE_HANDLER)(
IN PETH_FILTER Filter, IN NDIS_HANDLE MiniportAdapter,
IN NDIS_HANDLE MacReceiveContext, IN NDIS_HANDLE MacReceiveContext,
IN PCHAR Address, IN PCHAR Address,
IN PVOID HeaderBuffer, IN PVOID HeaderBuffer,
@ -4986,7 +4986,7 @@ NdisMDeregisterIoPortRange(
PacketSize) \ PacketSize) \
{ \ { \
(*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->EthRxIndicateHandler)( \ (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->EthRxIndicateHandler)( \
(((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->FilterDbs.u.EthDB), \ (MiniportAdapterHandle), \
(MiniportReceiveContext), \ (MiniportReceiveContext), \
(HeaderBuffer), \ (HeaderBuffer), \
(HeaderBuffer), \ (HeaderBuffer), \