Skip to content

Conversation

@rushilmehra
Copy link
Contributor

@rushilmehra rushilmehra commented May 16, 2025

Current logic avoids setting the UDP_SEGMENT cmsg on sendmsg() calls when sending a single packet over the wire. However, there are niche cases where it's desirable to update the segment size after a socket has been created. If the updated segment size is greater than what the socket was initialized with, and we omit the UDP_SEGMENT cmsg, then the kernel will fall back to the segment size that is configured on the socket and erroneously truncate the packet on the way out.

We now set the UDP_SEGMENT cmsg on each packet no matter what.

To help avoid this footgun, we now initialize GSO on the socket with the maximum possible segment size.

@rushilmehra rushilmehra changed the title tokio-quiche: always send UDP packets with UDP_SEGMENT, initialize so… tokio-quiche: always set UDP_SEGMENT cmsg when calling sendmsg() May 16, 2025
@rushilmehra rushilmehra marked this pull request as ready for review May 19, 2025 14:12
@rushilmehra rushilmehra requested a review from a team as a code owner May 19, 2025 14:12
antoniovicente
antoniovicente previously approved these changes May 19, 2025
Current logic avoids setting the UDP_SEGMENT cmsg on sendmsg() calls
when sending a single packet over the wire. However, there are niche
cases where it's desirable to update the segment size after a socket has
been created. If the updated segment size is greater than what the
socket was initialized with, and we omit the UDP_SEGMENT cmsg, then the
kernel will fall back to the segment size that is configured on the
socket and erroneously truncate the packet on the way out.

We now set the UDP_SEGMENT cmsg on each packet no matter what.

To help avoid this footgun, we now initialize GSO on the socket with the
maximum possible segment size.
@rushilmehra rushilmehra merged commit 548509b into master May 19, 2025
38 checks passed
@rushilmehra rushilmehra deleted the gso-cmsg-always branch May 19, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants