Skip to content

fix(http3/connect-udp): parse context id as varint - #3018

Merged
larseggert merged 2 commits into
mozilla:mainfrom
mxinden:varint-0
Sep 29, 2025
Merged

larseggert merged 2 commits into
mozilla:mainfrom
mxinden:varint-0

Conversation

@mxinden

@mxinden mxinden commented Sep 28, 2025 •

Copy link
Copy Markdown
Member

MASQUE connect-udp prefixes each proxied UDP datagram payload with a context ID. A context ID is a varint.

Context IDs are 62-bit integers (0 to 262-1). Context IDs are encoded as variable-length integers; see Section 16 of [QUIC].

https://www.rfc-editor.org/rfc/rfc9298.html#section-4

Previously the code would parse the first byte only, checking whether it is 0x00. But 0x00 is not the only varint encoding of 0. Another e.g. is 0x40 0x00.

This commit properly parses the context ID as a varint.


Fixes #3017

MASQUE connect-udp prefixes each proxied UDP datagram payload with a context ID.
A context ID is a varint.

> Context IDs are 62-bit integers (0 to 262-1). Context IDs are encoded as
> variable-length integers; see Section 16 of [QUIC].

https://www.rfc-editor.org/rfc/rfc9298.html#section-4

Previously the code would parse the first byte only, checking whether it is
0x00. But 0x00 is not the only varint encoding of 0. Another e.g. is 0x40 0x00.

This commit properly parses the context ID as a varint.

---

Fixes mozilla#3017
Copilot AI review requested due to automatic review settings September 28, 2025 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the parsing of context IDs in HTTP/3 MASQUE connect-udp datagrams to properly handle varint encoding as specified in RFC 9298. Previously, the code only checked the first byte for 0x00, but context ID 0 can be encoded in multiple varint formats (e.g., 0x00 or 0x40 0x00).

  • Replace byte-by-byte parsing with proper varint decoding using Decoder::decode_varint()
  • Update error type to handle 64-bit context IDs instead of 8-bit values
  • Add comprehensive test coverage for different varint encodings of context ID 0

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
neqo-http3/src/features/extended_connect/session.rs Update error enum to use u64 for context IDs
neqo-http3/src/features/extended_connect/connect_udp_session.rs Implement proper varint parsing and add test coverage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov

