Repository navigation
Add Socket::(set_)dontfrag_v4 and Socket::(set_)dontfrag_v6 - #679
Open
bhaskargurram-ai wants to merge 1 commit into
Open
bhaskargurram-ai wants to merge 1 commit into
bhaskargurram-ai wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #318.
Adds getters and setters for
IP_DONTFRAG(IP_DONTFRAGMENTon Windows) andIPV6_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 behindall.dontfrag_v4/set_dontfrag_v4: Apple platforms, FreeBSD, illumos, Solaris and Windows, behindall. Linux has noIP_DONTFRAG. Its equivalent isIP_MTU_DISCOVERwithIP_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_DONTFRAGMENTon 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