Skip to content

Commit b442e8a

Browse files
return error if xdp not available
1 parent 7f6d88e commit b442e8a

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/platform/datapath_winuser.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,15 +1734,6 @@ SocketCreateUdp(
17341734
// expected if multiple server processes were configured to share
17351735
// the same UDP and/or TCP port.
17361736
//
1737-
QuicTraceLogWarning(
1738-
DatapathCibirWarning,
1739-
"[data][%p] CIBIR detected, %s",
1740-
Socket,
1741-
"ignoring port collision by assuming some \
1742-
other MsQuic CIBIR process has reserved the OS port. \
1743-
Let's continue with initialization and skip port reservation.");
1744-
CxPlatRefInitializeEx(&Socket->RefCount, 1);
1745-
Socket->SkipCreatingOsSockets = TRUE;
17461737
BOOLEAN XdpAvailable = Datapath->RawDataPath != NULL;
17471738
BOOLEAN XdpEnabled = Config->Flags & CXPLAT_SOCKET_FLAG_XDP;
17481739
if (!XdpAvailable || !XdpEnabled) {
@@ -1753,7 +1744,19 @@ SocketCreateUdp(
17531744
!XdpAvailable ?
17541745
"but XDP not available. NO TRAFFIC WILL FLOW ON THIS LISTENER." :
17551746
"but XPD not enabled. NO TRAFFIC WILL FLOW ON THIS LISTENER.");
1747+
Status = QUIC_STATUS_INVALID_STATE;
1748+
goto Error;
17561749
}
1750+
1751+
QuicTraceLogWarning(
1752+
DatapathCibirWarning,
1753+
"[data][%p] CIBIR detected, %s",
1754+
Socket,
1755+
"ignoring port collision by assuming some \
1756+
other MsQuic CIBIR process has reserved the OS port. \
1757+
Let's continue with initialization and skip port reservation.");
1758+
CxPlatRefInitializeEx(&Socket->RefCount, 1);
1759+
Socket->SkipCreatingOsSockets = TRUE;
17571760
goto Skip;
17581761
}
17591762

src/platform/unittest/DataPathTest.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ TEST_P(DataPathTest, UdpDataShareCibirUdpPort) {
862862
//
863863
// Set CibirIdLength to some non-zero value to trigger the cibir path in the datapath code,
864864
// which should allow multiple cxplat sockets to be created on the same udp port so long as
865-
// cibir is configured.
865+
// cibir is configured. Now, since this test is executed without XDP being enabled, we should
866+
// expect a QUIC_STATUS_INVALID_STATE instead of QUIC_STATUS_ADDRESS_IN_USE.
866867
//
867868
Server1.CibirIdLength = 8;
868869
Server1.CreateUdp(Datapath, &unspecAddress.SockAddr, nullptr, &RecvContext);
@@ -872,11 +873,21 @@ TEST_P(DataPathTest, UdpDataShareCibirUdpPort) {
872873
}
873874
VERIFY_QUIC_SUCCESS(Server1.GetInitStatus());
874875
ASSERT_NE(nullptr, Server1.Socket);
876+
877+
//
878+
// Try creating a CIBIR-aware socket on the same port.
879+
//
875880
CxPlatSocket Server2;
876881
Server2.CibirIdLength = 8;
877882
Server2.CreateUdp(Datapath, &unspecAddress.SockAddr, nullptr, &RecvContext);
878-
VERIFY_QUIC_SUCCESS(Server2.GetInitStatus());
879-
ASSERT_NE(nullptr, Server2.Socket);
883+
ASSERT_EQ(QUIC_STATUS_INVALID_STATE, Server2.GetInitStatus());
884+
885+
//
886+
// Try creating a non-CIBIR-aware socket on the same port.
887+
//
888+
CxPlatSocket Server3;
889+
Server3.CreateUdp(Datapath, &unspecAddress.SockAddr, nullptr, &RecvContext);
890+
ASSERT_EQ(QUIC_STATUS_ADDRESS_IN_USE, Server3.GetInitStatus());
880891
}
881892

882893
TEST_P(DataPathTest, UdpDataPolling)

0 commit comments

Comments
 (0)