Skip to content

Commit

Permalink
Fix failing tests, and collect ToS/TClass on Windows for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
anrossi committed Jan 27, 2025
1 parent fe5a6f3 commit 35eff60
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/platform/datapath_raw_xdp_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,7 @@ CxPlatDpRawTxAlloc(
Packet->Buffer.Length = Config->MaxPacketSize;
Packet->Buffer.Buffer = &Packet->FrameBuffer[HeaderBackfill.AllLayer];
Packet->ECN = Config->ECN;
Packet->DSCP = Config->DSCP;
Packet->DatapathType = Config->Route->DatapathType = CXPLAT_DATAPATH_TYPE_RAW;
}

Expand Down
24 changes: 12 additions & 12 deletions src/platform/datapath_winkernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ SocketCreateUdp(
CxPlatDataPathSetControlSocket(
Binding,
WskSetOption,
IPV6_ECN,
IPV6_RECVTCLASS,
IPPROTO_IPV6,
sizeof(Option),
&Option);
Expand All @@ -1499,7 +1499,7 @@ SocketCreateUdp(
"[data][%p] ERROR, %u, %s.",
Binding,
Status,
"Set IPV6_ECN");
"Set IPV6_RECVTCLASS");
goto Error;
}

Expand All @@ -1508,7 +1508,7 @@ SocketCreateUdp(
CxPlatDataPathSetControlSocket(
Binding,
WskSetOption,
IP_ECN,
IP_RECVTOS,
IPPROTO_IP,
sizeof(Option),
&Option);
Expand All @@ -1518,7 +1518,7 @@ SocketCreateUdp(
"[data][%p] ERROR, %u, %s.",
Binding,
Status,
"Set IP_ECN");
"Set IP_RECVTOS");
goto Error;
}

