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

fix(udp): handle multiple datagrams on GRO #1708

Merged
merged 4 commits into from
Mar 5, 2024

Conversation

mxinden
Copy link
Collaborator

@mxinden mxinden commented Mar 2, 2024

Previously Socket::recv would at most return a single Datagram (i.e. -> Result<Option<Datagram>, io::Error>). When supported by the OS, the underlying quinn-udp can use both recvMmsg and GRO, each with the ability to return one or more datagrams.

As of today, neqo_common::udp does not make use of recvmmsg effectively, i.e. it only provides a single IoSliceMut to write into. That said, that single IoSliceMut might contain multiple Datagrams through GRO. Previously this would have been provided as a single Datagram to the caller of Socket::recv.

This commit makes sure to handle the case where many Datagrams are retrieved via GRO. I.e. where meta.stride < meta.len, indicating that the IoSliceMut contains more than one datagram. In addition it updates neqo_common::udp::Socket::recv and neqo-server and neqo-client accordingly.

See also the quinn-udp implementation and its usage in quinn:


This pull request has two commits:

  1. Test multi packet GRO read
  2. fix(udp): handle multiple datagrams through gro
    • The actual fix, having Socket::recv return multiple Datagrams on GRO read.

Bug introduced in #1604. Note however that since neqo_common::udp::Socket::send would never do GSO, this bug is unlikely to occur between neqo-client and neqo-server. It can however occur when connecting to other implementations.

Given that this is a bug fix only, diff is kept at a minimum. Proper GRO (and GSO) support coming with #1693.

@mxinden mxinden force-pushed the handle-gro branch 4 times, most recently from 7437ca5 to 8645e07 Compare March 3, 2024 13:51
@mxinden mxinden changed the title fix(udp): handle multiple datagrams on gro fix(udp): handle multiple datagrams on GRO Mar 3, 2024
Previously `Socket::recv` would at most return a single `Datagram` (i.e. `->
Result<Option<Datagram>, io::Error>`). When supported by the OS, the underlying
`quinn-udp` can use both recvMmsg and GRO, each with the ability to return one
or more datagrams.

As of today, `neqo_common::udp` does not make use of recvmmsg, i.e. it only
provides a single `IoSliceMut` to write into. That said, that single
`IoSliceMut` might contain multiple `Datagram`s through GRO. Previously this
would have been provided as a single `Datagram` to the caller of `Socket::recv`.

This commit makes sure to handle the case where many `Datagram`s are retrieved
via GRO (see `meta.stride` flag). It updates `neqo_common::udp::Socket::recv`
and `neqo-server` and `neqo-client` accordingly.
Copy link

codecov bot commented Mar 3, 2024

Codecov Report

Attention: Patch coverage is 97.05882% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 92.98%. Comparing base (a2d525b) to head (2249abd).

Files Patch % Lines
neqo-common/src/udp.rs 97.05% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1708      +/-   ##
==========================================
+ Coverage   92.97%   92.98%   +0.01%     
==========================================
  Files         120      120              
  Lines       37342    37399      +57     
==========================================
+ Hits        34718    34775      +57     
  Misses       2624     2624              

☔ 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 March 3, 2024 17:29
@larseggert larseggert added this pull request to the merge queue Mar 5, 2024
Merged via the queue into mozilla:main with commit a56e092 Mar 5, 2024
11 checks passed
mxinden added a commit to mxinden/neqo that referenced this pull request May 4, 2024
There are two server implementations based on neqo:

1. https://github.com/mozilla/neqo/tree/main/neqo-bin/src/server
  - http3 and http09 implementation
  - used for manual testing and QUIC Interop

2. https://searchfox.org/mozilla-central/source/netwerk/test/http3server/src/main.rs
  - used to test Firefox

I assume one was once an exact copy of the other. Both implement their own I/O,
event loop, ... Since then, the two implementations diverged significantly.
Especially (1) saw a lot of improvements in recent months:

- mozilla#1564
- mozilla#1569
- mozilla#1578
- mozilla#1581
- mozilla#1604
- mozilla#1612
- mozilla#1676
- mozilla#1692
- mozilla#1707
- mozilla#1708
- mozilla#1727
- mozilla#1753
- mozilla#1756
- mozilla#1766
- mozilla#1772
- mozilla#1786
- mozilla#1787
- mozilla#1788
- mozilla#1794
- mozilla#1806
- mozilla#1808
- mozilla#1848
- mozilla#1866

At this point, bugs in (2) are hard to fix, see e.g.
mozilla#1801.

This commit merges (2) into (1), thus removing all duplicate logic and
having (2) benefit from all the recent improvements to (1).
KershawChang pushed a commit to KershawChang/neqo that referenced this pull request May 7, 2024
There are two server implementations based on neqo:

1. https://github.com/mozilla/neqo/tree/main/neqo-bin/src/server
  - http3 and http09 implementation
  - used for manual testing and QUIC Interop

2. https://searchfox.org/mozilla-central/source/netwerk/test/http3server/src/main.rs
  - used to test Firefox

I assume one was once an exact copy of the other. Both implement their own I/O,
event loop, ... Since then, the two implementations diverged significantly.
Especially (1) saw a lot of improvements in recent months:

- mozilla#1564
- mozilla#1569
- mozilla#1578
- mozilla#1581
- mozilla#1604
- mozilla#1612
- mozilla#1676
- mozilla#1692
- mozilla#1707
- mozilla#1708
- mozilla#1727
- mozilla#1753
- mozilla#1756
- mozilla#1766
- mozilla#1772
- mozilla#1786
- mozilla#1787
- mozilla#1788
- mozilla#1794
- mozilla#1806
- mozilla#1808
- mozilla#1848
- mozilla#1866

At this point, bugs in (2) are hard to fix, see e.g.
mozilla#1801.

This commit merges (2) into (1), thus removing all duplicate logic and
having (2) benefit from all the recent improvements to (1).
github-merge-queue bot pushed a commit that referenced this pull request May 8, 2024
* refactor(bin): introduce server/http3.rs and server/http09.rs

The QUIC Interop Runner requires an http3 and http09 implementation for both
client and server. The client code is already structured into an http3 and an
http09 implementation since #1727.

This commit does the same for the server side, i.e. splits the http3 and http09
implementation into separate Rust modules.

* refactor: merge mozilla-central http3 server into neqo-bin

There are two server implementations based on neqo:

1. https://github.com/mozilla/neqo/tree/main/neqo-bin/src/server
  - http3 and http09 implementation
  - used for manual testing and QUIC Interop

2. https://searchfox.org/mozilla-central/source/netwerk/test/http3server/src/main.rs
  - used to test Firefox

I assume one was once an exact copy of the other. Both implement their own I/O,
event loop, ... Since then, the two implementations diverged significantly.
Especially (1) saw a lot of improvements in recent months:

- #1564
- #1569
- #1578
- #1581
- #1604
- #1612
- #1676
- #1692
- #1707
- #1708
- #1727
- #1753
- #1756
- #1766
- #1772
- #1786
- #1787
- #1788
- #1794
- #1806
- #1808
- #1848
- #1866

At this point, bugs in (2) are hard to fix, see e.g.
#1801.

This commit merges (2) into (1), thus removing all duplicate logic and
having (2) benefit from all the recent improvements to (1).

* Move firefox.rs to mozilla-central

* Reduce HttpServer trait functions

* Extract constructor

* Remove unused deps

* Remove clap color feature

Nice to have. Adds multiple dependencies. Hard to justify for mozilla-central.
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.

2 participants