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 setting TypeOfService/TrafficClass on connections #4757

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

anrossi
Copy link
Contributor

@anrossi anrossi commented Jan 21, 2025

Description

Resolves #4767. Add support for applications to set the Type of Service/Traffic Class field all traffic sent from a connection.

Testing

TBD

Documentation

Updated the settings document with the new get/set param.

Status = QUIC_STATUS_SUCCESS;
break;

case QUIC_PARAM_CONN_DSCP:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should GetParam return the last-set DSCP value, or the most recently received DSCP value?
Or should getting the received DSCP value be a separate, get-only param?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to support querying the last value set by the app. So, then we would need two parameters, one for send and one (get-only) for receive. But let's save receive for a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, receive can be a future PR

CMsg = (PWSACMSGHDR)&CMsgBuffer[CMsgLen];
CMsgLen += WSA_CMSG_SPACE(sizeof(INT));
CMsg->cmsg_level =
Route->LocalAddress.si_family == QUIC_ADDRESS_FAMILY_INET ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LocalAddress might be the wrong address to use; if trying to send to an IPv4 address using a dual-mode socket, you need to set the IPv4 IP_TOS, instead of the IPV6_TCLASS

@@ -803,7 +803,7 @@ QuicBindingProcessStatelessOperation(
Binding,
OperationType);

CXPLAT_SEND_CONFIG SendConfig = { RecvPacket->Route, 0, CXPLAT_ECN_NON_ECT, 0 };
CXPLAT_SEND_CONFIG SendConfig = { RecvPacket->Route, 0, CXPLAT_ECN_NON_ECT, 0, 0 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a #define for zero here instead of using a magic number?

Comment on lines +6626 to +6627
case QUIC_PARAM_CONN_DSCP:
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case QUIC_PARAM_CONN_DSCP:
{
case QUIC_PARAM_CONN_DSCP: {

Comment on lines +6633 to +6634
uint8_t DSCP = 0;
CxPlatCopyMemory(&DSCP, Buffer, BufferLength);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify?

Suggested change
uint8_t DSCP = 0;
CxPlatCopyMemory(&DSCP, Buffer, BufferLength);
uint8_t DSCP = *Buffer;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't the simplification cause a crash if the buffer is unaligned on ARM?

@@ -7207,27 +7228,55 @@ QuicConnParamGet(
}

case QUIC_PARAM_CONN_ORIG_DEST_CID:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't modify code that's not relevant to this PR?

@@ -923,6 +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_DSCP 0x50000019 // uint8_t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call it _SEND_DSCP?

Suggested change
#define QUIC_PARAM_CONN_DSCP 0x50000019 // uint8_t
#define QUIC_PARAM_CONN_SEND_DSCP 0x50000019 // uint8_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of the same pattern that socket options use where the send one has no prefix, but the receive one has a prefix. So when we do the last-received DSCP value, it would be QUIC_PARAM_CONN_RECV_DSCP

@@ -444,6 +455,7 @@ CxPlatDataPathUpdateConfig(
#define CXPLAT_DATAPATH_FEATURE_TCP 0x0020
#define CXPLAT_DATAPATH_FEATURE_RAW 0x0040
#define CXPLAT_DATAPATH_FEATURE_TTL 0x0080
#define CXPLAT_DATAPATH_FEATURE_DSCP 0x0100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we need separate features for send/receive support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the receive support already exists in all stacks, it's just the send support that's missing on some.

@@ -1672,7 +1708,7 @@ SocketCreateUdp(
setsockopt(
SocketProc->Socket,
IPPROTO_IP,
IP_ECN,
IP_RECVTOS,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be causing test failures because packets aren't getting received in some tests since adding this change.

} 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here; I think this change might be causing receives to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Specifying DSCP for QUIC Connections
2 participants