Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for both Qtip and UDP traffic for Server Listeners. #4803

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
63a4f6f
first iteration
ProjectsByJackHe Feb 7, 2025
4312eea
test code sanity check
ProjectsByJackHe Feb 7, 2025
f865630
full revert
ProjectsByJackHe Feb 7, 2025
19354ee
test this out
ProjectsByJackHe Feb 10, 2025
a2511c3
update control.cpp as well
ProjectsByJackHe Feb 10, 2025
2db51dd
update all instances of connAndPing
ProjectsByJackHe Feb 10, 2025
0a1ec39
sanity check
ProjectsByJackHe Feb 10, 2025
07aedfd
do not define multiple of these registrations
ProjectsByJackHe Feb 10, 2025
ae85b9f
turn QTIP off right after Listener.Start
ProjectsByJackHe Feb 11, 2025
cf38283
don't pass nullptr as size
ProjectsByJackHe Feb 11, 2025
1c9fa0b
revert back to old code - useqtip test SHOULD fail
ProjectsByJackHe Feb 11, 2025
93ff078
move the server config instantiation after we set qtip to be off
ProjectsByJackHe Feb 11, 2025
ba3c146
add sanity checks
ProjectsByJackHe Feb 11, 2025
c7b920a
fix sanity check
ProjectsByJackHe Feb 11, 2025
ebd9fd9
revise sanity check
ProjectsByJackHe Feb 11, 2025
5b2de37
better sanity check
ProjectsByJackHe Feb 12, 2025
b590242
set socket->usetcp to always false and see what happens when we enabl…
ProjectsByJackHe Feb 13, 2025
5486743
resolve warning for winkernel
ProjectsByJackHe Feb 13, 2025
1495588
add a couple of setparams
ProjectsByJackHe Feb 13, 2025
cae946f
add a few getparams
ProjectsByJackHe Feb 13, 2025
6629817
remember to generate cs
ProjectsByJackHe Feb 14, 2025
1adaad5
resolve merge conflicts
ProjectsByJackHe Feb 14, 2025
455b833
adjust hex
ProjectsByJackHe Feb 14, 2025
1c0c411
proper parameter definitions
ProjectsByJackHe Feb 14, 2025
0f5a6c6
delete include
ProjectsByJackHe Feb 14, 2025
a68f0f5
don't hardcode 0
ProjectsByJackHe Feb 14, 2025
64a9dff
add back removed include
ProjectsByJackHe Feb 14, 2025
38ba016
try and see if this works
ProjectsByJackHe Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -6754,6 +6754,26 @@
break;
#endif

#ifdef QUIC_API_ENABLE_PREVIEW_FEATURES
ProjectsByJackHe marked this conversation as resolved.
Show resolved Hide resolved
case QUIC_PARAM_CONN_SEND_QTIP:
if (BufferLength != sizeof(BOOLEAN) || Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;

Check warning on line 6761 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L6759-L6761

Added lines #L6759 - L6761 were not covered by tests
}
Connection->State.SendViaQtip = *(BOOLEAN*)Buffer;
Status = QUIC_STATUS_SUCCESS;
break;

Check warning on line 6765 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L6763-L6765

Added lines #L6763 - L6765 were not covered by tests

case QUIC_PARAM_CONN_RECV_QTIP:
if (BufferLength != sizeof(BOOLEAN) || Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;

Check warning on line 6770 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L6768-L6770

Added lines #L6768 - L6770 were not covered by tests
}
Connection->State.RecvViaQtip = *(BOOLEAN*)Buffer;
Status = QUIC_STATUS_SUCCESS;
break;

Check warning on line 6774 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L6772-L6774

Added lines #L6772 - L6774 were not covered by tests
#endif

default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
Expand Down Expand Up @@ -7284,6 +7304,42 @@
Status = QUIC_STATUS_SUCCESS;
break;

