-
-
Notifications
You must be signed in to change notification settings - Fork 515
feat(quinn-udp): add opt-in Apple fast UDP datapath #2463
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
base: main
Are you sure you want to change the base?
Conversation
|
@mxinden thinking about this some more, I wonder if we need to pass in the sockets from Gecko (due to Rust code limitations around socket creation), or if we should even do this probe entirely in Gecko and simply runtime-configure which Apple datapath |
What do you mean? |
|
I think each of this should be a separate commit:
It probably also makes sense to split some of this out:
|
Gecko is sandboxing all Rust code (and other third-party code) so it cannot open sockets. |
|
@djc I'll do some refactoring on this next week per your suggestions. |
FWIW, I just build Firefox with this PR and it does run (and detect the fast Apple datapath after the probe), so something has changed related to the sandbox 🎉 |
Extract control message decoding logic into dedicated helper functions. This refactoring prepares the codebase for future work that will make `decode_recv` generic over the `MsgHdr` trait, enabling shared decoding logic between `libc::msghdr` and `msghdr_x` message types. Broken out of quinn-rs#2463 as suggested by @djc.
Replace conditional compilation on the `hdr` parameter with a generic type bound `M: cmsg::MsgHdr<ControlMessage = libc::cmsghdr>`. This enables `decode_recv` to work with both `libc::msghdr` and `msghdr_x` message types. Broken out of quinn-rs#2463 as suggested by @djc.
Separate the fast path (`msghdr_x`-based) and slow path (`msghdr`-based) implementations to prepare for runtime dispatch between them. Broken out of quinn-rs#2463 as suggested by @djc.
|
Concerning the usage of quinn-udp in Firefox only:
Referencing a discussion out-of-band. The "sandboxing" is happening at compile time. There is also the runtime sandboxing of the process. Though as far as I am aware, that isn't enabled by default. https://github.com/mozilla-firefox/firefox/blob/main/security/sandbox/linux/SandboxFilter.cpp |
|
ACK. I will revamp this once back from vacation. |
What sort of crash, specifically? I hope we're not invoking UB or risking a collision with application signal handlers or something. |
|
The concern is that Apple would eliminate or change the signature of the syscalls. |
|
That would make a call UB, right? Can we rely on the exit code we get from the subprocess in that case? |
3100deb to
16d148e
Compare
|
I'll investigate if we can move the probe function into neqo/Gecko, and instead have some sort of flag in quinn for whether the fast datapath should be used. Marking this PR as draft until then. |
086b2ba to
534b208
Compare
Add runtime dispatch between Apple's private `sendmsg_x`/`recvmsg_x` APIs (fast path) and standard `sendmsg`/`recvmsg` (slow path). The fast path is disabled by default and must be explicitly enabled by callers. These private APIs may crash on unsupported OS versions, so callers must verify availability before enabling. A C ABI function is provided for embedders (e.g., Firefox) to enable the fast path after probing externally. Key changes: - Add `set_apple_fast_path_available()` to enable fast path at runtime - Add C ABI `quinn_udp_set_apple_fast_path_available()` for FFI callers - Split send/recv into fast path (`send_via_sendmsg_x`, `recv_via_recvmsg_x`) and slow path (`send_single`, `recv_single`) variants - Add `prepare_msg_x`/`prepare_recv_x` for `msghdr_x` preparation - Update `gso::max_gso_segments()` to return 1 when fast path is disabled
534b208 to
e6c7997
Compare
|
OK, I revamped this and moved the entire logic for deciding whether the fast datapath should be used out of |
|
@mxinden please check the current revision. |
Separate the fast path (`msghdr_x`-based) and slow path (`msghdr`-based) implementations to prepare for runtime dispatch between them. Broken out of quinn-rs#2463 as suggested by @djc.
Add runtime dispatch between Apple's private
sendmsg_x/recvmsg_xAPIs (fast path) and standardsendmsg/recvmsg(slow path). The fast path is disabled by default and must be explicitly enabled by callers.These private APIs may crash on unsupported OS versions, so callers must verify availability before enabling. A C ABI function is provided for embedders (e.g., Firefox) to enable the fast path after probing externally.
Key changes:
set_apple_fast_path_available()to enable fast path at runtimequinn_udp_set_apple_fast_path_available()for FFI callerssend_via_sendmsg_x,recv_via_recvmsg_x)and slow path (
send_single,recv_single) variantsprepare_msg_x/prepare_recv_xformsghdr_xpreparationgso::max_gso_segments()to return 1 when fast path is disabled