Re: Problem with the NDIS MUX IM driver (decapsulation not working)



Perhaps this is a problem concerning NDIS task offload. If the higher-level protocol (TCP/IP) and the lower-level miniport have enabled some TCP task offload contract, then the decapsulated packet you are indicating may not provide the necessary task offload information.

If you changed adapters recently, then the new one can have this feature and your old one didn't. If this is the case, then temporarily disabling the NDIS task offload features of the adapter using the adapter's NCPA advanced property tab should make the behavior "better". Then you have isolated the problem.

Read the comment in the PassThru MPQueryInformation routine concerning OID_TCP_TASK_OFFLOAD. Using this scheme you effectively disable NDIS task offload altogether.

Or, set the packet protocol ID to NDIS_PROTOCOL_ID_DEFAULT _ONLY_ in your decapsulated packets. You may want a separate NDIS packet pool for your decapsulated packets if you go this route. This should convince the higher level protocol that the packet is an "ordinary" packet (no NDIS task offload info).

Alternatively, you can look into the NDIS task offload details and try to emulate them.

In any case, look at NDIS Task Offload.

Good luck,

Thomas F. Divine, Windows DDK MVP
http://www.pcasua.com



<gauravl@xxxxxxxxx> wrote in message news:1117005218.323715.52610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm using the Win2003 DDK and MUX sample, building using ddk tools.
Running the driver on Win2003 machines.

I'm writing a MUX IM driver based on the sample to do some form of
'tunneling'.  I slap on my own ethernet header infront of the real
ethernet header (with a custom eth type) when sending packets down
(MiniportSendPackets).  When my IM receives a packet
(ProtocolReceivePacket, ProtocolReceive) with my header, I take it off
and send the packet up.

The problem i'm seeing is that the IM driver takes this extra header
off, but the higher layer protocols seem to get this packet with the
original tunneling header included.  I've verified that i take the
header off by stepping through my code in the debugger, and, I've
verified that higher protocols get the original packet by attaching
ethereal to the IM miniport.

Whats interesting is that this thing worked 2 weeks ago.  A couple of
things could have changed, but i've tried to roll back everything to
then, and i cant seem to get it to work.  One thing that i noticed
today is that earlier i was sure that my packets were coming in on
ProtocolReceivePacket.  Now i see all my packets coming in on
ProtocolReceive.  I'm wondering if this is a problem.  I've attached my
code snippet below.

I'm also suspicious of this line:
  NDIS_SET_ORIGINAL_PACKET(MyPacket,
NDIS_GET_ORIGINAL_PACKET(Packet));
Maybe someone in an upperlayer protocol is ignoring MyPacket and using
the OriginalPacket instead ?

Someone had posted in 2002 how they faced a similar issue - their IM
was stripping of part of the packet, yet upper layer protocoles were
getting the original packet.  Their problem was something to do with
retransmissions but it doesnt make sense here to me.

Anyone seen anything like this ?
I've been debugging this for 3 days now and i'm running out of ideas.
Suggestions/Hints/Comments welcome.

Thanks,

Gaurav

-------------------------------------------------------------

Heres how my code strips the header off (based off the MUX sample)
called from ProtocolReceice and ProtocolReceivePacket.

       //
       // Strip off the tag header "in place":
       //
       pDst = (PVOID)((PUCHAR)pVa + TAG_HEADER_SIZE);

       //
       // Allocate a new buffer descriptor for the first
       // buffer in the packet. This could very well be the
       // only buffer in the packet.
       //
       NdisAllocateBuffer(&Status,
                           &pNdisBuffer,
                           pVElan->BufferPoolHandle,
                           pDst,
                           BufferLength - TAG_HEADER_SIZE);

       if (Status != NDIS_STATUS_SUCCESS)
       {
           //
           // Drop the packet
           //
           Status = NDIS_STATUS_RESOURCES;
           MUX_INCR_STATISTICS(&pVElan->RcvResourceErrors);
           break;
       }

       //
       // Prepare the new packet to be indicated up: this consists
       // of the buffer chain starting with the second buffer,
       // appended to the first buffer set up in the previous step.
       //
       MyPacket->Private.Head =
NDIS_BUFFER_LINKAGE(Packet->Private.Head);

       //
       // Only one buffer in the packet
       //
       if (MyPacket->Private.Head == NULL)
       {
           OnlyOneBuffer = TRUE;
       }

       NdisChainBufferAtFront(MyPacket, pNdisBuffer);

       if (OnlyOneBuffer)
       {
           MyPacket->Private.Tail = MyPacket->Private.Head;
       }
       else
       {
           MyPacket->Private.Tail = Packet->Private.Tail;
       }
-------------------------------------------------------------


.