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

feat(bin): enable Firefox to use quinn-udp through neqo-udp #1920

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

mxinden
Copy link
Collaborator

@mxinden mxinden commented Jun 7, 2024

  • Needed for:
  • Moves UDP related logic into new neqo-udp crate. Firefox does not need neqo-server, neqo-client, nor any of its dependencies. A new crate enforces none of this leaking into Firefox.
  • Allow UDP Socket to be used both with tokio::net::UdpSocket (for neqo-client, neqo-server, mozilla-central's http3server) and std::os::fd::BorrowedFd (std::os::windows::io::BorrowedSocket on Windows). The latter allows neqo-glue to use neqo-udp with a UDP socket managed by NSPR.

Copy link

github-actions bot commented Jun 7, 2024

Failed Interop Tests

QUIC Interop Runner, client vs. server

All results

Succeeded Interop Tests

QUIC Interop Runner, client vs. server

Unsupported Interop Tests

QUIC Interop Runner, client vs. server

Copy link

github-actions bot commented Jun 7, 2024

Firefox builds for this PR

The following builds are available for testing. Crossed-out builds did not succeed.

@mxinden mxinden changed the title feat(bin): enable Firefox to use quinn-udp through neqo-bin feat(bin): enable Firefox to use quinn-udp through neqo-udp Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 82.71605% with 14 lines in your changes missing coverage. Please review.

Project coverage is 94.80%. Comparing base (121fe68) to head (9ce36cb).
Report is 2 commits behind head on main.

Files Patch % Lines
neqo-udp/src/lib.rs 82.50% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1920      +/-   ##
==========================================
- Coverage   94.82%   94.80%   -0.02%     
==========================================
  Files         110      111       +1     
  Lines       35792    35968     +176     
==========================================
+ Hits        33938    34100     +162     
- Misses       1854     1868      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mxinden mxinden marked this pull request as ready for review June 14, 2024 11:51
Copy link
Collaborator

@KershawChang KershawChang left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@martinthomson , @larseggert , could you also review this PR?
Thanks.

neqo-common/src/log.rs Outdated Show resolved Hide resolved
Comment on lines 20 to 21
[dev-dependencies]
tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is tokio also a dev-dependency?

Copy link
Member

Choose a reason for hiding this comment

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

Presumably because the dev variant has more features enabled.

The lack of an EOL here is also worth fixing. You can configure your editor to add these to all text files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct.

Firefox does not need tokio. neqo-client and neqo-server in neqo-bin do need tokio, but only the net feature. Thus tokio is an optional dependency restricted to the net feature only.

[dependencies]
# [...]
tokio = { version = "1", default-features = false, features = ["net"], optional = true }

In addition, the neqo-udp tests always need tokio and they make use of various features beyond net, thus the additional import as a dev-dependency with more features enabled.

[dev-dependencies]
tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] }

The lack of an EOL here is also worth fixing. You can configure your editor to add these to all text files.

Will do!

use quinn_udp::{EcnCodepoint, RecvMeta, Transmit, UdpSocketState};
use tokio::io::Interest;

/// Socket receive buffer size.
///
/// Allows reading multiple datagrams in a single [`Socket::recv`] call.
const RECV_BUF_SIZE: usize = u16::MAX as usize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the max on all platforms?

Copy link
Member

Choose a reason for hiding this comment

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

That seems unlikely. But @larseggert, does that need to be fixed here, or can we track that with another issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think finding the right value needs more experimentation.

Here is what others use:

Google's Quiche handles 1472 bytes per segment with at most 16 segments per read.

MSQuic uses (UINT16_MAX - CXPLAT_UDP_HEADER_SIZE).

Quinn uses a receive buffer of 64 * 1024.

Note that in Firefox this buffer is allocated once per socket thread. Given that Firefox has a single socket thread only, there is effectively a single u16::MAX receive buffer only.

Would you recommend a larger buffer size to start with @larseggert?

neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
meta.addr,
*local_address,
meta.ecn.map(|n| IpTos::from(n as u8)).unwrap_or_default(),
None, // TODO: get the real TTL https://github.com/quinn-rs/quinn/issues/1749
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should remove the TTL stuff from neqo until quinn actually supports it...

Copy link
Member

Choose a reason for hiding this comment

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

Separate issue, but I'm not sure that we really need TTL, so I'd be happy to see it removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good to me. I created #1940.

Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

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

LGTM, with nits.

Comment on lines 20 to 21
[dev-dependencies]
tokio = { version = "1", default-features = false, features = ["net", "time", "macros", "rt", "rt-multi-thread"] }
Copy link
Member

Choose a reason for hiding this comment

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

Presumably because the dev variant has more features enabled.

The lack of an EOL here is also worth fixing. You can configure your editor to add these to all text files.

use quinn_udp::{EcnCodepoint, RecvMeta, Transmit, UdpSocketState};
use tokio::io::Interest;

/// Socket receive buffer size.
///
/// Allows reading multiple datagrams in a single [`Socket::recv`] call.
const RECV_BUF_SIZE: usize = u16::MAX as usize;
Copy link
Member

Choose a reason for hiding this comment

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

That seems unlikely. But @larseggert, does that need to be fixed here, or can we track that with another issue?

neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
meta.addr,
*local_address,
meta.ecn.map(|n| IpTos::from(n as u8)).unwrap_or_default(),
None, // TODO: get the real TTL https://github.com/quinn-rs/quinn/issues/1749
Copy link
Member

Choose a reason for hiding this comment

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

Separate issue, but I'm not sure that we really need TTL, so I'd be happy to see it removed.

neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
neqo-udp/src/lib.rs Outdated Show resolved Hide resolved
mxinden added a commit to mxinden/neqo that referenced this pull request Jun 25, 2024
mozilla#1568 introduced TTL information to
datagrams. On the input path it would take the ttl information, but not act on
it. On the output path it would set only "the default TTL on many OSes".

https://github.com/mozilla/neqo/blob/66504908e5fa070a8a5fa67d8b5a201d2c9a5cc5/neqo-transport/src/path.rs#L576

This commit removes the ttl information from `Datagram`, thus reverting a subset
of mozilla#1568.

This is partially motivated by mozilla#1920,
introducing `quinn-udp` as the IO library of choice, which does not support
reading and writing TTL.

See also discussion in
mozilla#1920 (comment).
mxinden added a commit to mxinden/neqo that referenced this pull request Jun 25, 2024
mozilla#1568 introduced TTL information to
datagrams. On the input path it would take the ttl information, but not act on
it. On the output path it would set only "the default TTL on many OSes".

https://github.com/mozilla/neqo/blob/66504908e5fa070a8a5fa67d8b5a201d2c9a5cc5/neqo-transport/src/path.rs#L576

This commit removes the ttl information from `Datagram`, thus reverting a subset
of mozilla#1568.

This is partially motivated by mozilla#1920,
introducing `quinn-udp` as the IO library of choice, which does not support
reading and writing TTL.

See also discussion in
mozilla#1920 (comment).
github-merge-queue bot pushed a commit that referenced this pull request Jun 26, 2024
#1568 introduced TTL information to
datagrams. On the input path it would take the ttl information, but not act on
it. On the output path it would set only "the default TTL on many OSes".

https://github.com/mozilla/neqo/blob/66504908e5fa070a8a5fa67d8b5a201d2c9a5cc5/neqo-transport/src/path.rs#L576

This commit removes the ttl information from `Datagram`, thus reverting a subset
of #1568.

This is partially motivated by #1920,
introducing `quinn-udp` as the IO library of choice, which does not support
reading and writing TTL.

See also discussion in
#1920 (comment).
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.

None yet

4 participants