#ifdef QUIC_API_ENABLE_PREVIEW_FEATURES
case QUIC_PARAM_CONN_SEND_QTIP:
if (*BufferLength < sizeof(BOOLEAN)) {
*BufferLength = sizeof(BOOLEAN);
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
break;

Check warning on line 7312 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7309-L7312

Added lines #L7309 - L7312 were not covered by tests
}

if (Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;

Check warning on line 7317 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7315-L7317

Added lines #L7315 - L7317 were not covered by tests
}

*BufferLength = sizeof(BOOLEAN);
*(BOOLEAN*)Buffer = Connection->State.SendViaQtip;

Check warning on line 7321 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7320-L7321

Added lines #L7320 - L7321 were not covered by tests

Status = QUIC_STATUS_SUCCESS;
break;

Check warning on line 7324 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7323-L7324

Added lines #L7323 - L7324 were not covered by tests

case QUIC_PARAM_CONN_RECV_QTIP:
if (*BufferLength < sizeof(BOOLEAN)) {
*BufferLength = sizeof(BOOLEAN);
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
break;

Check warning on line 7330 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7327-L7330

Added lines #L7327 - L7330 were not covered by tests
}

if (Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;

Check warning on line 7335 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7333-L7335

Added lines #L7333 - L7335 were not covered by tests
}
*BufferLength = sizeof(BOOLEAN);
*(BOOLEAN*)Buffer = Connection->State.RecvViaQtip;
Status = QUIC_STATUS_SUCCESS;
break;

Check warning on line 7340 in src/core/connection.c

View check run for this annotation

Codecov / codecov/patch

src/core/connection.c#L7337-L7340

Added lines #L7337 - L7340 were not covered by tests
#endif

default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
Expand Down
12 changes: 12 additions & 0 deletions src/core/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ typedef union QUIC_CONNECTION_STATE {
//
BOOLEAN DisableVneTp : 1;
#endif

#ifdef QUIC_API_ENABLE_PREVIEW_FEATURES
//
// Whether to use QTIP on sends for this connection.
//
BOOLEAN SendViaQtip : 1;

//
// Whether to allow QTIP on receives for this connection.
//
BOOLEAN RecvViaQtip : 1;
ProjectsByJackHe marked this conversation as resolved.
Show resolved Hide resolved
#endif
};
} QUIC_CONNECTION_STATE;

Expand Down
6 changes: 6 additions & 0 deletions src/cs/lib/msquic_generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3450,6 +3450,12 @@ internal static unsafe partial class MsQuic
[NativeTypeName("#define QUIC_PARAM_CONN_SEND_DSCP 0x05000019")]
internal const uint QUIC_PARAM_CONN_SEND_DSCP = 0x05000019;

[NativeTypeName("#define QUIC_PARAM_CONN_SEND_QTIP 0x0500001A")]
internal const uint QUIC_PARAM_CONN_SEND_QTIP = 0x0500001A;

[NativeTypeName("#define QUIC_PARAM_CONN_RECV_QTIP 0x0500001B")]
internal const uint QUIC_PARAM_CONN_RECV_QTIP = 0x0500001B;

[NativeTypeName("#define QUIC_PARAM_TLS_HANDSHAKE_INFO 0x06000000")]
internal const uint QUIC_PARAM_TLS_HANDSHAKE_INFO = 0x06000000;

Expand Down
5 changes: 5 additions & 0 deletions src/inc/msquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,11 @@ typedef struct QUIC_SCHANNEL_CREDENTIAL_ATTRIBUTE_W {
#define QUIC_PARAM_CONN_ORIG_DEST_CID 0x05000018 // uint8_t[]
#define QUIC_PARAM_CONN_SEND_DSCP 0x05000019 // uint8_t

#ifdef QUIC_API_ENABLE_PREVIEW_FEATURES
#define QUIC_PARAM_CONN_SEND_QTIP 0x0500001A // uint8_t (BOOLEAN)
#define QUIC_PARAM_CONN_RECV_QTIP 0x0500001B // uint8_t (BOOLEAN)
#endif
ProjectsByJackHe marked this conversation as resolved.
Show resolved Hide resolved

//
// Parameters for TLS.
//
Expand Down
7 changes: 6 additions & 1 deletion src/platform/datapath_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ CxPlatDpRawRxEthernet(

if (Socket) {
if (PacketChain->Reserved == L4_TYPE_UDP || PacketChain->Reserved == L4_TYPE_TCP) {
uint8_t SocketType = Socket->UseTcp ? L4_TYPE_TCP : L4_TYPE_UDP;
//
// If we have UseTcp enabled, we should still support UDP type of packets.
//
// uint8_t SocketType = (Socket->UseTcp && PacketChain->Reserved == L4_TYPE_TCP) ? L4_TYPE_TCP : L4_TYPE_UDP;

uint8_t SocketType = (Socket->UseTcp) ? L4_TYPE_TCP : L4_TYPE_UDP; // This is the old code

//
// Found a match. Chain and deliver contiguous packets with the same 4-tuple.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/datapath_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ SocketCreateUdp(
Socket->HasFixedRemoteAddress = (Config->RemoteAddress != NULL);
Socket->Type = CXPLAT_SOCKET_UDP;
Socket->UseRio = Datapath->UseRio;
Socket->UseTcp = Datapath->UseTcp;
Socket->UseTcp = 0; // TODO: revert this back to Datapath->UseTcp
if (Config->LocalAddress) {
CxPlatConvertToMappedV6(Config->LocalAddress, &Socket->LocalAddress);
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/test/MsQuicTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ QuicTestConnectAndPing(
_In_ bool UseSendBuffer,
_In_ bool UnidirectionalStreams,
_In_ bool ServerInitiatedStreams,
_In_ bool FifoScheduling
_In_ bool FifoScheduling,
_In_ bool SendUdpToQtipListener
);

//
Expand Down Expand Up @@ -820,6 +821,7 @@ typedef struct {
uint8_t UnidirectionalStreams;
uint8_t ServerInitiatedStreams;
uint8_t FifoScheduling;
uint8_t SendUdpToQtipListener;
} QUIC_RUN_CONNECT_AND_PING_PARAMS;

#pragma pack(pop)
Expand Down
46 changes: 36 additions & 10 deletions src/test/bin/quic_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,8 @@ TEST_P(WithSendArgs1, Send) {
(uint8_t)GetParam().UseSendBuffer,
(uint8_t)GetParam().UnidirectionalStreams,
(uint8_t)GetParam().ServerInitiatedStreams,
0 // FifoScheduling
0, // FifoScheduling
0, // SendUdpToQtipListener
};
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_CONNECT_AND_PING, Params));
} else {
Expand All @@ -1757,7 +1758,24 @@ TEST_P(WithSendArgs1, Send) {
GetParam().UseSendBuffer,
GetParam().UnidirectionalStreams,
GetParam().ServerInitiatedStreams,
false); // FifoScheduling
false, // FifoScheduling
false); // SendUdpToQtipListener
QuicTestConnectAndPing(
GetParam().Family,
GetParam().Length,
GetParam().ConnectionCount,
GetParam().StreamCount,
1, // StreamBurstCount
0, // StreamBurstDelayMs
false, // ServerStatelessRetry
false, // ClientRebind
false, // ClientZeroRtt
false, // ServerRejectZeroRtt
GetParam().UseSendBuffer,
GetParam().UnidirectionalStreams,
GetParam().ServerInitiatedStreams,
false, // FifoScheduling
true); // SendUdpToQtipListener
}
}