codecov Bot commented Sep 28, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.37%. Comparing base (f6821b3) to head (00c4fac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3018      +/-   ##
==========================================
- Coverage   93.40%   93.37%   -0.04%     
==========================================
  Files         123      123              
  Lines       35716    35724       +8     
  Branches    35716    35724       +8     
==========================================
- Hits        33361    33357       -4     
- Misses       1509     1521      +12     
  Partials      846      846              
Components Coverage Δ
neqo-common 97.30% <ø> (ø)
neqo-crypto 83.25% <ø> (-0.48%) ⬇️
neqo-http3 93.33% <90.90%> (+<0.01%) ⬆️
neqo-qpack 94.15% <ø> (ø)
neqo-transport 94.46% <ø> (-0.02%) ⬇️
neqo-udp 80.48% <ø> (ø)
mtu 85.76% <ø> (ø)

@github-actions

Copy link
Copy Markdown
Contributor

Client/server transfer results

Performance differences relative to f6821b3.

Transfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.

Client vs. server (params) Mean ± σ Min Max MiB/s ± σ Δ main Δ main
google vs. google 454.9 ± 4.4 448.4 467.3 70.3 ± 7.3
google vs. neqo (cubic, paced) 276.0 ± 4.7 267.0 286.1 115.9 ± 6.8 0.2 0.1%
msquic vs. msquic 170.5 ± 47.8 139.7 507.3 187.7 ± 0.7
msquic vs. neqo (cubic, paced) 188.2 ± 37.0 147.7 383.7 170.0 ± 0.9 1.0 0.5%
neqo vs. google (cubic, paced) 754.8 ± 3.7 749.7 768.9 42.4 ± 8.6 -0.1 -0.0%
neqo vs. msquic (cubic, paced) 158.0 ± 7.1 150.6 184.9 202.5 ± 4.5 -1.0 -0.6%
neqo vs. neqo (cubic) 89.9 ± 3.8 82.7 97.8 356.1 ± 8.4 -1.0 -1.1%
neqo vs. neqo (cubic, paced) 90.2 ± 3.6 83.8 97.9 354.8 ± 8.9 -0.1 -0.1%
neqo vs. neqo (reno) 90.0 ± 4.4 83.6 104.8 355.7 ± 7.3 0.1 0.1%
neqo vs. neqo (reno, paced) 90.9 ± 4.4 83.8 99.7 352.0 ± 7.3 -0.5 -0.6%
neqo vs. quiche (cubic, paced) 193.0 ± 4.6 185.7 202.4 165.8 ± 7.0 💚 -2.4 -1.2%
neqo vs. s2n (cubic, paced) 220.7 ± 4.5 211.7 232.7 145.0 ± 7.1 -0.2 -0.1%
quiche vs. neqo (cubic, paced) 156.1 ± 4.9 144.1 166.8 205.0 ± 6.5 💔 1.9 1.2%
quiche vs. quiche 147.2 ± 5.0 137.5 164.5 217.4 ± 6.4
s2n vs. neqo (cubic, paced) 177.4 ± 5.2 167.5 190.1 180.4 ± 6.2 💔 1.5 0.8%
s2n vs. s2n 246.1 ± 19.8 233.4 343.4 130.0 ± 1.6

Download data for profiler.firefox.com or download performance comparison data.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

Performance differences relative to f6821b3.

1-conn/1-100mb-resp/mtu-1504 (aka. Download)/client: No change in performance detected.
       time:   [200.86 ms 201.29 ms 201.85 ms]
       thrpt:  [495.43 MiB/s 496.80 MiB/s 497.86 MiB/s]
change:
       time:   [−0.2232% +0.0758% +0.4093%] (p = 0.65 > 0.05)
       thrpt:  [−0.4077% −0.0758% +0.2237%]

Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe

1-conn/10_000-parallel-1b-resp/mtu-1504 (aka. RPS)/client: Change within noise threshold.
       time:   [291.82 ms 293.59 ms 295.39 ms]
       thrpt:  [33.854 Kelem/s 34.061 Kelem/s 34.268 Kelem/s]
change:
       time:   [−2.4614% −1.6373% −0.7932%] (p = 0.00 < 0.05)
       thrpt:  [+0.7995% +1.6646% +2.5235%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

1-conn/1-1b-resp/mtu-1504 (aka. HPS)/client: Change within noise threshold.
       time:   [28.468 ms 28.569 ms 28.691 ms]
       thrpt:  [34.854   B/s 35.003   B/s 35.127   B/s]
change:
       time:   [+0.1155% +0.4658% +0.9658%] (p = 0.02 < 0.05)
       thrpt:  [−0.9566% −0.4636% −0.1153%]

Found 20 outliers among 100 measurements (20.00%)
5 (5.00%) low severe
2 (2.00%) high mild
13 (13.00%) high severe

1-conn/1-100mb-req/mtu-1504 (aka. Upload)/client: No change in performance detected.
       time:   [208.70 ms 209.00 ms 209.36 ms]
       thrpt:  [477.65 MiB/s 478.46 MiB/s 479.17 MiB/s]
change:
       time:   [−0.2259% −0.0076% +0.2204%] (p = 0.95 > 0.05)
       thrpt:  [−0.2199% +0.0076% +0.2264%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe

decode 4096 bytes, mask ff: Change within noise threshold.
       time:   [11.594 µs 11.615 µs 11.644 µs]
       change: [−0.7142% −0.3549% +0.0027%] (p = 0.05 < 0.05)

Found 9 outliers among 100 measurements (9.00%)
1 (1.00%) low severe
3 (3.00%) low mild
5 (5.00%) high severe

decode 1048576 bytes, mask ff: No change in performance detected.
       time:   [3.0221 ms 3.0331 ms 3.0448 ms]
       change: [−0.1881% +0.2898% +0.7843%] (p = 0.24 > 0.05)

Found 12 outliers among 100 measurements (12.00%)
1 (1.00%) high mild
11 (11.00%) high severe

decode 4096 bytes, mask 7f: No change in performance detected.
       time:   [19.945 µs 19.996 µs 20.055 µs]
       change: [−0.8418% −0.3371% +0.1264%] (p = 0.18 > 0.05)

Found 19 outliers among 100 measurements (19.00%)
1 (1.00%) low severe
3 (3.00%) low mild
2 (2.00%) high mild
13 (13.00%) high severe

decode 1048576 bytes, mask 7f: No change in performance detected.
       time:   [5.0409 ms 5.0561 ms 5.0740 ms]
       change: [−0.3575% +0.0877% +0.5044%] (p = 0.69 > 0.05)

Found 16 outliers among 100 measurements (16.00%)
16 (16.00%) high severe

decode 4096 bytes, mask 3f: No change in performance detected.
       time:   [8.2827 µs 8.3219 µs 8.3665 µs]
       change: [−0.8219% +0.0969% +0.8249%] (p = 0.84 > 0.05)

Found 25 outliers among 100 measurements (25.00%)
1 (1.00%) low severe
9 (9.00%) low mild
3 (3.00%) high mild
12 (12.00%) high severe

decode 1048576 bytes, mask 3f: No change in performance detected.
       time:   [1.5867 ms 1.5936 ms 1.6006 ms]
       change: [−0.5980% +0.0152% +0.6292%] (p = 0.89 > 0.05)

Found 7 outliers among 100 measurements (7.00%)
7 (7.00%) high severe

1-streams/each-1000-bytes/wallclock-time: No change in performance detected.
       time:   [592.09 µs 594.01 µs 596.23 µs]
       change: [−0.0868% +0.4653% +0.9903%] (p = 0.09 > 0.05)

Found 6 outliers among 100 measurements (6.00%)
6 (6.00%) high severe
1-streams/each-1000-bytes/simulated-time
time: [118.69 ms 118.90 ms 119.12 ms]
thrpt: [8.1984 KiB/s 8.2130 KiB/s 8.2276 KiB/s]
change:
time: [−0.3515% −0.1055% +0.1398%] (p = 0.40 > 0.05)
thrpt: [−0.1396% +0.1057% +0.3527%]
No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

1000-streams/each-1-bytes/wallclock-time: No change in performance detected.
       time:   [13.985 ms 14.009 ms 14.034 ms]
       change: [−0.3030% −0.0643% +0.1852%] (p = 0.61 > 0.05)
1000-streams/each-1-bytes/simulated-time: No change in performance detected.
       time:   [14.975 s 14.990 s 15.004 s]
       thrpt:  [66.649   B/s 66.713   B/s 66.777   B/s]
change:
       time:   [−0.2271% −0.0917% +0.0443%] (p = 0.19 > 0.05)
       thrpt:  [−0.0443% +0.0918% +0.2276%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

1000-streams/each-1000-bytes/wallclock-time: Change within noise threshold.
       time:   [50.547 ms 50.726 ms 50.918 ms]
       change: [+0.8774% +1.3613% +1.8768%] (p = 0.00 < 0.05)

Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe
1000-streams/each-1000-bytes/simulated-time
time: [18.667 s 18.839 s 19.013 s]
thrpt: [51.363 KiB/s 51.838 KiB/s 52.315 KiB/s]
change:
time: [−1.1990% +0.1421% +1.4370%] (p = 0.84 > 0.05)
thrpt: [−1.4167% −0.1419% +1.2135%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high mild

coalesce_acked_from_zero 1+1 entries: No change in performance detected.
       time:   [88.209 ns 88.510 ns 88.804 ns]
       change: [−0.7070% −0.1409% +0.4249%] (p = 0.64 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
9 (9.00%) high mild
2 (2.00%) high severe

coalesce_acked_from_zero 3+1 entries: No change in performance detected.
       time:   [106.17 ns 106.59 ns 107.03 ns]
       change: [−0.3858% +0.0754% +0.5557%] (p = 0.75 > 0.05)

Found 12 outliers among 100 measurements (12.00%)
12 (12.00%) high severe

coalesce_acked_from_zero 10+1 entries: No change in performance detected.
       time:   [105.46 ns 105.81 ns 106.26 ns]
       change: [−1.1406% −0.1526% +0.8016%] (p = 0.78 > 0.05)

Found 16 outliers among 100 measurements (16.00%)
4 (4.00%) low severe
2 (2.00%) low mild
10 (10.00%) high severe

coalesce_acked_from_zero 1000+1 entries: No change in performance detected.
       time:   [89.218 ns 89.368 ns 89.540 ns]
       change: [−0.9603% +0.1542% +1.2508%] (p = 0.79 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
3 (3.00%) high mild
8 (8.00%) high severe

RxStreamOrderer::inbound_frame(): Change within noise threshold.
       time:   [110.18 ms 110.29 ms 110.45 ms]
       change: [+0.3150% +0.4519% +0.6145%] (p = 0.00 < 0.05)

Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

sent::Packets::take_ranges: :green_heart: Performance has improved.
       time:   [4.5135 µs 4.6212 µs 4.7228 µs]
       change: [−7.0650% −4.1535% −1.0614%] (p = 0.01 < 0.05)

Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

transfer/pacing-false/varying-seeds/wallclock-time/run: Change within noise threshold.
       time:   [26.067 ms 26.104 ms 26.143 ms]
       change: [−0.9842% −0.7749% −0.5602%] (p = 0.00 < 0.05)

Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

transfer/pacing-false/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [25.116 s 25.150 s 25.185 s]
       thrpt:  [162.64 KiB/s 162.86 KiB/s 163.09 KiB/s]
change:
       time:   [−0.2866% −0.0777% +0.1287%] (p = 0.47 > 0.05)
       thrpt:  [−0.1285% +0.0778% +0.2874%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

transfer/pacing-true/varying-seeds/wallclock-time/run: No change in performance detected.
       time:   [26.703 ms 26.773 ms 26.846 ms]
       change: [−0.5900% −0.2206% +0.1474%] (p = 0.25 > 0.05)

Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe

transfer/pacing-true/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [24.965 s 25.007 s 25.049 s]
       thrpt:  [163.52 KiB/s 163.79 KiB/s 164.07 KiB/s]
change:
       time:   [−0.0757% +0.1656% +0.4050%] (p = 0.19 > 0.05)
       thrpt:  [−0.4034% −0.1653% +0.0758%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

transfer/pacing-false/same-seed/wallclock-time/run: No change in performance detected.
       time:   [26.027 ms 26.056 ms 26.098 ms]
       change: [−0.0175% +0.1350% +0.3259%] (p = 0.12 > 0.05)

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe

transfer/pacing-false/same-seed/simulated-time/run: No change in performance detected.
       time:   [25.152 s 25.152 s 25.152 s]
       thrpt:  [162.85 KiB/s 162.85 KiB/s 162.85 KiB/s]
change:
       time:   [+0.0000% +0.0000% +0.0000%] (p = NaN > 0.05)
       thrpt:  [+0.0000% +0.0000% +0.0000%]
transfer/pacing-true/same-seed/wallclock-time/run: Change within noise threshold.
       time:   [27.747 ms 27.784 ms 27.836 ms]
       change: [−1.8767% −1.7309% −1.5263%] (p = 0.00 < 0.05)

Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

transfer/pacing-true/same-seed/simulated-time/run: No change in performance detected.
       time:   [25.588 s 25.588 s 25.588 s]
       thrpt:  [160.07 KiB/s 160.07 KiB/s 160.07 KiB/s]
change:
       time:   [+0.0000% +0.0000% +0.0000%] (p = NaN > 0.05)
       thrpt:  [+0.0000% +0.0000% +0.0000%]

Download data for profiler.firefox.com or download performance comparison data.

@mxinden
mxinden marked this pull request as ready for review September 28, 2025 18:57
@github-actions

Copy link
Copy Markdown
Contributor

Failed Interop Tests

QUIC Interop Runner, client vs. server, differences relative to f6821b3.

neqo-latest as client

neqo-latest as server

All results

Succeeded Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

Unsupported Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

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.

http3: handle >1 byte connect-udp context id varint

3 participants