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

set may_fragment based on whether setting IP_DONTFRAG fails with ENOPROTOOPT. #1626

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

jieliangma
Copy link

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Possible argument against this PR: iOS 13 (the last version of iOS that didn't support this, assuming iOS releases got support at the same time as macOS) has been out of security support since Sep 2020.

@jieliangma why has this device not been updated to a later OS? It looks like it ought to support iOS 16 (the current latest version) just fine.

quinn-udp/src/unix.rs Outdated Show resolved Hide resolved
@Ralith
Copy link
Collaborator

Ralith commented Aug 9, 2023

The reason we hesitated to add support for older macOS/iOS versions up front in #1547 is that platforms which may fragment packets must report this accurately in may_fragment(), so that PMTU discovery is correctly disabled. Because PMTU discovery is a desirable performance improvement in general, we must ensure that we do so only on these legacy platforms, without interfering with performance on modern Unixes.

In short, this PR can't be merged without adding dynamic iOS version detection logic to may_fragment(). For robustness, we should also only ignore the specific expected error, and only in environments specifically expected to produce it.

@jieliangma jieliangma force-pushed the bugfix/socket branch 2 times, most recently from 7ef0002 to dc8da00 Compare August 10, 2023 11:51
@djc
Copy link
Member

djc commented Aug 10, 2023

In short, this PR can't be merged without adding dynamic iOS version detection logic to may_fragment(). For robustness, we should also only ignore the specific expected error, and only in environments specifically expected to produce it.

If we try to set IP_DONTFRAG in init(), I suppose we can store the may_fragment bit as state after that, so that we don't need to interrogate the socket for every call to may_fragment()?

@Ralith
Copy link
Collaborator

Ralith commented Aug 10, 2023

Good point, that's also a lot easier and less fragile than version checks. may_fragment should then probably be a method on UdpSocketState.

@jieliangma jieliangma changed the title Ignoring error setting IP_DONTFRAG on iOS WIP:Ignoring error setting IP_DONTFRAG on iOS Aug 11, 2023
@Ralith
Copy link
Collaborator

Ralith commented Aug 11, 2023

Thanks for the revision! Please split the cosmetic refactoring commits out from the semantic changes so they can be easily reviewed.

@jieliangma jieliangma force-pushed the bugfix/socket branch 2 times, most recently from 42c7ed2 to 8936671 Compare August 11, 2023 05:23
@jieliangma jieliangma changed the title WIP:Ignoring error setting IP_DONTFRAG on iOS Ignoring error setting IP_DONTFRAG on iOS Aug 11, 2023
@jieliangma
Copy link
Author

Thanks for the revision! Please split the cosmetic refactoring commits out from the semantic changes so they can be easily reviewed.

done

@jieliangma jieliangma force-pushed the bugfix/socket branch 2 times, most recently from be5b118 to 4e1f1b5 Compare August 11, 2023 06:31
@jieliangma jieliangma requested a review from djc August 11, 2023 10:23
quinn-udp/src/lib.rs Show resolved Hide resolved
quinn-udp/src/unix.rs Outdated Show resolved Hide resolved
quinn-udp/src/unix.rs Outdated Show resolved Hide resolved
@djc
Copy link
Member

djc commented Aug 11, 2023

In short, this PR can't be merged without adding dynamic iOS version detection logic to may_fragment(). For robustness, we should also only ignore the specific expected error, and only in environments specifically expected to produce it.

It seems okay to me to set may_fragment based on whether setting IP_DONTFRAG fails with NOPROTOOPT, without separate implementations for FreeBSD or newer versions of the Apple OSes, do you see any reason?

@Ralith
Copy link
Collaborator

Ralith commented Aug 11, 2023

Yeah, that sounds good to me, since we're no longer relying on an independent judgement in may_fragment to line up.

@djc
Copy link
Member

djc commented Aug 11, 2023

@jieliangma #1629 refactored part of this code a bit, should make the changes here easier but will require some rebasing or rework.

@jieliangma jieliangma force-pushed the bugfix/socket branch 5 times, most recently from 0d56397 to 70386bf Compare August 14, 2023 03:26
@jieliangma jieliangma changed the title Ignoring error setting IP_DONTFRAG on iOS WIP: Ignoring error setting IP_DONTFRAG on iOS Aug 14, 2023
@jieliangma jieliangma force-pushed the bugfix/socket branch 3 times, most recently from 2ce0117 to 3912813 Compare August 14, 2023 11:04
@jieliangma jieliangma changed the title WIP: Ignoring error setting IP_DONTFRAG on iOS return may_fragment based on whether setting IP_DONTFRAG fails Aug 14, 2023
quinn-udp/src/unix.rs Outdated Show resolved Hide resolved
quinn-udp/src/unix.rs Outdated Show resolved Hide resolved
@jieliangma jieliangma closed this Aug 15, 2023
@jieliangma jieliangma deleted the bugfix/socket branch August 15, 2023 04:24
@jieliangma jieliangma restored the bugfix/socket branch August 15, 2023 04:25
@jieliangma jieliangma reopened this Aug 15, 2023
@jieliangma jieliangma changed the title return may_fragment based on whether setting IP_DONTFRAG fails WIP: set may_fragment based on whether setting IP_DONTFRAG fails with ENOPROTOOPT. Aug 15, 2023
@jieliangma jieliangma changed the title WIP: set may_fragment based on whether setting IP_DONTFRAG fails with ENOPROTOOPT. set may_fragment based on whether setting IP_DONTFRAG fails with ENOPROTOOPT. Aug 15, 2023
@djc
Copy link
Member

djc commented Aug 15, 2023

Going to merge this and fix it up a little. Thanks @jieliangma!

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.

3 participants