0

I am using the "NDIS MUX Intermediate Driver and Notify Object" driver on WEC2013 to simulate 3 different networks with one ethernet adapter (3 VELAN).

My board is running a Freescale iMX6 processor connected to a Marvell switch. The switch is programmed to have 3 VLAN, one for each network.

This NDIS driver ([https://code.msdn.microsoft.com/windowshardware/NDIS-MUX-Intermediate-3e97f538][1]) is supposed to support this kind of configuration.

On startup everything is working fine, but after 64 rx transactions, the driver starts receiving the same headers as at the beggining. If I check the TCP sequence number, it's look like transaction headers are wrapping around.

The driver uses the VLAN tag from the receive transaction to determine on which virtual ethernet lan this transaction is supposed to go. Then it removes the VLAN tag and send the transaction to the VELAN.

// Code used to Strip off VLAN TAG header

pDst = (PVOID)((PUCHAR)pFrame + VLAN_TAG_HEADER_SIZE);
RtlMoveMemory(pDst, pFrame, 2 * ETH_LENGTH_OF_ADDRESS);
NdisAdvanceNetBufferDataStart(NET_BUFFER_LIST_FIRST_NB(NetBufferList), VLAN_TAG_HEADER_SIZE, FALSE, NULL);*

// Code used to resend the transaction

NdisMIndicateReceiveNetBufferLists(pVElan->MiniportAdapterHandle, CurrentNetBufferList, PortNumber, 1, NewReceiveFlags);

After the transaction is handled by the upper protocol statck, the driver reinsert the VLAN tag before returning the netbufferlist.

// Codes to reinsert the tag

Status = NdisRetreatNetBufferDataStart(NET_BUFFER_LIST_FIRST_NB(NetBufferList),VLAN_TAG_HEADER_SIZE,0,NULL);
NdisMoveMemory(pFrame, pFrame + VLAN_TAG_HEADER_SIZE, (2 * ETH_LENGTH_OF_ADDRESS));
NdisMoveMemory(pFrame + (2 * ETH_LENGTH_OF_ADDRESS), &Tpid, 2);
NdisMoveMemory(pFrame + (2 * ETH_LENGTH_OF_ADDRESS) + sizeof(Tpid), &ReceiveNblEntry->TagHeader, 2);

I did many researches on the Net to know if it is legal or not to directly modify the net_buffer of a net_buffer_list and did not find a clear answer (I think it was not before NDIS 6 but with NDIS 6 it is ok).

If I comment the codes to remove and reinsert the VLAN tag, everything works fine (of course the transaction is not recognized at the upper level because of the tag). That's why I am not sure if it is legal to change the buffer directly. But this driver is supposed to work.

Any idea?

Jocelyn
  • 1
  • 2

1 Answers1

0

To solve my problem, I created a temporary buffer, copy the one received from the miniport driver and then I removed the tag from the copy and frowned the copy to the upper protocol layer.

This way, I never have to modify the original buffer and everything is now working fine.

Hope this will help someone else.

Jocelyn
  • 1
  • 2