Expand Down Expand Up @@ -2070,7 +2070,7 @@ CxPlatDataPathSocketReceive(
SOCKADDR_INET LocalAddr = { 0 };
SOCKADDR_INET RemoteAddr;
UINT16 MessageLength = 0;
INT ECN = 0;
INT TOS = 0;
INT HopLimitTTL = 0;

//
Expand Down Expand Up @@ -2100,9 +2100,9 @@ CxPlatDataPathSocketReceive(
IsUnreachableError = TRUE;
break;
}
} else if (CMsg->cmsg_type == IPV6_ECN) {
ECN = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(ECN < UINT8_MAX);
} else if (CMsg->cmsg_type == IPV6_TCLASS) {
TOS = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(TOS <= UINT8_MAX);
} else if (CMsg->cmsg_type == IPV6_HOPLIMIT) {
HopLimitTTL = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(HopLimitTTL < 256);
Expand All @@ -2123,9 +2123,9 @@ CxPlatDataPathSocketReceive(
IsUnreachableError = TRUE;
break;
}
} else if (CMsg->cmsg_type == IP_ECN) {
ECN = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(ECN < UINT8_MAX);
} else if (CMsg->cmsg_type == IP_TOS) {
TOS = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(TOS <= UINT8_MAX);
} else if (CMsg->cmsg_type == IP_TTL) {
HopLimitTTL = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(HopLimitTTL < 256);
Expand Down Expand Up @@ -2295,7 +2295,7 @@ CxPlatDataPathSocketReceive(
Datagram->IoBlock = IoBlock;
Datagram->Data.Next = NULL;
Datagram->Data.PartitionIndex = (uint16_t)(CurProcNumber % Binding->Datapath->ProcCount);
Datagram->Data.TypeOfService = (uint8_t)ECN;
Datagram->Data.TypeOfService = (uint8_t)TOS;
Datagram->Data.HopLimitTTL = (uint8_t)HopLimitTTL;
Datagram->Data.Allocated = TRUE;
Datagram->Data.QueuedOnConnection = FALSE;
Expand Down
26 changes: 13 additions & 13 deletions src/platform/datapath_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ typedef struct DATAPATH_RX_IO_BLOCK {
RIO_CMSG_BASE_SIZE +
WSA_CMSG_SPACE(sizeof(IN6_PKTINFO)) + // IP_PKTINFO
WSA_CMSG_SPACE(sizeof(DWORD)) + // UDP_COALESCED_INFO
WSA_CMSG_SPACE(sizeof(INT)) + // IP_ECN
WSA_CMSG_SPACE(sizeof(INT)) + // IP_TOS
WSA_CMSG_SPACE(sizeof(INT)) // IP_HOP_LIMIT
];

Expand Down Expand Up @@ -1688,7 +1688,7 @@ SocketCreateUdp(
setsockopt(
SocketProc->Socket,
IPPROTO_IPV6,
IPV6_ECN,
IPV6_RECVTCLASS,
(char*)&Option,
sizeof(Option));
if (Result == SOCKET_ERROR) {
Expand All @@ -1698,7 +1698,7 @@ SocketCreateUdp(
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"Set IPV6_ECN");
"Set IPV6_RECVTCLASS");
Status = HRESULT_FROM_WIN32(WsaError);
goto Error;
}
Expand All @@ -1708,7 +1708,7 @@ SocketCreateUdp(
setsockopt(
SocketProc->Socket,
IPPROTO_IP,
IP_ECN,
IP_RECVTOS,
(char*)&Option,
sizeof(Option));
if (Result == SOCKET_ERROR) {
Expand All @@ -1718,7 +1718,7 @@ SocketCreateUdp(
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"Set IP_ECN");
"Set IP_RECVTOS");
Status = HRESULT_FROM_WIN32(WsaError);
goto Error;
}
Expand Down Expand Up @@ -3463,7 +3463,7 @@ CxPlatDataPathUdpRecvComplete(
UINT16 MessageLength = NumberOfBytesTransferred;
ULONG MessageCount = 0;
BOOLEAN IsCoalesced = FALSE;
INT ECN = 0;
INT TOS = 0;
INT HopLimitTTL = 0;
if (SocketProc->Parent->UseRio) {
PRIO_CMSG_BUFFER RioRcvMsg = (PRIO_CMSG_BUFFER)IoBlock->ControlBuf;
Expand All @@ -3484,9 +3484,9 @@ CxPlatDataPathUdpRecvComplete(
CxPlatConvertFromMappedV6(LocalAddr, LocalAddr);
LocalAddr->Ipv6.sin6_scope_id = PktInfo6->ipi6_ifindex;
FoundLocalAddr = TRUE;
} else if (CMsg->cmsg_type == IPV6_ECN) {
ECN = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(ECN < UINT8_MAX);
} else if (CMsg->cmsg_type == IPV6_TCLASS) {
TOS = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(TOS <= UINT8_MAX);
} else if (CMsg->cmsg_type == IPV6_HOPLIMIT) {
HopLimitTTL = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(HopLimitTTL < 256);
Expand All @@ -3500,9 +3500,9 @@ CxPlatDataPathUdpRecvComplete(
LocalAddr->Ipv4.sin_port = SocketProc->Parent->LocalAddress.Ipv6.sin6_port;
LocalAddr->Ipv6.sin6_scope_id = PktInfo->ipi_ifindex;
FoundLocalAddr = TRUE;
} else if (CMsg->cmsg_type == IP_ECN) {
ECN = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(ECN < UINT8_MAX);
} else if (CMsg->cmsg_type == IP_TOS) {
TOS = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(TOS <= UINT8_MAX);
} else if (CMsg->cmsg_type == IP_TTL) {
HopLimitTTL = *(PINT)WSA_CMSG_DATA(CMsg);
CXPLAT_DBG_ASSERT(HopLimitTTL < 256);
Expand Down Expand Up @@ -3563,7 +3563,7 @@ CxPlatDataPathUdpRecvComplete(
Datagram->Route = &IoBlock->Route;
Datagram->PartitionIndex =
SocketProc->DatapathProc->PartitionIndex % SocketProc->DatapathProc->Datapath->PartitionCount;
Datagram->TypeOfService = (uint8_t)ECN;
Datagram->TypeOfService = (uint8_t)TOS;
Datagram->HopLimitTTL = (uint8_t) HopLimitTTL;
Datagram->Allocated = TRUE;
Datagram->Route->DatapathType = Datagram->DatapathType = CXPLAT_DATAPATH_TYPE_NORMAL;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unittest/DataPathTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ TEST_P(DataPathTest, UdpDataRebind)
VERIFY_QUIC_SUCCESS(Client.GetInitStatus());
ASSERT_NE(nullptr, Client.Socket);

CXPLAT_SEND_CONFIG SendConfig = { &Client.Route, 0, CXPLAT_ECN_NON_ECT, 0, 0 };
CXPLAT_SEND_CONFIG SendConfig = { &Client.Route, 0, CXPLAT_ECN_NON_ECT, 0, RecvContext.Dscp };
auto ClientSendData = CxPlatSendDataAlloc(Client, &SendConfig);
ASSERT_NE(nullptr, ClientSendData);
auto ClientBuffer = CxPlatSendDataAllocBuffer(ClientSendData, ExpectedDataSize);
Expand Down

0 comments on commit 35eff60

Please sign in to comment.