Expand All @@ -1778,7 +1796,8 @@ TEST_P(WithSendArgs2, SendLarge) {
(uint8_t)GetParam().UseSendBuffer,
0, // UnidirectionalStreams
0, // ServerInitiatedStreams
1 // FifoScheduling
1, // FifoScheduling
0 // SendUdpToQtipListener
};
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_CONNECT_AND_PING, Params));
} else {
Expand All @@ -1796,7 +1815,8 @@ TEST_P(WithSendArgs2, SendLarge) {
GetParam().UseSendBuffer,
false, // UnidirectionalStreams
false, // ServerInitiatedStreams
true); // FifoScheduling
true, // FifoScheduling
false); // SendUdpToQtipListener
}
}

Expand All @@ -1817,7 +1837,8 @@ TEST_P(WithSendArgs3, SendIntermittently) {
(uint8_t)GetParam().UseSendBuffer,
0, // UnidirectionalStreams
0, // ServerInitiatedStreams
0 // FifoScheduling
0, // FifoScheduling
0 // SendUdpToQtipListener
};
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_CONNECT_AND_PING, Params));
} else {
Expand All @@ -1835,7 +1856,8 @@ TEST_P(WithSendArgs3, SendIntermittently) {
GetParam().UseSendBuffer,
false, // UnidirectionalStreams
false, // ServerInitiatedStreams
false); // FifoScheduling
false, // FifoScheduling
false); // SendUdpToQtipListener
}
}

Expand Down Expand Up @@ -1868,7 +1890,8 @@ TEST_P(WithSend0RttArgs1, Send0Rtt) {
(uint8_t)GetParam().UseSendBuffer,
(uint8_t)GetParam().UnidirectionalStreams,
0, // ServerInitiatedStreams
0 // FifoScheduling
0, // FifoScheduling
0 // SendUdpToQtipListener
};
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_CONNECT_AND_PING, Params));
} else {
Expand All @@ -1886,7 +1909,8 @@ TEST_P(WithSend0RttArgs1, Send0Rtt) {
GetParam().UseSendBuffer,
GetParam().UnidirectionalStreams,
false, // ServerInitiatedStreams
false); // FifoScheduling
false, // FifoScheduling
false); // SendUdpToQtipListener
}
}

Expand Down Expand Up @@ -1916,7 +1940,8 @@ TEST_P(WithSend0RttArgs2, Reject0Rtt) {
0, // UseSendBuffer
0, // UnidirectionalStreams
0, // ServerInitiatedStreams
0 // FifoScheduling
0, // FifoScheduling
0 // SendUdpToQtipListener
};
ASSERT_TRUE(DriverClient.Run(IOCTL_QUIC_RUN_CONNECT_AND_PING, Params));
} else {
Expand All @@ -1934,7 +1959,8 @@ TEST_P(WithSend0RttArgs2, Reject0Rtt) {
false, // UseSendBuffer
false, // UnidirectionalStreams
false, // ServerInitiatedStreams
false); // FifoScheduling
false, // FifoScheduling
false); // SendUdpToQtipListener
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/bin/winkernel/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,8 @@ QuicTestCtlEvtIoDeviceControl(
Params->Params2.UseSendBuffer != 0,
Params->Params2.UnidirectionalStreams != 0,
Params->Params2.ServerInitiatedStreams != 0,
Params->Params2.FifoScheduling != 0
Params->Params2.FifoScheduling != 0,
Params->Params2.SendUdpToQtipListener != 0
));
break;

Expand Down
55 changes: 31 additions & 24 deletions src/test/lib/DataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ QuicTestConnectAndPing(
_In_ bool UseSendBuffer,
_In_ bool UnidirectionalStreams,
_In_ bool ServerInitiatedStreams,
_In_ bool FifoScheduling
_In_ bool FifoScheduling,
_In_ bool SendUdpToQtipListener
)
{
const uint32_t TimeoutMs = EstimateTimeoutMs(Length) * StreamBurstCount;
Expand All @@ -378,6 +379,7 @@ QuicTestConnectAndPing(
PingStats ClientStats(Length, ConnectionCount, TotalStreamCount, FifoScheduling, UnidirectionalStreams, ServerInitiatedStreams, ClientZeroRtt && !ServerRejectZeroRtt);

MsQuicRegistration Registration(NULL, QUIC_EXECUTION_PROFILE_TYPE_MAX_THROUGHPUT, true);

TEST_TRUE(Registration.IsValid());

if (ServerRejectZeroRtt) {
Expand All @@ -400,7 +402,6 @@ QuicTestConnectAndPing(
}

MsQuicAlpn Alpn("MsQuicTest");

MsQuicSettings Settings;
if (ClientZeroRtt) {
Settings.SetServerResumptionLevel(QUIC_SERVER_RESUME_AND_ZERORTT);
Expand All @@ -410,7 +411,19 @@ QuicTestConnectAndPing(
Settings.SetPeerUnidiStreamCount(TotalStreamCount);
}
Settings.SetSendBufferingEnabled(UseSendBuffer);

if (UseQTIP && SendUdpToQtipListener) {
// Do a sanity check to make sure we actually have QTIP enabled.
QUIC_EXECUTION_CONFIG Config = {QUIC_EXECUTION_CONFIG_FLAG_NONE, 0, 0, {0}};
// Get the current global execution config.
uint32_t Size = sizeof(Config);
TEST_TRUE(QUIC_SUCCEEDED(
MsQuic->GetParam(
nullptr,
QUIC_PARAM_GLOBAL_EXECUTION_CONFIG,
&Size,
&Config)));
TEST_TRUE((Config.Flags & QUIC_EXECUTION_CONFIG_FLAG_QTIP) != 0);
}
MsQuicConfiguration ServerConfiguration(Registration, Alpn, Settings, ServerSelfSignedCredConfig);
TEST_TRUE(ServerConfiguration.IsValid());

Expand All @@ -427,22 +440,6 @@ QuicTestConnectAndPing(
TEST_QUIC_SUCCEEDED(ServerConfiguration.SetTicketKey(&GoodKey));
}

MsQuicCredentialConfig ClientCredConfig;
MsQuicConfiguration ClientConfiguration(Registration, Alpn, ClientCredConfig);
TEST_TRUE(ClientConfiguration.IsValid());

if (ClientZeroRtt) {
QuicTestPrimeResumption(
QuicAddrFamily,
Registration,
ServerConfiguration,
ClientConfiguration,
&ClientStats.ResumptionTicket);
if (!ClientStats.ResumptionTicket) {
return;
}
}

StatelessRetryHelper RetryHelper(ServerStatelessRetry);

{
Expand All @@ -457,18 +454,29 @@ QuicTestConnectAndPing(
TEST_TRUE(Listener.IsValid());
TEST_QUIC_SUCCEEDED(Listener.Start(Alpn));

MsQuicCredentialConfig ClientCredConfig;
MsQuicConfiguration ClientConfiguration(Registration, Alpn, ClientCredConfig);
TEST_TRUE(ClientConfiguration.IsValid());
if (ClientZeroRtt) {
QuicTestPrimeResumption(
QuicAddrFamily,
Registration,
ServerConfiguration,
ClientConfiguration,
&ClientStats.ResumptionTicket);
if (!ClientStats.ResumptionTicket) {
return;
}
}

QuicAddr ServerLocalAddr;
TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerLocalAddr));

Listener.Context = &ServerStats;

TestConnection** ConnAlloc = new(std::nothrow) TestConnection*[ConnectionCount];
if (ConnAlloc == nullptr) {
return;
}

UniquePtrArray<TestConnection*> Connections(ConnAlloc);

for (uint32_t i = 0; i < ClientStats.ConnectionCount; ++i) {
Connections.get()[i] =
NewPingConnection(
Expand All @@ -483,7 +491,6 @@ QuicTestConnectAndPing(
Connections.get()[i]->SetTlsSecrets(&ClientSecrets[i]));
}
}

QuicAddr LocalAddr;
for (uint32_t j = 0; j < StreamBurstCount; ++j) {
if (j != 0) {
Expand Down
Loading