Skip to content

Commit

Permalink
Fix winkernel and add test for the API setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
anrossi committed Feb 4, 2025
1 parent 2ea4426 commit 098f9e6
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/core/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ QuicBindingProcessStatelessOperation(
Binding,
OperationType);

CXPLAT_SEND_CONFIG SendConfig = { RecvPacket->Route, 0, CXPLAT_ECN_NON_ECT, 0, 0 };
CXPLAT_SEND_CONFIG SendConfig = { RecvPacket->Route, 0, CXPLAT_ECN_NON_ECT, 0, CXPLAT_DSCP_CS0 };
CXPLAT_SEND_DATA* SendData = CxPlatSendDataAlloc(Binding->Socket, &SendConfig);
if (SendData == NULL) {
QuicTraceEvent(
Expand Down
10 changes: 8 additions & 2 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -6638,6 +6638,12 @@ QuicConnParamSet(

Connection->DSCP = DSCP;

QuicTraceLogConnInfo(
ConnDscpSet,
Connection,
"Connection DSCP set to %hhu",
Connection->DSCP);

Status = QUIC_STATUS_SUCCESS;
break;
}
Expand Down Expand Up @@ -7258,9 +7264,9 @@ QuicConnParamGet(

case QUIC_PARAM_CONN_SEND_DSCP:

if (*BufferLength < sizeof(Connection->DSCP)) {
if (*BufferLength < sizeof(uint8_t)) {
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
*BufferLength = sizeof(Connection->DSCP);
*BufferLength = sizeof(uint8_t);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/cs/lib/msquic_generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3447,8 +3447,8 @@ internal static unsafe partial class MsQuic
[NativeTypeName("#define QUIC_PARAM_CONN_ORIG_DEST_CID 0x05000018")]
internal const uint QUIC_PARAM_CONN_ORIG_DEST_CID = 0x05000018;

[NativeTypeName("#define QUIC_PARAM_CONN_SEND_DSCP 0x50000019")]
internal const uint QUIC_PARAM_CONN_SEND_DSCP = 0x50000019;
[NativeTypeName("#define QUIC_PARAM_CONN_SEND_DSCP 0x05000019")]
internal const uint QUIC_PARAM_CONN_SEND_DSCP = 0x05000019;

[NativeTypeName("#define QUIC_PARAM_TLS_HANDSHAKE_INFO 0x06000000")]
internal const uint QUIC_PARAM_TLS_HANDSHAKE_INFO = 0x06000000;
Expand Down
20 changes: 20 additions & 0 deletions src/generated/linux/connection.c.clog.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,26 @@ tracepoint(CLOG_CONNECTION_C, CibirIdSet , arg1, arg3, arg4);\



/*----------------------------------------------------------
// Decoder Ring for ConnDscpSet
// [conn][%p] Connection DSCP set to %hhu
// QuicTraceLogConnInfo(
ConnDscpSet,
Connection,
"Connection DSCP set to %hhu",
Connection->DSCP);
// arg1 = arg1 = Connection = arg1
// arg3 = arg3 = Connection->DSCP = arg3
----------------------------------------------------------*/
#ifndef _clog_4_ARGS_TRACE_ConnDscpSet
#define _clog_4_ARGS_TRACE_ConnDscpSet(uniqueId, arg1, encoded_arg_string, arg3)\
tracepoint(CLOG_CONNECTION_C, ConnDscpSet , arg1, arg3);\

#endif




/*----------------------------------------------------------
// Decoder Ring for ApplySettings
// [conn][%p] Applying new settings
Expand Down
23 changes: 23 additions & 0 deletions src/generated/linux/connection.c.clog.h.lttng.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,29 @@ TRACEPOINT_EVENT(CLOG_CONNECTION_C, CibirIdSet,



/*----------------------------------------------------------
// Decoder Ring for ConnDscpSet
// [conn][%p] Connection DSCP set to %hhu
// QuicTraceLogConnInfo(
ConnDscpSet,
Connection,
"Connection DSCP set to %hhu",
Connection->DSCP);
// arg1 = arg1 = Connection = arg1
// arg3 = arg3 = Connection->DSCP = arg3
----------------------------------------------------------*/
TRACEPOINT_EVENT(CLOG_CONNECTION_C, ConnDscpSet,
TP_ARGS(
const void *, arg1,
unsigned char, arg3),
TP_FIELDS(
ctf_integer_hex(uint64_t, arg1, (uint64_t)arg1)
ctf_integer(unsigned char, arg3, arg3)
)
)



/*----------------------------------------------------------
// Decoder Ring for ApplySettings
// [conn][%p] Applying new settings
Expand Down
2 changes: 1 addition & 1 deletion src/inc/msquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ typedef struct QUIC_SCHANNEL_CREDENTIAL_ATTRIBUTE_W {
#define QUIC_PARAM_CONN_STATISTICS_V2 0x05000016 // QUIC_STATISTICS_V2
#define QUIC_PARAM_CONN_STATISTICS_V2_PLAT 0x05000017 // QUIC_STATISTICS_V2
#define QUIC_PARAM_CONN_ORIG_DEST_CID 0x05000018 // uint8_t[]
#define QUIC_PARAM_CONN_SEND_DSCP 0x50000019 // uint8_t
#define QUIC_PARAM_CONN_SEND_DSCP 0x05000019 // uint8_t

//
// Parameters for TLS.
Expand Down
21 changes: 21 additions & 0 deletions src/manifest/clog.sidecar
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,22 @@
],
"macroName": "QuicTraceEvent"
},
"ConnDscpSet": {
"ModuleProperites": {},
"TraceString": "[conn][%p] Connection DSCP set to %hhu",
"UniqueId": "ConnDscpSet",
"splitArgs": [
{
"DefinationEncoding": "p",
"MacroVariableName": "arg1"
},
{
"DefinationEncoding": "hhu",
"MacroVariableName": "arg3"
}
],
"macroName": "QuicTraceLogConnInfo"
},
"ConnEcnCapable": {
"ModuleProperites": {},
"TraceString": "[conn][%p] Ecn: IsCapable=%hu",
Expand Down Expand Up @@ -13820,6 +13836,11 @@
"TraceID": "ConnDropPacketEx",
"EncodingString": "[conn][%p] DROP packet Value=%llu Dst=%!ADDR! Src=%!ADDR! Reason=%s."
},
{
"UniquenessHash": "c753358e-985b-ee38-30e0-cc6cebbe5526",
"TraceID": "ConnDscpSet",
"EncodingString": "[conn][%p] Connection DSCP set to %hhu"
},
{
"UniquenessHash": "9c10f710-84bf-766d-0da5-9e31796cf450",
"TraceID": "ConnEcnCapable",
Expand Down
10 changes: 6 additions & 4 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_RECVTCLASS,
IPV6_ECN,
IPPROTO_IPV6,
sizeof(Option),
&Option);
Expand All @@ -1499,7 +1499,7 @@ SocketCreateUdp(
"[data][%p] ERROR, %u, %s.",
Binding,
Status,
"Set IPV6_RECVTCLASS");
"Set IPV6_ECN");
goto Error;
}

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

Expand Down Expand Up @@ -2983,6 +2983,8 @@ SocketSend(
Route->LocalAddress.si_family == QUIC_ADDRESS_FAMILY_INET ?
IP_TOS : IPV6_TCLASS;
CMsg->cmsg_len = WSA_CMSG_LEN(sizeof(INT));

*(PINT)WSA_CMSG_DATA(CMsg) = SendData->ECN | (SendData->DSCP << 2);
}

if (SendData->SegmentSize > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/datapath_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4535,7 +4535,7 @@ CxPlatSocketSendInline(
CMsg->cmsg_level = IPPROTO_IP;
CMsg->cmsg_type = IP_TOS;
CMsg->cmsg_len = WSA_CMSG_LEN(sizeof(INT));
*(PINT)WSA_CMSG_DATA(CMsg) = SendData->DSCP;
*(PINT)WSA_CMSG_DATA(CMsg) = SendData->ECN | (SendData->DSCP << 2);
}

} else {
Expand Down Expand Up @@ -4566,7 +4566,7 @@ CxPlatSocketSendInline(
CMsg->cmsg_level = IPPROTO_IPV6;
CMsg->cmsg_type = IPV6_TCLASS;
CMsg->cmsg_len = WSA_CMSG_LEN(sizeof(INT));
*(PINT)WSA_CMSG_DATA(CMsg) = SendData->DSCP;
*(PINT)WSA_CMSG_DATA(CMsg) = SendData->ECN | (SendData->DSCP << 2);
}
}

Expand Down
78 changes: 78 additions & 0 deletions src/test/lib/ApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4521,6 +4521,83 @@ void QuicTest_QUIC_PARAM_CONN_ORIG_DEST_CID(MsQuicRegistration& Registration, Ms
}
}

void QuicTest_QUIC_PARAM_CONN_SEND_DSCP(MsQuicRegistration& Registration)
{
TestScopeLogger LogScope0("QUIC_PARAM_CONN_SEND_DSCP");
{
TestScopeLogger LogScope1("SetParam null buffer");
MsQuicConnection Connection(Registration);
TEST_QUIC_SUCCEEDED(Connection.GetInitStatus());
uint8_t Dummy = 0;
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
Connection.SetParam(
QUIC_PARAM_CONN_SEND_DSCP,
sizeof(Dummy),
nullptr));
}
{
TestScopeLogger LogScope1("SetParam zero length");
MsQuicConnection Connection(Registration);
TEST_QUIC_SUCCEEDED(Connection.GetInitStatus());
uint8_t Dummy = 0;
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
Connection.SetParam(
QUIC_PARAM_CONN_SEND_DSCP,
0,
&Dummy));
}
{
TestScopeLogger LogScope1("SetParam non-DSCP number");
MsQuicConnection Connection(Registration);
TEST_QUIC_SUCCEEDED(Connection.GetInitStatus());
uint8_t Dummy = 64;
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
Connection.SetParam(
QUIC_PARAM_CONN_SEND_DSCP,
sizeof(Dummy),
&Dummy));
Dummy = 255;
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
Connection.SetParam(
QUIC_PARAM_CONN_SEND_DSCP,
sizeof(Dummy),
&Dummy));
}
{
TestScopeLogger LogScope1("GetParam Default");
MsQuicConnection Connection(Registration);
TEST_QUIC_SUCCEEDED(Connection.GetInitStatus());
uint8_t Dscp = 0;
SimpleGetParamTest(Connection.Handle, QUIC_PARAM_CONN_SEND_DSCP, sizeof(Dscp), &Dscp);
}
{
TestScopeLogger LogScope1("SetParam/GetParam Valid DSCP");
MsQuicConnection Connection(Registration);
TEST_QUIC_SUCCEEDED(Connection.GetInitStatus());
uint8_t Dscp = CXPLAT_DSCP_LE;
uint8_t GetValue = 0;
TEST_QUIC_STATUS(
QUIC_STATUS_SUCCESS,
Connection.SetParam(
QUIC_PARAM_CONN_SEND_DSCP,
sizeof(Dscp),
&Dscp));
uint32_t BufferSize = sizeof(GetValue);
TEST_QUIC_STATUS(
QUIC_STATUS_SUCCESS,
Connection.GetParam(
QUIC_PARAM_CONN_SEND_DSCP,
&BufferSize,
&GetValue));
TEST_EQUAL(BufferSize, sizeof(GetValue));
TEST_EQUAL(GetValue, Dscp);
}
}

void QuicTestConnectionParam()
{
MsQuicAlpn Alpn("MsQuicTest");
Expand Down Expand Up @@ -4554,6 +4631,7 @@ void QuicTestConnectionParam()
QuicTest_QUIC_PARAM_CONN_STATISTICS_V2(Registration);
QuicTest_QUIC_PARAM_CONN_STATISTICS_V2_PLAT(Registration);
QuicTest_QUIC_PARAM_CONN_ORIG_DEST_CID(Registration, ClientConfiguration);
QuicTest_QUIC_PARAM_CONN_SEND_DSCP(Registration);
}

//
Expand Down

0 comments on commit 098f9e6

Please sign in to comment.