|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] receiver: Fix the byte order of EtherType
EtherType was compared with ETHERNET_MTU without being converted to host
byte order first. This causes the comparison below to be incorrect.
Pass the TypeOrLength field to NTOHS, then annotate the EtherType field
in NET_BUFFER_LIST_RESERVED with its byte order.
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
src/xennet/receiver.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/xennet/receiver.c b/src/xennet/receiver.c
index 7fb3ed2..e449682 100644
--- a/src/xennet/receiver.c
+++ b/src/xennet/receiver.c
@@ -66,6 +66,7 @@ struct _XENNET_RECEIVER {
typedef struct _NET_BUFFER_LIST_RESERVED {
PVOID Cookie;
+ // Host order
USHORT EtherType;
} NET_BUFFER_LIST_RESERVED, *PNET_BUFFER_LIST_RESERVED;
@@ -169,9 +170,9 @@ __ReceiverAllocateNetBufferList(
Buffer = MmGetSystemAddressForMdlSafe(Mdl, NormalPagePriority |
MdlMappingNoExecute);
if (Buffer != NULL) {
EthernetHeader = (PETHERNET_HEADER)(Buffer + Offset +
Info->EthernetHeader.Offset);
- EtherType = ETHERNET_HEADER_IS_TAGGED(EthernetHeader) ?
- EthernetHeader->Tagged.TypeOrLength :
- EthernetHeader->Untagged.TypeOrLength;
+ EtherType = NTOHS(ETHERNET_HEADER_IS_TAGGED(EthernetHeader) ?
+ EthernetHeader->Tagged.TypeOrLength :
+ EthernetHeader->Untagged.TypeOrLength);
if (EtherType <= ETHERNET_MTU)
EtherType = 0;
}
--
2.56.0.windows.4
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |