Skip to content

Add Socket::(set_)dontfrag_v4 and Socket::(set_)dontfrag_v6 - #679

Open
bhaskargurram-ai wants to merge 1 commit into
rust-lang:masterfrom
bhaskargurram-ai:feat/dontfrag
Open

bhaskargurram-ai wants to merge 1 commit into
rust-lang:masterfrom
bhaskargurram-ai:feat/dontfrag

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown
Contributor

Closes #318.

Adds getters and setters for IP_DONTFRAG (IP_DONTFRAGMENT on Windows) and IPV6_DONTFRAG. These stop outgoing datagrams from being fragmented, which UDP senders need for path MTU discovery (the use case in the issue and in #487).

  • dontfrag_v6/set_dontfrag_v6: Linux, Android, Apple platforms, FreeBSD, DragonFly, NetBSD, OpenBSD, illumos, Solaris and Windows. That covers all tier 1 platforms, so it isn't behind all.
  • dontfrag_v4/set_dontfrag_v4: Apple platforms, FreeBSD, illumos, Solaris and Windows, behind all. Linux has no IP_DONTFRAG. Its equivalent is IP_MTU_DISCOVER with IP_PMTUDISC_DO, which takes a mode rather than a bool, so I left it out.

I took the platform lists from where libc and windows-sys define the constants. The tests set and get both options on UDP sockets, since Windows only accepts IP_DONTFRAGMENT on datagram sockets. cargo check --all-targets, with and without --all-features, passes for x86_64 Linux, macOS, Windows (msvc) and FreeBSD, and clippy, fmt and doc are clean. I couldn't run the new tests here: this machine has no IPv6, and Linux doesn't have the IPv4 option, so CI will be their first run

Sets IP_DONTFRAG (IP_DONTFRAGMENT on Windows) and IPV6_DONTFRAG, so that
UDP senders can do path MTU discovery without the packets being fragmented.

Linux has no IP_DONTFRAG (it uses IP_MTU_DISCOVER instead), so the IPv4
version is behind the all feature.

Closes rust-lang#318

This branch has not been deployed

No deployments
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.

support set IP_DONTFRAG

1 participant