tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dce014621e7f3de5de95ca075424d01026949b65
parent 8e11aec37dcca61ac636cfaf49522474c4f906ae
Author: Sandor Molnar <smolnar@mozilla.com>
Date:   Tue, 21 Oct 2025 22:14:04 +0300

Revert "Bug 1994955 - Update neqo to v0.17.0 r=necko-reviewers,supply-chain-reviewers,valentin" for causing xpc failures @ test_http3_with_proxy.js

This reverts commit dea51a7819de7a3dd2a3a995b80ce1cc1c1c0b25.

Diffstat:
M.cargo/config.toml.in | 4++--
MCargo.lock | 30+++++++++++++++---------------
Mnetwerk/socket/neqo_glue/Cargo.toml | 12++++++------
Mnetwerk/socket/neqo_glue/src/lib.rs | 49+++++++++++++++++++------------------------------
Mnetwerk/test/http3server/Cargo.toml | 12++++++------
Mnetwerk/test/http3server/src/main.rs | 188++++++++++++++++++++++++++++++++++++-------------------------------------------
Msupply-chain/audits.toml | 2+-
Mthird_party/rust/mtu/.cargo-checksum.json | 4++--
Mthird_party/rust/mtu/Cargo.toml | 8--------
Mthird_party/rust/mtu/src/lib.rs | 3---
Mthird_party/rust/neqo-bin/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-bin/Cargo.toml | 11+----------
Mthird_party/rust/neqo-bin/src/client/http3.rs | 35+++++++++--------------------------
Mthird_party/rust/neqo-bin/src/client/mod.rs | 5-----
Mthird_party/rust/neqo-bin/src/lib.rs | 3---
Mthird_party/rust/neqo-bin/src/server/http3.rs | 16+++++++---------
Mthird_party/rust/neqo-bin/src/udp.rs | 7-------
Mthird_party/rust/neqo-common/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-common/Cargo.toml | 11+----------
Dthird_party/rust/neqo-common/src/bytes.rs | 138-------------------------------------------------------------------------------
Mthird_party/rust/neqo-common/src/codec.rs | 24+++++++++++-------------
Mthird_party/rust/neqo-common/src/datagram.rs | 10+---------
Mthird_party/rust/neqo-common/src/header.rs | 1-
Mthird_party/rust/neqo-common/src/hrtime.rs | 1-
Mthird_party/rust/neqo-common/src/incrdecoder.rs | 1-
Mthird_party/rust/neqo-common/src/lib.rs | 4----
Mthird_party/rust/neqo-common/src/qlog.rs | 25++++++++++++++++++++++---
Mthird_party/rust/neqo-common/src/tos.rs | 1-
Mthird_party/rust/neqo-crypto/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-crypto/Cargo.toml | 12++----------
Mthird_party/rust/neqo-crypto/src/aead.rs | 143++++++++++++++++++++++++++++++++-----------------------------------------------
Mthird_party/rust/neqo-crypto/src/aead_null.rs | 91+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mthird_party/rust/neqo-crypto/src/agent.rs | 1-
Mthird_party/rust/neqo-crypto/src/err.rs | 1-
Mthird_party/rust/neqo-crypto/src/hp.rs | 10++++++----
Mthird_party/rust/neqo-crypto/src/lib.rs | 3---
Mthird_party/rust/neqo-crypto/src/p11.rs | 1-
Mthird_party/rust/neqo-crypto/src/result.rs | 1-
Mthird_party/rust/neqo-crypto/src/selfencrypt.rs | 7+++----
Mthird_party/rust/neqo-crypto/src/ssl.rs | 1-
Mthird_party/rust/neqo-crypto/src/time.rs | 1-
Mthird_party/rust/neqo-crypto/tests/aead.rs | 13+------------
Mthird_party/rust/neqo-crypto/tests/hp.rs | 14++++++++++++++
Mthird_party/rust/neqo-http3/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-http3/Cargo.toml | 11+----------
Mthird_party/rust/neqo-http3/src/buffered_send_stream.rs | 17+++++------------
Mthird_party/rust/neqo-http3/src/client_events.rs | 8++++----
Mthird_party/rust/neqo-http3/src/conn_params.rs | 1-
Mthird_party/rust/neqo-http3/src/connection.rs | 101++++++++++++++++++++++---------------------------------------------------------
Mthird_party/rust/neqo-http3/src/connection_client.rs | 127++++++++++++++++++++++++++-----------------------------------------------------
Mthird_party/rust/neqo-http3/src/connection_server.rs | 50+++++++++++++-------------------------------------
Mthird_party/rust/neqo-http3/src/control_stream_local.rs | 9+++------
Mthird_party/rust/neqo-http3/src/control_stream_remote.rs | 21++++++++++-----------
Mthird_party/rust/neqo-http3/src/features/extended_connect/connect_udp_session.rs | 56++++++++++----------------------------------------------
Mthird_party/rust/neqo-http3/src/features/extended_connect/mod.rs | 41++++++++++-------------------------------
Mthird_party/rust/neqo-http3/src/features/extended_connect/session.rs | 106++++++++++++++++++++++++++++++-------------------------------------------------
Mthird_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs | 18+++++++++---------
Mthird_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs | 18+++++++-----------
Mthird_party/rust/neqo-http3/src/features/extended_connect/webtransport_session.rs | 14++++++--------
Mthird_party/rust/neqo-http3/src/features/extended_connect/webtransport_streams.rs | 19+++++++------------
Mthird_party/rust/neqo-http3/src/frames/connect_udp_frame.rs | 1-
Mthird_party/rust/neqo-http3/src/frames/mod.rs | 1-
Mthird_party/rust/neqo-http3/src/frames/reader.rs | 13++++++-------
Mthird_party/rust/neqo-http3/src/frames/tests/mod.rs | 8++++----
Mthird_party/rust/neqo-http3/src/frames/tests/reader.rs | 34++++++++++++++++++----------------
Mthird_party/rust/neqo-http3/src/headers_checks.rs | 1-
Mthird_party/rust/neqo-http3/src/lib.rs | 29+++++++++--------------------
Mthird_party/rust/neqo-http3/src/priority.rs | 1-
Mthird_party/rust/neqo-http3/src/qlog.rs | 62++++++++++++++++++++++++++++++--------------------------------
Mthird_party/rust/neqo-http3/src/qpack_decoder_receiver.rs | 4++--
Mthird_party/rust/neqo-http3/src/qpack_encoder_receiver.rs | 8+++-----
Mthird_party/rust/neqo-http3/src/recv_message.rs | 39++++++++++++---------------------------
Mthird_party/rust/neqo-http3/src/send_message.rs | 19+++++++++----------
Mthird_party/rust/neqo-http3/src/server.rs | 5++---
Mthird_party/rust/neqo-http3/src/server_connection_events.rs | 8++++----
Mthird_party/rust/neqo-http3/src/server_events.rs | 45+++++++++++++++++++--------------------------
Mthird_party/rust/neqo-http3/src/settings.rs | 1-
Mthird_party/rust/neqo-http3/src/stream_type_reader.rs | 9++++-----
Mthird_party/rust/neqo-http3/tests/classic_connect.rs | 4++--
Mthird_party/rust/neqo-http3/tests/connect_udp.rs | 20+++++++++-----------
Mthird_party/rust/neqo-http3/tests/httpconn.rs | 38+++++++++++++++++++-------------------
Mthird_party/rust/neqo-http3/tests/send_message.rs | 63+++++++++++++++++++++++++++------------------------------------
Mthird_party/rust/neqo-http3/tests/webtransport.rs | 19+++++++------------
Mthird_party/rust/neqo-qpack/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-qpack/Cargo.toml | 11+----------
Mthird_party/rust/neqo-qpack/src/decoder.rs | 1-
Mthird_party/rust/neqo-qpack/src/decoder_instructions.rs | 1-
Mthird_party/rust/neqo-qpack/src/encoder.rs | 71+++++++++++++++++++++++++++--------------------------------------------
Mthird_party/rust/neqo-qpack/src/encoder_instructions.rs | 1-
Mthird_party/rust/neqo-qpack/src/header_block.rs | 1-
Mthird_party/rust/neqo-qpack/src/huffman.rs | 1-
Mthird_party/rust/neqo-qpack/src/lib.rs | 2--
Mthird_party/rust/neqo-qpack/src/qlog.rs | 45+++++++++++++++++++--------------------------
Mthird_party/rust/neqo-qpack/src/qpack_send_buf.rs | 1-
Mthird_party/rust/neqo-qpack/src/reader.rs | 3---
Mthird_party/rust/neqo-qpack/src/table.rs | 1-
Mthird_party/rust/neqo-transport/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-transport/Cargo.toml | 11+----------
Mthird_party/rust/neqo-transport/src/addr_valid.rs | 1-
Mthird_party/rust/neqo-transport/src/cc/classic_cc.rs | 32+++++++++++++++++++-------------
Mthird_party/rust/neqo-transport/src/cc/cubic.rs | 429++++++++++++++++++++++++++++---------------------------------------------------
Mthird_party/rust/neqo-transport/src/cc/mod.rs | 1-
Mthird_party/rust/neqo-transport/src/cc/tests/cubic.rs | 46++++++++++++++++++++++++++++------------------
Mthird_party/rust/neqo-transport/src/cid.rs | 1-
Mthird_party/rust/neqo-transport/src/connection/mod.rs | 33++++++++++++++-------------------
Mthird_party/rust/neqo-transport/src/connection/params.rs | 4+---
Mthird_party/rust/neqo-transport/src/connection/tests/cc.rs | 6+-----
Mthird_party/rust/neqo-transport/src/connection/tests/datagram.rs | 18+++++++++++++++++-
Mthird_party/rust/neqo-transport/src/connection/tests/handshake.rs | 9+--------
Mthird_party/rust/neqo-transport/src/connection/tests/idle.rs | 20++++++++------------
Mthird_party/rust/neqo-transport/src/connection/tests/mod.rs | 2+-
Mthird_party/rust/neqo-transport/src/connection/tests/recovery.rs | 8++------
Mthird_party/rust/neqo-transport/src/connection/tests/resumption.rs | 2+-
Mthird_party/rust/neqo-transport/src/crypto.rs | 25+++++++++++--------------
Mthird_party/rust/neqo-transport/src/ecn.rs | 8++++----
Mthird_party/rust/neqo-transport/src/events.rs | 1-
Mthird_party/rust/neqo-transport/src/fc.rs | 1-
Mthird_party/rust/neqo-transport/src/frame.rs | 1-
Mthird_party/rust/neqo-transport/src/lib.rs | 2--
Mthird_party/rust/neqo-transport/src/pace.rs | 1-
Mthird_party/rust/neqo-transport/src/packet/mod.rs | 43+++++++++++++++++++++----------------------
Mthird_party/rust/neqo-transport/src/packet/retry.rs | 4++--
Mthird_party/rust/neqo-transport/src/pmtud.rs | 33+++++++++++----------------------
Mthird_party/rust/neqo-transport/src/qlog.rs | 24++++++++++++------------
Mthird_party/rust/neqo-transport/src/quic_datagrams.rs | 22+++-------------------
Mthird_party/rust/neqo-transport/src/recovery/mod.rs | 11+++++------
Mthird_party/rust/neqo-transport/src/recovery/sent.rs | 1-
Mthird_party/rust/neqo-transport/src/recv_stream.rs | 1-
Mthird_party/rust/neqo-transport/src/rtt.rs | 14++++++++------
Mthird_party/rust/neqo-transport/src/send_stream.rs | 1-
Mthird_party/rust/neqo-transport/src/server.rs | 15+++++----------
Mthird_party/rust/neqo-transport/src/sni.rs | 1-
Mthird_party/rust/neqo-transport/src/stream_id.rs | 1-
Mthird_party/rust/neqo-transport/src/tparams.rs | 1-
Mthird_party/rust/neqo-transport/src/tracking.rs | 1-
Mthird_party/rust/neqo-transport/tests/connection.rs | 10+++++-----
Mthird_party/rust/neqo-transport/tests/retry.rs | 2+-
Mthird_party/rust/neqo-transport/tests/server.rs | 11+++++------
Mthird_party/rust/neqo-udp/.cargo-checksum.json | 4++--
Mthird_party/rust/neqo-udp/Cargo.toml | 15++-------------
Mthird_party/rust/neqo-udp/src/lib.rs | 9---------
141 files changed, 1110 insertions(+), 1892 deletions(-)

diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in @@ -110,9 +110,9 @@ git = "https://github.com/mozilla/mp4parse-rust" rev = "f955be5d2a04a631c0f1777d6f35370ea1a99e2d" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/neqo?tag=v0.17.0"] +[source."git+https://github.com/mozilla/neqo?tag=v0.16.1"] git = "https://github.com/mozilla/neqo" -tag = "v0.17.0" +tag = "v0.16.1" replace-with = "vendored-sources" [source."git+https://github.com/rust-lang/rust-bindgen?rev=9366e0af8da529c958b4cd4fcbe492d951c86f5c"] diff --git a/Cargo.lock b/Cargo.lock @@ -4713,7 +4713,7 @@ dependencies = [ [[package]] name = "mtu" version = "0.2.9" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "bindgen 0.69.999", "cfg_aliases", @@ -4757,8 +4757,8 @@ dependencies = [ [[package]] name = "neqo-bin" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "clap", "clap-verbosity-flag", @@ -4781,8 +4781,8 @@ dependencies = [ [[package]] name = "neqo-common" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "enum-map", "env_logger", @@ -4795,8 +4795,8 @@ dependencies = [ [[package]] name = "neqo-crypto" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "bindgen 0.69.999", "enum-map", @@ -4813,8 +4813,8 @@ dependencies = [ [[package]] name = "neqo-http3" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "enumset", "log", @@ -4832,8 +4832,8 @@ dependencies = [ [[package]] name = "neqo-qpack" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "log", "neqo-common", @@ -4846,8 +4846,8 @@ dependencies = [ [[package]] name = "neqo-transport" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "enum-map", "enumset", @@ -4866,8 +4866,8 @@ dependencies = [ [[package]] name = "neqo-udp" -version = "0.17.0" -source = "git+https://github.com/mozilla/neqo?tag=v0.17.0#0f8a822da1766cd397a4b0687f23da096d762733" +version = "0.16.1" +source = "git+https://github.com/mozilla/neqo?tag=v0.16.1#b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" dependencies = [ "cfg_aliases", "libc", diff --git a/netwerk/socket/neqo_glue/Cargo.toml b/netwerk/socket/neqo_glue/Cargo.toml @@ -10,11 +10,11 @@ name = "neqo_glue" [dependencies] firefox-on-glean = { path = "../../../toolkit/components/glean/api" } -neqo-udp = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-http3 = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-transport = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo", features = ["gecko"] } -neqo-common = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-qpack = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } +neqo-udp = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-http3 = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-transport = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo", features = ["gecko"] } +neqo-common = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-qpack = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } nserror = { path = "../../../xpcom/rust/nserror" } nsstring = { path = "../../../xpcom/rust/nsstring" } xpcom = { path = "../../../xpcom/rust/xpcom" } @@ -31,7 +31,7 @@ zlib-rs = "0.4.2" winapi = {version = "0.3", features = ["ws2def"] } [dependencies.neqo-crypto] -tag= "v0.17.0" +tag = "v0.16.1" git = "https://github.com/mozilla/neqo" default-features = false features = ["gecko"] diff --git a/netwerk/socket/neqo_glue/src/lib.rs b/netwerk/socket/neqo_glue/src/lib.rs @@ -24,9 +24,9 @@ use firefox_on_glean::{ metrics::networking, private::{LocalCustomDistribution, LocalMemoryDistribution}, }; +use libc::{c_uchar, size_t}; #[cfg(not(windows))] use libc::{c_int, AF_INET, AF_INET6}; -use libc::{c_uchar, size_t}; use neqo_common::{ event::Provider as _, qdebug, qerror, qlog::Qlog, qwarn, Datagram, DatagramBatch, Decoder, Encoder, Header, Role, Tos, @@ -233,7 +233,7 @@ fn enable_zstd_decoder(c: &mut Connection) -> neqo_transport::Res<()> { }; // ZSTD_isError return 1 if error, 0 otherwise - if unsafe { ZSTD_isError(output_len) != 0 } { + if unsafe {ZSTD_isError(output_len) != 0} { qdebug!("zstd compression failed with {output_len}"); return Err(neqo_crypto::Error::CertificateDecoding); } @@ -420,13 +420,6 @@ impl NeqoHttp3Conn { } }; - let pmtud_enabled = - // Check if PMTUD is explicitly enabled, - pmtud_enabled - // but disable PMTUD if NSPR is used (socket == None) or - // transmitted UDP datagrams might get fragmented by the IP layer. - && socket.as_ref().map_or(false, |s| !s.may_fragment()); - let params = ConnectionParameters::default() .versions(quic_version, version_list) .cc_algorithm(cc_algorithm) @@ -439,8 +432,7 @@ impl NeqoHttp3Conn { .pmtud_iface_mtu(cfg!(not(target_os = "openbsd"))) // MLKEM support is configured further below. By default, disable it. .mlkem(false) - .datagram_size(1500) - .pmtud(pmtud_enabled); + .datagram_size(1500).pmtud(pmtud_enabled); // Set a short timeout when fuzzing. #[cfg(feature = "fuzzing")] @@ -525,7 +517,6 @@ impl NeqoHttp3Conn { Some("Firefox Client qlog".to_string()), Some("Firefox Client qlog".to_string()), format!("{}_{}.qlog", origin, Uuid::new_v4()), - Instant::now(), ) { Ok(qlog) => conn.set_qlog(qlog), Err(e) => { @@ -1252,7 +1243,12 @@ pub extern "C" fn neqo_http3conn_connect( return NS_ERROR_INVALID_ARG; } let priority = Priority::new(urgency, incremental); - match conn.conn.connect(Instant::now(), host_tmp, &hdrs, priority) { + match conn.conn.connect( + Instant::now(), + host_tmp, + &hdrs, + priority, + ) { Ok(id) => { *stream_id = id.as_u64(); NS_OK @@ -1295,7 +1291,7 @@ pub unsafe extern "C" fn neqo_htttp3conn_send_request_body( ) -> nsresult { let array = slice::from_raw_parts(buf, len as usize); conn.conn - .send_data(StreamId::from(stream_id), array, Instant::now()) + .send_data(StreamId::from(stream_id), array) .map_or(NS_ERROR_UNEXPECTED, |amount| { let Ok(amount) = u32::try_from(amount) else { return NS_ERROR_UNEXPECTED; @@ -1533,10 +1529,7 @@ pub extern "C" fn neqo_http3conn_close_stream( conn: &mut NeqoHttp3Conn, stream_id: u64, ) -> nsresult { - match conn - .conn - .stream_close_send(StreamId::from(stream_id), Instant::now()) - { + match conn.conn.stream_close_send(StreamId::from(stream_id)) { Ok(()) => NS_OK, Err(_) => NS_ERROR_INVALID_ARG, } @@ -2245,12 +2238,10 @@ pub extern "C" fn neqo_http3conn_webtransport_close_session( let Ok(message_tmp) = str::from_utf8(message) else { return NS_ERROR_INVALID_ARG; }; - match conn.conn.webtransport_close_session( - StreamId::from(session_id), - error, - message_tmp, - Instant::now(), - ) { + match conn + .conn + .webtransport_close_session(StreamId::from(session_id), error, message_tmp) + { Ok(()) => NS_OK, Err(_) => NS_ERROR_INVALID_ARG, } @@ -2266,12 +2257,10 @@ pub extern "C" fn neqo_http3conn_connect_udp_close_session( let Ok(message_tmp) = str::from_utf8(message) else { return NS_ERROR_INVALID_ARG; }; - match conn.conn.connect_udp_close_session( - StreamId::from(session_id), - error, - message_tmp, - Instant::now(), - ) { + match conn + .conn + .connect_udp_close_session(StreamId::from(session_id), error, message_tmp) + { Ok(()) => NS_OK, Err(_) => NS_ERROR_INVALID_ARG, } diff --git a/netwerk/test/http3server/Cargo.toml b/netwerk/test/http3server/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" license = "MPL-2.0" [dependencies] -neqo-bin = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-transport = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo", features = ["gecko"] } -neqo-common = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-http3 = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } -neqo-qpack = { tag= "v0.17.0", git = "https://github.com/mozilla/neqo" } +neqo-bin = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-transport = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo", features = ["gecko"] } +neqo-common = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-http3 = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } +neqo-qpack = { tag = "v0.16.1", git = "https://github.com/mozilla/neqo" } log = "0.4.0" base64 = "0.22" cfg-if = "1.0" @@ -21,7 +21,7 @@ tokio = { version = "1", features = ["rt-multi-thread"] } mozilla-central-workspace-hack = { version = "0.1", features = ["http3server"], optional = true } [dependencies.neqo-crypto] -tag= "v0.17.0" +tag = "v0.16.1" git = "https://github.com/mozilla/neqo" default-features = false features = ["gecko"] diff --git a/netwerk/test/http3server/src/main.rs b/netwerk/test/http3server/src/main.rs @@ -6,7 +6,6 @@ use base64::prelude::*; use neqo_bin::server::{HttpServer, Runner}; -use neqo_common::Bytes; use neqo_common::{event::Provider, qdebug, qinfo, qtrace, Datagram, Header}; use neqo_crypto::{generate_ech_keys, init_db, AllowZeroRtt, AntiReplay}; use neqo_http3::{ @@ -76,7 +75,7 @@ struct Http3TestServer { webtransport_bidi_stream: HashSet<Http3OrWebTransportStream>, wt_unidi_conn_to_stream: HashMap<ConnectionRef, Http3OrWebTransportStream>, wt_unidi_echo_back: HashMap<Http3OrWebTransportStream, Http3OrWebTransportStream>, - received_datagram: Option<Bytes>, + received_datagram: Option<Vec<u8>>, } impl ::std::fmt::Display for Http3TestServer { @@ -101,17 +100,17 @@ impl Http3TestServer { } } - fn new_response(&mut self, stream: Http3OrWebTransportStream, mut data: Vec<u8>, now: Instant) { + fn new_response(&mut self, stream: Http3OrWebTransportStream, mut data: Vec<u8>) { if data.len() == 0 { - let _ = stream.stream_close_send(now); + let _ = stream.stream_close_send(); return; } - match stream.send_data(&data, now) { + match stream.send_data(&data) { Ok(sent) => { if sent < data.len() { self.responses.insert(stream, data.split_off(sent)); } else { - let _ = stream.stream_close_send(now); + let _ = stream.stream_close_send(); } } Err(e) => { @@ -120,15 +119,15 @@ impl Http3TestServer { } } - fn handle_stream_writable(&mut self, stream: Http3OrWebTransportStream, now: Instant) { + fn handle_stream_writable(&mut self, stream: Http3OrWebTransportStream) { if let Some(data) = self.responses.get_mut(&stream) { - match stream.send_data(&data, now) { + match stream.send_data(&data) { Ok(sent) => { if sent < data.len() { let new_d = (*data).split_off(sent); *data = new_d; } else { - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); self.responses.remove(&stream); } } @@ -139,11 +138,12 @@ impl Http3TestServer { } } - fn maybe_close_session(&mut self, now: Instant) { + fn maybe_close_session(&mut self) { + let now = Instant::now(); for (expires, sessions) in self.sessions_to_close.iter_mut() { if *expires <= now { for s in sessions.iter_mut() { - drop(s.close_session(0, "", now)); + drop(s.close_session(0, "")); } } } @@ -163,7 +163,7 @@ impl Http3TestServer { .retain(|expires, _| *expires >= now); } - fn maybe_create_wt_stream(&mut self, now: Instant) { + fn maybe_create_wt_stream(&mut self) { if self.sessions_to_create_stream.is_empty() { return; } @@ -172,7 +172,7 @@ impl Http3TestServer { let wt_server_stream = session.create_stream(tuple.1).unwrap(); if tuple.1 == StreamType::UniDi { if let Some(data) = tuple.2 { - self.new_response(wt_server_stream, data, now); + self.new_response(wt_server_stream, data); } else { // relaying Http3ServerEvent::Data to uni streams // slows down netwerk/test/unit/test_webtransport_simple.js @@ -182,7 +182,7 @@ impl Http3TestServer { } } else { if let Some(data) = tuple.2 { - self.new_response(wt_server_stream, data, now); + self.new_response(wt_server_stream, data); } else { self.webtransport_bidi_stream.insert(wt_server_stream); } @@ -218,8 +218,8 @@ impl HttpServer for Http3TestServer { fn process_events(&mut self, now: Instant) { self.maybe_close_connection(); - self.maybe_close_session(now); - self.maybe_create_wt_stream(now); + self.maybe_close_session(); + self.maybe_create_wt_stream(); while let Some(event) = self.server.next_event() { qtrace!("Event: {:?}", event); @@ -262,7 +262,7 @@ impl HttpServer for Http3TestServer { ), ]) .unwrap(); - self.new_response(stream, response_body, now); + self.new_response(stream, response_body); } else if path == "/RequestCancelled" { stream .stream_stop_sending(Error::HttpRequestCancelled.code()) @@ -308,7 +308,7 @@ impl HttpServer for Http3TestServer { .unwrap() .push(stream.conn.clone()); - self.new_response(stream, response_body, now); + self.new_response(stream, response_body); } else if path == "/.well-known/http-opportunistic" { let host_hdr = headers.iter().find(|&h| h.name() == ":authority"); match host_hdr { @@ -327,11 +327,11 @@ impl HttpServer for Http3TestServer { ), ]) .unwrap(); - self.new_response(stream, content, now); + self.new_response(stream, content); } _ => { stream.send_headers(&default_headers).unwrap(); - self.new_response(stream, default_ret, now); + self.new_response(stream, default_ret); } } } else if path == "/no_body" { @@ -342,7 +342,7 @@ impl HttpServer for Http3TestServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } else if path == "/no_content_length" { stream .send_headers(&[ @@ -350,7 +350,7 @@ impl HttpServer for Http3TestServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - self.new_response(stream, vec![b'a'; 4000], now); + self.new_response(stream, vec![b'a'; 4000]); } else if path == "/content_length_smaller" { stream .send_headers(&[ @@ -360,7 +360,7 @@ impl HttpServer for Http3TestServer { Header::new("content-length", 4000.to_string()), ]) .unwrap(); - self.new_response(stream, vec![b'a'; 8000], now); + self.new_response(stream, vec![b'a'; 8000]); } else if path == "/post" { // Read all data before responding. self.posts.insert(stream, 0); @@ -380,11 +380,7 @@ impl HttpServer for Http3TestServer { ), ]) .unwrap(); - self.new_response( - stream, - priority.value().as_bytes().to_vec(), - now, - ); + self.new_response(stream, priority.value().as_bytes().to_vec()); } else { stream .send_headers(&[ @@ -392,7 +388,7 @@ impl HttpServer for Http3TestServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } } else if path == "/103_response" { if let Some(early_hint) = @@ -414,16 +410,20 @@ impl HttpServer for Http3TestServer { Header::new("content-length", "0"), ]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } else if path == "/get_webtransport_datagram" { - if let Some(dgram) = self.received_datagram.take() { + if let Some(vec_ref) = self.received_datagram.as_ref() { stream .send_headers(&[ Header::new(":status", "200"), - Header::new("content-length", dgram.len().to_string()), + Header::new( + "content-length", + vec_ref.len().to_string(), + ), ]) .unwrap(); - self.new_response(stream, dgram.as_ref().to_vec(), now); + self.new_response(stream, vec_ref.to_vec()); + self.received_datagram = None; } else { stream .send_headers(&[ @@ -431,7 +431,7 @@ impl HttpServer for Http3TestServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } } else if path == "/alt_svc_header" { if let Some(alt_svc) = @@ -449,7 +449,7 @@ impl HttpServer for Http3TestServer { ), ]) .unwrap(); - self.new_response(stream, vec![b'a'; 100], now); + self.new_response(stream, vec![b'a'; 100]); } else { stream .send_headers(&[ @@ -457,7 +457,7 @@ impl HttpServer for Http3TestServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - self.new_response(stream, vec![b'a'; 100], now); + self.new_response(stream, vec![b'a'; 100]); } } else { match path.trim_matches(|p| p == '/').parse::<usize>() { @@ -470,18 +470,18 @@ impl HttpServer for Http3TestServer { Header::new("content-length", v.to_string()), ]) .unwrap(); - self.new_response(stream, vec![b'a'; v], now); + self.new_response(stream, vec![b'a'; v]); } Err(_) => { stream.send_headers(&default_headers).unwrap(); - self.new_response(stream, default_ret, now); + self.new_response(stream, default_ret); } } } } _ => { stream.send_headers(&default_headers).unwrap(); - self.new_response(stream, default_ret, now); + self.new_response(stream, default_ret); } } } @@ -489,7 +489,7 @@ impl HttpServer for Http3TestServer { // echo bidirectional input back to client if self.webtransport_bidi_stream.contains(&stream) { if stream.handler.borrow().state().active() { - self.new_response(stream, data, now); + self.new_response(stream, data); } break; } @@ -498,8 +498,8 @@ impl HttpServer for Http3TestServer { // need to close or we hang if self.wt_unidi_echo_back.contains_key(&stream) { let echo_back = self.wt_unidi_echo_back.remove(&stream).unwrap(); - echo_back.send_data(&data, now).unwrap(); - echo_back.stream_close_send(now).unwrap(); + echo_back.send_data(&data).unwrap(); + echo_back.stream_close_send().unwrap(); break; } @@ -517,13 +517,11 @@ impl HttpServer for Http3TestServer { Header::new("content-length", default_ret.len().to_string()), ]) .unwrap(); - self.new_response(stream, default_ret, now); + self.new_response(stream, default_ret); } } } - Http3ServerEvent::DataWritable { stream } => { - self.handle_stream_writable(stream, now) - } + Http3ServerEvent::DataWritable { stream } => self.handle_stream_writable(stream), Http3ServerEvent::StateChange { conn, state } => { if matches!(state, neqo_http3::Http3State::Connected) { let mut h = DefaultHasher::new(); @@ -557,37 +555,31 @@ impl HttpServer for Http3TestServer { let path = ph.value(); qtrace!("Serve request {}", path); if path == "/success" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); } else if path == "/redirect" { session - .response( - &SessionAcceptAction::Reject( - [ - Header::new(":status", "302"), - Header::new("location", "/"), - ] - .to_vec(), - ), - now, - ) + .response(&SessionAcceptAction::Reject( + [ + Header::new(":status", "302"), + Header::new("location", "/"), + ] + .to_vec(), + )) .unwrap(); } else if path == "/reject" { session - .response( - &SessionAcceptAction::Reject( - [Header::new(":status", "404")].to_vec(), - ), - now, - ) + .response(&SessionAcceptAction::Reject( + [Header::new(":status", "404")].to_vec(), + )) .unwrap(); } else if path == "/closeafter0ms" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); if !self.sessions_to_close.contains_key(&now) { self.sessions_to_close.insert(now, Vec::new()); } self.sessions_to_close.get_mut(&now).unwrap().push(session); } else if path == "/closeafter100ms" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); let expires = Instant::now() + Duration::from_millis(100); if !self.sessions_to_close.contains_key(&expires) { self.sessions_to_close.insert(expires, Vec::new()); @@ -597,21 +589,21 @@ impl HttpServer for Http3TestServer { .unwrap() .push(session); } else if path == "/create_unidi_stream" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); self.sessions_to_create_stream.push(( session, StreamType::UniDi, None, )); } else if path == "/create_unidi_stream_and_hello" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); self.sessions_to_create_stream.push(( session, StreamType::UniDi, Some(Vec::from("qwerty")), )); } else if path == "/create_bidi_stream" { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); self.sessions_to_create_stream.push(( session, StreamType::BiDi, @@ -619,7 +611,7 @@ impl HttpServer for Http3TestServer { )); } else if path == "/create_bidi_stream_and_hello" { self.webtransport_bidi_stream.clear(); - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); self.sessions_to_create_stream.push(( session, StreamType::BiDi, @@ -628,24 +620,21 @@ impl HttpServer for Http3TestServer { } else if path == "/create_bidi_stream_and_large_data" { self.webtransport_bidi_stream.clear(); let data: Vec<u8> = vec![1u8; 32 * 1024 * 1024]; - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); self.sessions_to_create_stream.push(( session, StreamType::BiDi, Some(data), )); } else { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); } } _ => { session - .response( - &SessionAcceptAction::Reject( - [Header::new(":status", "404")].to_vec(), - ), - now, - ) + .response(&SessionAcceptAction::Reject( + [Header::new(":status", "404")].to_vec(), + )) .unwrap(); } } @@ -775,17 +764,17 @@ impl Http3ReverseProxyServer { } #[cfg(not(target_os = "android"))] - fn new_response(&mut self, stream: Http3OrWebTransportStream, mut data: Vec<u8>, now: Instant) { + fn new_response(&mut self, stream: Http3OrWebTransportStream, mut data: Vec<u8>) { if data.len() == 0 { - let _ = stream.stream_close_send(now); + let _ = stream.stream_close_send(); return; } - match stream.send_data(&data, now) { + match stream.send_data(&data) { Ok(sent) => { if sent < data.len() { self.responses.insert(stream, data.split_off(sent)); } else { - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } } Err(e) => { @@ -795,15 +784,15 @@ impl Http3ReverseProxyServer { } } - fn handle_stream_writable(&mut self, stream: Http3OrWebTransportStream, now: Instant) { + fn handle_stream_writable(&mut self, stream: Http3OrWebTransportStream) { if let Some(data) = self.responses.get_mut(&stream) { - match stream.send_data(&data, now) { + match stream.send_data(&data) { Ok(sent) => { if sent < data.len() { let new_d = (*data).split_off(sent); *data = new_d; } else { - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); self.responses.remove(&stream); } } @@ -926,7 +915,7 @@ impl Http3ReverseProxyServer { } #[cfg(not(target_os = "android"))] - fn maybe_process_response(&mut self, now: Instant) { + fn maybe_process_response(&mut self) { let mut data_to_send = HashMap::new(); self.response_to_send .retain(|id, receiver| match receiver.try_recv() { @@ -942,7 +931,7 @@ impl Http3ReverseProxyServer { qtrace!("response headers: {:?}", header); match stream.send_headers(&header) { Ok(()) => { - self.new_response(stream, data, now); + self.new_response(stream, data); } _ => {} } @@ -977,9 +966,9 @@ impl HttpServer for Http3ReverseProxyServer { output } - fn process_events(&mut self, now: Instant) { + fn process_events(&mut self, _now: Instant) { #[cfg(not(target_os = "android"))] - self.maybe_process_response(now); + self.maybe_process_response(); while let Some(event) = self.server.next_event() { qtrace!("Event: {:?}", event); match event { @@ -1053,9 +1042,7 @@ impl HttpServer for Http3ReverseProxyServer { } } } - Http3ServerEvent::DataWritable { stream } => { - self.handle_stream_writable(stream, now) - } + Http3ServerEvent::DataWritable { stream } => self.handle_stream_writable(stream), Http3ServerEvent::StateChange { .. } | Http3ServerEvent::PriorityUpdate { .. } => {} Http3ServerEvent::StreamReset { stream, error } => { qtrace!("Http3ServerEvent::StreamReset {:?} {:?}", stream, error); @@ -1110,7 +1097,7 @@ impl HttpServer for Http3ConnectProxyServer { self.server.process_multiple(dgrams, now, max_datagrams) } - fn process_events(&mut self, now: Instant) { + fn process_events(&mut self, _now: Instant) { while let Some(event) = self.server.next_event() { qtrace!("Event: {:?}", event); match event { @@ -1161,7 +1148,7 @@ impl HttpServer for Http3ConnectProxyServer { Header::new("cache-control", "no-cache"), ]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); return; } }; @@ -1201,7 +1188,7 @@ impl HttpServer for Http3ConnectProxyServer { let tcp_stream = self.tcp_streams.get_mut(&stream.stream_id()).unwrap(); while !tcp_stream.recv_buffer.is_empty() { let sent = stream - .send_data(&tcp_stream.recv_buffer.make_contiguous(), now) + .send_data(&tcp_stream.recv_buffer.make_contiguous()) .unwrap(); qtrace!("tcp_stream send to client sent={}", sent); if sent == 0 { @@ -1214,7 +1201,7 @@ impl HttpServer for Http3ConnectProxyServer { session, headers, }) => { - session.response(&SessionAcceptAction::Accept, now).unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); let host_hdr = headers.iter().find(|&h| h.name() == ":path").unwrap(); let path_parts: Vec<&str> = host_hdr.value().split('/').collect(); @@ -1312,10 +1299,7 @@ impl HttpServer for Http3ConnectProxyServer { while !stream.recv_buffer.is_empty() { let sent = stream .session - .send_data( - &stream.recv_buffer.make_contiguous(), - Instant::now(), - ) + .send_data(&stream.recv_buffer.make_contiguous()) .unwrap(); qdebug!("TCP: stream send to client sent={}", sent); if sent == 0 { @@ -1383,14 +1367,14 @@ impl HttpServer for Http3ConnectProxyServer { } while let Some(datagram) = socket.send_buffer.pop_front() { - match socket.socket.poll_send(cx, datagram.as_ref()) { + match socket.socket.poll_send(cx, datagram.as_slice()) { Poll::Ready(Ok(0)) | Poll::Pending => { socket.send_buffer.push_front(datagram); break; } Poll::Ready(Ok(n)) => { assert_eq!(n, datagram.len()); - qinfo!("Sent {}/{} bytes to origin", n, datagram.len()); + qinfo!("Sent {}/{} bytes to origin", n, datagram.as_slice().len()); progressed = true; } Poll::Ready(Err(e)) => { @@ -1419,7 +1403,7 @@ struct TcpStream { struct UdpSocket { session: ConnectUdpRequest, - send_buffer: VecDeque<Bytes>, + send_buffer: VecDeque<Vec<u8>>, socket: tokio::net::UdpSocket, } diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml @@ -4216,7 +4216,7 @@ delta = "0.2.6 -> 0.2.9" [[audits.mtu]] who = "Max Leonard Inden <mail@max-inden.de>" criteria = "safe-to-deploy" -delta = "0.2.9 -> 0.2.9@git:0f8a822da1766cd397a4b0687f23da096d762733" +delta = "0.2.9 -> 0.2.9@git:b3d8f0d21db5657ebafb14f9b60c8892d2eb3aa9" importable = false [[audits.naga]] diff --git a/third_party/rust/mtu/.cargo-checksum.json b/third_party/rust/mtu/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".clippy.toml":"6ab1a673bd5c7ba29bd77e62f42183db3ace327c23d446d5b4b0618f6c39d639","Cargo.toml":"b4c4826e5e748da588a67852184dac53e76fe3f31f1b1eb7bb390808688103a5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"4ad721b5b6a3d39ca3e2202f403d897c4a1d42896486dd58963a81f8e64ef61d","README.md":"24df0e24154b7f0096570ad221aea02bd53a0f1124a2adafff5730af5443a65c","SECURITY.md":"75455814b6cf997e22a927eb979b4356d788583aa1eb96e90853aaab0f82ad1b","build.rs":"a4bcd0562c80914a8e909e8b10507605bfd6f0f268fad9ef4d79f4c48bdaed6c","src/bsd.rs":"7641b2a905a5e05505507fdf2e3af37e9c901a997d48759258f9f853cd2ab0e5","src/lib.rs":"6e8702d77e0f211d05862820eec77f2aa8cd8db6ec4de2c5278d223fbd96b31d","src/linux.rs":"aecc6acbea2419dd6cc31e916148e438d8cec20cf001758042299ff2ccc81d39","src/routesocket.rs":"be837947e2c3f9301a174499217fe8920ff492918bf85ca5eb281eb7ad2240e1","src/windows.rs":"d7e18d55b3be5462d2041fc22fb22cf1fc163ec30b107a3274f2bd22ad618411"},"package":null} -\ No newline at end of file +{"files":{".clippy.toml":"6ab1a673bd5c7ba29bd77e62f42183db3ace327c23d446d5b4b0618f6c39d639","Cargo.toml":"732444d59ddb0ea98698c22e8bda203d991231a9828d4643f2af0ceb55213ba0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"4ad721b5b6a3d39ca3e2202f403d897c4a1d42896486dd58963a81f8e64ef61d","README.md":"24df0e24154b7f0096570ad221aea02bd53a0f1124a2adafff5730af5443a65c","SECURITY.md":"75455814b6cf997e22a927eb979b4356d788583aa1eb96e90853aaab0f82ad1b","build.rs":"a4bcd0562c80914a8e909e8b10507605bfd6f0f268fad9ef4d79f4c48bdaed6c","src/bsd.rs":"7641b2a905a5e05505507fdf2e3af37e9c901a997d48759258f9f853cd2ab0e5","src/lib.rs":"eab2e45bbee6a21221e6d6955c8d9b1b301570d27c0d28cdaf7a2bb503d14d93","src/linux.rs":"aecc6acbea2419dd6cc31e916148e438d8cec20cf001758042299ff2ccc81d39","src/routesocket.rs":"be837947e2c3f9301a174499217fe8920ff492918bf85ca5eb281eb7ad2240e1","src/windows.rs":"d7e18d55b3be5462d2041fc22fb22cf1fc163ec30b107a3274f2bd22ad618411"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/mtu/Cargo.toml b/third_party/rust/mtu/Cargo.toml @@ -109,7 +109,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -117,8 +116,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -171,8 +168,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/mtu/src/lib.rs b/third_party/rust/mtu/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - //! A crate to return the name and maximum transmission unit (MTU) of the local network interface //! towards a given destination `SocketAddr`, optionally from a given local `SocketAddr`. //! @@ -131,7 +129,6 @@ pub fn interface_and_mtu(remote: IpAddr) -> Result<(String, usize)> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { #![expect(clippy::unwrap_used, reason = "OK in tests.")] diff --git a/third_party/rust/neqo-bin/.cargo-checksum.json b/third_party/rust/neqo-bin/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"ecd47a2455990f50241cd928d64830bd8d5d292e96107008f91af81f430db7e4","benches/main.rs":"6b7bd05c718020f9180a630a2fe1a13066245ad90ee9b9bf72b7aa9f74709764","src/bin/client.rs":"9df4af3b25159adccfca36d6001443cf295993351fec51f833827d91ebb67fd4","src/bin/server.rs":"f55f26c8f0a34de415ede8c4865b845b3d755c3f5fe4f5574b5ee7f3a3601598","src/client/http09.rs":"7ee588c1a8317f70f8a45cdaf0fdfc49419340dd4b41700de1219e8f5ab6c097","src/client/http3.rs":"0084e2671e761cc46ce18e856f193ebe875386d6bbc4f2dc88f2bd563ca865c9","src/client/mod.rs":"ab34c80769e4996d02f930c136c9c832d130209f435845b68d7ab89fe789fe29","src/lib.rs":"ef20c29297d978a192011371e6af12be26d57063b616d3e21fb3d2750987ce88","src/send_data.rs":"ef8ad949e8b787f77f091a4705672b9801dc79c863d9d54a5296e0839789802e","src/server/http09.rs":"6f8f9bec9c2b8d524f2c331fc0db81c17f71c8c8ac00d50e4b6670c3e226b2b2","src/server/http3.rs":"bc58cd9a11498d574d56e2f7aa80853ed5eca4828065f0841509fdb9bfb576c4","src/server/mod.rs":"3897044c5b690360cf1a872d90f467ff4e629e9283a56bdf633045c2a1a730b0","src/udp.rs":"a0f456178f353fcd91013b3fab46dac14863f979930305c9d5bd5471d953e144"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"5393a1263e2640e1d31d6e9f9f00b9fd6d05fc9f2a576ff9fe2cf9e2474cb904","benches/main.rs":"6b7bd05c718020f9180a630a2fe1a13066245ad90ee9b9bf72b7aa9f74709764","src/bin/client.rs":"9df4af3b25159adccfca36d6001443cf295993351fec51f833827d91ebb67fd4","src/bin/server.rs":"f55f26c8f0a34de415ede8c4865b845b3d755c3f5fe4f5574b5ee7f3a3601598","src/client/http09.rs":"7ee588c1a8317f70f8a45cdaf0fdfc49419340dd4b41700de1219e8f5ab6c097","src/client/http3.rs":"795224a530fca0c890dae874c71abd326458447de688e1c962b12c47e4ef12cb","src/client/mod.rs":"8aee34dab837fb115c5b19f4e17a26c028fa1e6d0b74122faa9a28fc81c88e71","src/lib.rs":"fbc9cb8cbafac11279c76519970a5348f70a09f3e5330bae41bc41700ea6e5c7","src/send_data.rs":"ef8ad949e8b787f77f091a4705672b9801dc79c863d9d54a5296e0839789802e","src/server/http09.rs":"6f8f9bec9c2b8d524f2c331fc0db81c17f71c8c8ac00d50e4b6670c3e226b2b2","src/server/http3.rs":"c0320ea5707ed3a66b17a055567d528c414312fadc5eacc3574612b0673a9825","src/server/mod.rs":"3897044c5b690360cf1a872d90f467ff4e629e9283a56bdf633045c2a1a730b0","src/udp.rs":"2d202a7a0c8ac83c9d9535c2f6afdc6afc6d919da019c8038eb07faf6648a4b8"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-bin/Cargo.toml b/third_party/rust/neqo-bin/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-bin" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = false autolib = false @@ -47,7 +47,6 @@ bench = [ "neqo-bin/bench", "neqo-http3/bench", "neqo-transport/bench", - "log/release_max_level_info", ] draft-29 = [] fast-apple-datapath = ["quinn-udp/fast-apple-datapath"] @@ -206,7 +205,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -214,8 +212,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -268,8 +264,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-bin/src/client/http3.rs b/third_party/rust/neqo-bin/src/client/http3.rs @@ -231,7 +231,7 @@ impl super::Handler for Handler { qwarn!("Data on unexpected stream: {stream_id}"); } Some(handler) => { - handler.process_data_writable(client, stream_id, Instant::now()); + handler.process_data_writable(client, stream_id); } } } @@ -269,12 +269,7 @@ trait StreamHandler { data: &[u8], output_read_data: bool, ) -> Res<()>; - fn process_data_writable( - &mut self, - client: &mut Http3Client, - stream_id: StreamId, - now: Instant, - ); + fn process_data_writable(&mut self, client: &mut Http3Client, stream_id: StreamId); } struct DownloadStreamHandler { @@ -315,13 +310,7 @@ impl StreamHandler for DownloadStreamHandler { Ok(()) } - fn process_data_writable( - &mut self, - _client: &mut Http3Client, - _stream_id: StreamId, - _now: Instant, - ) { - } + fn process_data_writable(&mut self, _client: &mut Http3Client, _stream_id: StreamId) {} } struct UploadStreamHandler { @@ -353,17 +342,12 @@ impl StreamHandler for UploadStreamHandler { } } - fn process_data_writable( - &mut self, - client: &mut Http3Client, - stream_id: StreamId, - now: Instant, - ) { + fn process_data_writable(&mut self, client: &mut Http3Client, stream_id: StreamId) { let done = self .data - .send(|chunk| client.send_data(stream_id, chunk, now).unwrap()); + .send(|chunk| client.send_data(stream_id, chunk).unwrap()); if done { - client.stream_close_send(stream_id, now).unwrap(); + client.stream_close_send(stream_id).unwrap(); } } } @@ -400,9 +384,8 @@ impl UrlHandler { .url_queue .pop_front() .expect("download_next called with empty queue"); - let now = Instant::now(); match client.fetch( - now, + Instant::now(), &self.args.method, &url, &self.args.headers, @@ -418,12 +401,12 @@ impl UrlHandler { self.args.output_dir.as_ref(), &mut self.all_paths, ); - client.stream_close_send(client_stream_id, now).unwrap(); + client.stream_close_send(client_stream_id).unwrap(); Box::new(DownloadStreamHandler { out_file }) } "POST" => Box::new(UploadStreamHandler { data: SendData::zeroes(self.args.upload_size), - start: now, + start: Instant::now(), }), _ => unimplemented!(), }; diff --git a/third_party/rust/neqo-bin/src/client/mod.rs b/third_party/rust/neqo-bin/src/client/mod.rs @@ -547,7 +547,6 @@ fn qlog_new(args: &Args, hostname: &str, cid: &ConnectionId) -> Res<Qlog> { Some("Neqo client qlog".to_string()), Some("Neqo client qlog".to_string()), format!("client-{hostname}-{cid}"), - Instant::now(), ) .map_err(Error::Qlog) } @@ -614,10 +613,6 @@ pub async fn client(mut args: Args) -> Res<()> { exit(1); }; let mut socket = crate::udp::Socket::bind(local_addr_for(&remote_addr, 0))?; - if socket.may_fragment() { - qinfo!("Datagrams may be fragmented by the IP layer. Disabling PMTUD."); - args.shared.quic_parameters.no_pmtud = true; - } let real_local = socket.local_addr().unwrap(); qinfo!( "{} Client connecting: {real_local:?} -> {remote_addr:?}", diff --git a/third_party/rust/neqo-bin/src/lib.rs b/third_party/rust/neqo-bin/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - use std::{ net::{SocketAddr, ToSocketAddrs as _}, path::PathBuf, @@ -276,7 +274,6 @@ pub enum Error { #[cfg(not(target_os = "netbsd"))] // FIXME: Test fails on NetBSD. #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{fs, path::PathBuf, str::FromStr as _, time::SystemTime}; diff --git a/third_party/rust/neqo-bin/src/server/http3.rs b/third_party/rust/neqo-bin/src/server/http3.rs @@ -93,7 +93,6 @@ impl super::HttpServer for HttpServer { } fn process_events(&mut self, _now: Instant) { - let now = Instant::now(); while let Some(event) = self.server.next_event() { match event { Http3ServerEvent::Headers { @@ -123,7 +122,7 @@ impl super::HttpServer for HttpServer { stream .send_headers(&[Header::new(":status", "404")]) .unwrap(); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); continue; } } @@ -141,9 +140,9 @@ impl super::HttpServer for HttpServer { Header::new("content-length", response.len().to_string()), ]) .unwrap(); - let done = response.send(|chunk| stream.send_data(chunk, now).unwrap()); + let done = response.send(|chunk| stream.send_data(chunk).unwrap()); if done { - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } else { self.remaining_data.insert(stream.stream_id(), response); } @@ -151,11 +150,10 @@ impl super::HttpServer for HttpServer { Http3ServerEvent::DataWritable { stream } => { if self.posts.get_mut(&stream).is_none() { if let Some(remaining) = self.remaining_data.get_mut(&stream.stream_id()) { - let done = - remaining.send(|chunk| stream.send_data(chunk, now).unwrap()); + let done = remaining.send(|chunk| stream.send_data(chunk).unwrap()); if done { self.remaining_data.remove(&stream.stream_id()); - stream.stream_close_send(now).unwrap(); + stream.stream_close_send().unwrap(); } } } @@ -171,8 +169,8 @@ impl super::HttpServer for HttpServer { stream .send_headers(&[Header::new(":status", "200")]) .unwrap(); - stream.send_data(&msg, now).unwrap(); - stream.stream_close_send(now).unwrap(); + stream.send_data(&msg).unwrap(); + stream.stream_close_send().unwrap(); } } } diff --git a/third_party/rust/neqo-bin/src/udp.rs b/third_party/rust/neqo-bin/src/udp.rs @@ -110,11 +110,4 @@ impl Socket { pub fn max_gso_segments(&self) -> usize { self.state.max_gso_segments() } - - /// Whether transmitted datagrams might get fragmented by the IP layer - /// - /// Returns `false` on targets which employ e.g. the `IPV6_DONTFRAG` socket option. - pub fn may_fragment(&self) -> bool { - self.state.may_fragment() - } } diff --git a/third_party/rust/neqo-common/.cargo-checksum.json b/third_party/rust/neqo-common/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"5a8714e512c102e8bb9c212c67303bb5ab367e515b736328ce1162a281b1c4a6","benches/decoder.rs":"9a5e780ff68f180d7597e9d56b6d0ae609594a4558e4010babb2f33660ddddbe","build.rs":"d9accad1f92a1d82aff73a588269342db882918173e8d9b2b914c514e42e2839","src/bytes.rs":"b9ce44977af8d0731b51798fa9bd752fa4be437603a08446eb55889c2348281c","src/codec.rs":"1d5a036147a0bd4789eb4caa545f82ee0d18eca25ad1b6bdfd2fad58d99ae29e","src/datagram.rs":"b36bcfa4134aee3841e0210dc01aae410e1e6b4cf37163bb81a6276b7af007fd","src/event.rs":"289cf8e265c33e7cded58820ac81e5b575e3f84dd52fa18b0761f4094fb361c0","src/fuzz.rs":"9e0f2dca1832ef49b93b214e8d5f1ca2f5f8cb84a856fead344f62a722c370db","src/header.rs":"7f5d82577a5e1020ff237143e3aaa7e671403466a5a87f633b4c75f9d4e90aa9","src/hrtime.rs":"fd1fbf9ddd38c77e92abe25d7ab9e62872c1cd62ffae8743835bf94f76b6ddc8","src/incrdecoder.rs":"62f61d2600dafb1eec7d6cc85b3c7b07aba0ccd1149892b1dfa1a441f30927a3","src/lib.rs":"2bb6289a73dc07edfd2bc5bccda9542d403066656f41042116ed31f4fc4725ca","src/log.rs":"61a9b24bf6bf1493da67082bcf7fef8fe55f0a23d7f2a9ad13748982c54c85e2","src/qlog.rs":"2c072bb9ad31aad99c1f41421f162fbc48fbd4a17f4e554187b41267afef144b","src/tos.rs":"e09a69a20d54178a4c74b63596c607dbe8ace4ae0758a65f9878ea63d40e3c80","tests/log.rs":"c73187e390ee1a7c4a72266cb7ce5c326e862803dbcf86c2b9a892462fa22356"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"cf4124475660525c7f2ec99bf399139a8b1de9dc79a6e4706958b6f41065a493","benches/decoder.rs":"9a5e780ff68f180d7597e9d56b6d0ae609594a4558e4010babb2f33660ddddbe","build.rs":"d9accad1f92a1d82aff73a588269342db882918173e8d9b2b914c514e42e2839","src/codec.rs":"87785e00d04f4cac7bc68e6f2273e06589ddfb60eb0d2fb8bc3b4d75359cc3e2","src/datagram.rs":"9447a03e63736f7369bac9e6be5ae2ffbc5bfbb8b4ce7259ddfdf68151cda5b1","src/event.rs":"289cf8e265c33e7cded58820ac81e5b575e3f84dd52fa18b0761f4094fb361c0","src/fuzz.rs":"9e0f2dca1832ef49b93b214e8d5f1ca2f5f8cb84a856fead344f62a722c370db","src/header.rs":"8390a46666a52b101fc7c3c6995e73ce0f1c85d71e2eb1d133284f5ab5a9a7e0","src/hrtime.rs":"dbf3b5c2842b7e2f50a49cf19e5e8cb3e64cea62df201ea76b8430c572960677","src/incrdecoder.rs":"029081f0ae19db49c3278c865f22584fc24315169e5ffc1bd5a0087e8c0d38b9","src/lib.rs":"19fc6148663d72895689f25fc3634af2d18f9eed298c56dee4e865956d2954d2","src/log.rs":"61a9b24bf6bf1493da67082bcf7fef8fe55f0a23d7f2a9ad13748982c54c85e2","src/qlog.rs":"6fbc1092d296558ef8f3e2cc500fd07befe9a0aa7b9fc944d035d9dd6a028e98","src/tos.rs":"32e54ec4e14a5fd2dcbfde0709c4bdd9aedfceb2f5d48c84797c20a191c6d3a7","tests/log.rs":"c73187e390ee1a7c4a72266cb7ce5c326e862803dbcf86c2b9a892462fa22356"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-common/Cargo.toml b/third_party/rust/neqo-common/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-common" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = "build.rs" autolib = false @@ -43,7 +43,6 @@ repository = "https://github.com/mozilla/neqo/" bench = [ "neqo-crypto/bench", "test-fixture/bench", - "log/release_max_level_info", ] build-fuzzing-corpus = ["hex/alloc"] ci = [] @@ -138,7 +137,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -146,8 +144,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -200,8 +196,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-common/src/bytes.rs b/third_party/rust/neqo-common/src/bytes.rs @@ -1,138 +0,0 @@ -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/// Owned contiguous byte array with an optional offset. -/// -/// Inspired by `bytes` crate's `Bytes`. -#[derive(Debug, Clone)] -pub struct Bytes { - data: Vec<u8>, - offset: usize, -} - -impl Bytes { - /// Create a new `Bytes` with the given data and offset. - /// - /// # Panics - /// - /// Panics if `offset > data.len()`. - #[must_use] - pub fn new(data: Vec<u8>, offset: usize) -> Self { - assert!( - offset <= data.len(), - "offset {offset} is out of bounds for data of length {}", - data.len() - ); - Self { data, offset } - } - - #[must_use] - pub fn len(&self) -> usize { - self.data.len() - self.offset - } - - #[must_use] - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - - /// Skips the first `n` bytes, consuming and returning `self`. - /// - /// # Panics - /// - /// Panics if `n > self.len()`. - #[must_use] - pub fn skip(mut self, n: usize) -> Self { - assert!( - n <= self.len(), - "cannot skip {n} bytes when only {} bytes remain", - self.len() - ); - self.offset += n; - self - } -} - -impl AsRef<[u8]> for Bytes { - fn as_ref(&self) -> &[u8] { - &self.data[self.offset..] - } -} - -impl AsMut<[u8]> for Bytes { - fn as_mut(&mut self) -> &mut [u8] { - &mut self.data[self.offset..] - } -} - -impl PartialEq for Bytes { - fn eq(&self, other: &Self) -> bool { - self.as_ref() == other.as_ref() - } -} - -impl Eq for Bytes {} - -impl From<Vec<u8>> for Bytes { - fn from(data: Vec<u8>) -> Self { - Self::new(data, 0) - } -} - -impl<const N: usize> PartialEq<[u8; N]> for Bytes { - fn eq(&self, other: &[u8; N]) -> bool { - self.as_ref() == other.as_slice() - } -} - -impl PartialEq<[u8]> for Bytes { - fn eq(&self, other: &[u8]) -> bool { - self.as_ref() == other - } -} - -#[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] -mod tests { - use crate::Bytes; - - #[test] - #[should_panic(expected = "offset 4 is out of bounds for data of length 3")] - fn illegal_offset() { - _ = Bytes::new(vec![1, 2, 3], 4); - } - - #[test] - fn len() { - let b = Bytes::new(vec![1, 2, 3, 4], 1); - assert_eq!(b.len(), 3); - } - - #[test] - fn is_empty() { - let b = Bytes::new(vec![1, 2, 3, 4], 4); - assert!(b.is_empty()); - } - - #[test] - fn skip() { - let b = Bytes::new(vec![1, 2, 3, 4], 1).skip(2); - assert_eq!(b.as_ref(), &[4]); - } - - #[test] - #[should_panic(expected = "cannot skip 4 bytes when only 3 bytes remain")] - fn illegal_skip() { - _ = Bytes::new(vec![1, 2, 3, 4], 1).skip(4); - } - - #[test] - fn is_equal() { - let a = Bytes::new(vec![1, 2, 3, 4], 1); - let b = Bytes::from(vec![2, 3, 4]); - assert_eq!(a, b); - } -} diff --git a/third_party/rust/neqo-common/src/codec.rs b/third_party/rust/neqo-common/src/codec.rs @@ -104,6 +104,7 @@ impl<'a> Decoder<'a> { Some(res) } + #[inline] pub(crate) fn decode_n(&mut self, n: usize) -> Option<u64> { debug_assert!(n > 0 && n <= 8); if self.remaining() < n { @@ -274,10 +275,10 @@ impl<B: Buffer> Encoder<B> { pub fn encode_uint<T: Into<u64>>(&mut self, n: usize, v: T) -> &mut Self { let v = v.into(); assert!(n > 0 && n <= 8); - // Using to_be_bytes() generates better assembly, especially for odd sizes - // where it uses rev + strh instead of multiple strb instructions - let bytes = v.to_be_bytes(); - self.encode(&bytes[8 - n..]) + for i in 0..n { + self.encode_byte(((v >> (8 * (n - i - 1))) & 0xff) as u8); + } + self } /// Encode a QUIC varint. @@ -287,16 +288,14 @@ impl<B: Buffer> Encoder<B> { /// When `v >= 1<<62`. pub fn encode_varint<T: Into<u64>>(&mut self, v: T) -> &mut Self { let v = v.into(); - // Using to_be_bytes() generates better assembly with rev instructions - // instead of multiple shifts and ors - #[expect(clippy::cast_possible_truncation, reason = "This is intentional.")] match () { - () if v < (1 << 6) => self.encode_byte(v as u8), - () if v < (1 << 14) => self.encode(&((v as u16 | (1 << 14)).to_be_bytes())), - () if v < (1 << 30) => self.encode(&((v as u32 | (2 << 30)).to_be_bytes())), - () if v < (1 << 62) => self.encode(&(v | (3 << 62)).to_be_bytes()), + () if v < (1 << 6) => self.encode_uint(1, v), + () if v < (1 << 14) => self.encode_uint(2, v | (1 << 14)), + () if v < (1 << 30) => self.encode_uint(4, v | (2 << 30)), + () if v < (1 << 62) => self.encode_uint(8, v | (3 << 62)), () => panic!("Varint value too large"), - } + }; + self } /// Encode a vector in TLS style. @@ -676,7 +675,6 @@ impl Buffer for Cursor<&mut [u8]> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::io::Cursor; diff --git a/third_party/rust/neqo-common/src/datagram.rs b/third_party/rust/neqo-common/src/datagram.rs @@ -10,7 +10,7 @@ use std::{ ops::{Deref, DerefMut}, }; -use crate::{hex_with_len, Bytes, Tos}; +use crate::{hex_with_len, Tos}; #[derive(Clone, PartialEq, Eq)] pub struct Datagram<D = Vec<u8>> { @@ -130,13 +130,6 @@ impl<'a> Datagram<&'a mut [u8]> { } } -impl Datagram<Bytes> { - #[must_use] - pub const fn from_bytes(src: SocketAddr, dst: SocketAddr, tos: Tos, d: Bytes) -> Self { - Self { src, dst, tos, d } - } -} - impl<D: AsRef<[u8]>> AsRef<[u8]> for Datagram<D> { fn as_ref(&self) -> &[u8] { self.d.as_ref() @@ -259,7 +252,6 @@ impl DatagramBatch { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::net::{IpAddr, Ipv6Addr, SocketAddr}; diff --git a/third_party/rust/neqo-common/src/header.rs b/third_party/rust/neqo-common/src/header.rs @@ -117,7 +117,6 @@ impl FromStr for Header { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::*; diff --git a/third_party/rust/neqo-common/src/hrtime.rs b/third_party/rust/neqo-common/src/hrtime.rs @@ -384,7 +384,6 @@ impl Drop for Time { // but only when not running sanitizers. #[cfg(all(target_os = "linux", not(neqo_sanitize)))] #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use std::{ thread::{sleep, spawn}, diff --git a/third_party/rust/neqo-common/src/incrdecoder.rs b/third_party/rust/neqo-common/src/incrdecoder.rs @@ -127,7 +127,6 @@ impl IncrementalDecoderIgnore { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{ Decoder, IncrementalDecoderBuffer, IncrementalDecoderIgnore, IncrementalDecoderUint, diff --git a/third_party/rust/neqo-common/src/lib.rs b/third_party/rust/neqo-common/src/lib.rs @@ -4,9 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - -pub mod bytes; mod codec; mod datagram; pub mod event; @@ -27,7 +24,6 @@ use strum::Display; #[cfg(feature = "build-fuzzing-corpus")] pub use self::fuzz::write_item_to_fuzzing_corpus; pub use self::{ - bytes::Bytes, codec::{Buffer, Decoder, Encoder, MAX_VARINT}, datagram::{Datagram, DatagramBatch}, header::Header, diff --git a/third_party/rust/neqo-common/src/qlog.rs b/third_party/rust/neqo-common/src/qlog.rs @@ -42,7 +42,6 @@ impl Qlog { title: Option<String>, description: Option<String>, file_prefix: D, - now: Instant, ) -> Result<Self, qlog::Error> { qlog_path.push(format!("{file_prefix}.sqlog")); @@ -59,7 +58,7 @@ impl Qlog { title, description, None, - now, + Instant::now(), new_trace(role), qlog::events::EventImportance::Base, Box::new(BufWriter::new(file)), @@ -115,6 +114,27 @@ impl Qlog { }); } + /// If logging enabled, closure may generate an event to be logged. + /// + /// This function is similar to [`Qlog::add_event_data_with_instant`], + /// but it does not take `now: Instant` as an input parameter. Instead, it + /// internally calls [`std::time::Instant::now`]. Prefer calling + /// [`Qlog::add_event_data_with_instant`] when `now` is available, as it + /// ensures consistency with the current time, which might differ from + /// [`std::time::Instant::now`] (e.g., when using simulated time instead of + /// real time). + pub fn add_event_data_now<F>(&self, f: F) + where + F: FnOnce() -> Option<qlog::events::EventData>, + { + self.add_event_with_stream(|s| { + if let Some(ev_data) = f() { + s.add_event_data_now(ev_data)?; + } + Ok(()) + }); + } + /// If logging enabled, closure is given the Qlog stream to write events and /// frames to. pub fn add_event_with_stream<F>(&self, f: F) @@ -174,7 +194,6 @@ pub fn new_trace(role: Role) -> TraceSeq { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use qlog::events::Event; use regex::Regex; diff --git a/third_party/rust/neqo-common/src/tos.rs b/third_party/rust/neqo-common/src/tos.rs @@ -236,7 +236,6 @@ impl Tos { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use crate::{Dscp, Ecn, Tos}; diff --git a/third_party/rust/neqo-crypto/.cargo-checksum.json b/third_party/rust/neqo-crypto/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"d3fd943b240ab7c2514f82362cc972619bbc5f03787ee5430ee02d7582a7f9d3","bindings/bindings.toml":"edffd81bae5081805f92fd527fd1fb474abf07a96c7b1536629ed0b2a328b638","bindings/nspr_err.h":"2d5205d017b536c2d838bcf9bc4ec79f96dd50e7bb9b73892328781f1ee6629d","bindings/nspr_error.h":"e41c03c77b8c22046f8618832c9569fbcc7b26d8b9bbc35eea7168f35e346889","bindings/nspr_io.h":"085b289849ef0e77f88512a27b4d9bdc28252bd4d39c6a17303204e46ef45f72","bindings/nspr_time.h":"2e637fd338a5cf0fd3fb0070a47f474a34c2a7f4447f31b6875f5a9928d0a261","bindings/nss_ciphers.h":"95ec6344a607558b3c5ba8510f463b6295f3a2fb3f538a01410531045a5f62d1","bindings/nss_init.h":"ef49045063782fb612aff459172cc6a89340f15005808608ade5320ca9974310","bindings/nss_p11.h":"0b81e64fe6db49b2ecff94edd850be111ef99ec11220e88ceb1c67be90143a78","bindings/nss_secerr.h":"713e8368bdae5159af7893cfa517dabfe5103cede051dee9c9557c850a2defc6","bindings/nss_ssl.h":"af222fb957b989e392e762fa2125c82608a0053aff4fb97e556691646c88c335","bindings/nss_sslerr.h":"24b97f092183d8486f774cdaef5030d0249221c78343570d83a4ee5b594210ae","bindings/nss_sslopt.h":"b7807eb7abdad14db6ad7bc51048a46b065a0ea65a4508c95a12ce90e59d1eea","build.rs":"7b121a109b0c2e32ecb04768d6d6d2f8a04a081aaafce765c4632253239ce44a","min_version.txt":"0f9ddf9ddaeb5137a5ab3d238d06286822f9579b1f46ba76312a8c6d76176500","src/aead.rs":"7f627f7dcb08444891b4898a8ab8c0bc4984c035212572547323046ec46e4bb1","src/aead_null.rs":"e8946edbff657763885dd52ccc5516726f316286b6e0c84671458d02a3c7e44a","src/agent.rs":"69e2d99c47c12bf24d4659e723fb85096d6286d134ced65054c40631e88c7c0c","src/agentio.rs":"eb13376f2aed4b0b822784d43d341709b3a33f6ba52560ff48ca3e339d1e86da","src/auth.rs":"bbba836237b0c5d079f1348a96bc46b5bb6fb3cd34ca568581c9f7f8800444d1","src/cert.rs":"afecc277b918e9123d6099fc2b7f5a4ef58c9c3c1b3ca9d4790bda0a46665fe3","src/constants.rs":"83606aeb646b2833a8094f9d980c266ecc3e8cb40c93a4820da221988319dd1a","src/ech.rs":"cf6670ce7ceaaa67c8b0f93b5063cf4a0b92a0b176bbbb664b0a58f1b922b710","src/err.rs":"40658d015ac45cdd29b3bc34540c93b80a20baf5d470e0c59754fc45ce6af204","src/exp.rs":"70549c53ce8df99d62d3343697abd2a177d67ff56703a3d26048bdcdc8b87a0d","src/ext.rs":"7082cd7b44ba97275a8aefe0c31c2419d750f9621486c9c017864c82a7580423","src/hkdf.rs":"76c5abc8b2d6ee12d8a86cd730af2cf47a59b2fbfd3b8a635a1826636156794d","src/hp.rs":"04a461676c02d308f1f851b975846f83daa50ee08de9e573b4136ce4d54b4473","src/lib.rs":"42bdd28c9cd22178e2a0ab1736a0ea49cb240c78cc924d26296086d469a1f2fe","src/min_version.rs":"c6e1f98b9f56db0622ac38c1be131c55acf4a0f09ed0d6283f4d6308e2d1301a","src/p11.rs":"dda7025c61987caffbb9acd38c3e4169a45692a96c3f23025612a4ef4a035157","src/prio.rs":"1858088afd2668e8fbff56959765b7d4df09342371b9282ade27bb4d7bd6ce69","src/replay.rs":"7bf84ce1964658e69d81a810f3b8d71d36d5a7fc336d83c04fb585a6a98e6d33","src/result.rs":"27067d9aba61e8162fb92bca03f9a462cf4fe2f0a259d52696b63e1f6a959a5c","src/secrets.rs":"b021c91b9c1b63373474c39e817a7d9083681be13b5466c4d2b776db9a65b9f8","src/selfencrypt.rs":"2cdca9ec879057ef76bbef168fea0750c34eeaea8dd370e8c192469b377168ad","src/ssl.rs":"49f4339e665959bd3a0fbd0e192611928fdeab986c4f539a4be2ab9cb6d60b8b","src/time.rs":"c4c9987bfe273f19a2f5ef09920ccfe384ab1c1eaf2b2281eb4b02aa8d3b9970","tests/aead.rs":"2e99fba2f155aa8442709c4847f171f0cdfc179b2a7cd2afd853b550d02f7792","tests/agent.rs":"81266b780a40f1d8d31edbe1f43a37fd641f2cb44f75365c67b068c0d3442bb3","tests/ext.rs":"40e3bb0e5ea00fe411cfaf1a006fd4b11a22503f66d3738423361a8b7f80fe13","tests/handshake.rs":"7c6dbdf1b2ae74d15f0a3242d9969abf04ea9839eddcf1aae73379142f33a433","tests/hkdf.rs":"1d2098dc8398395864baf13e4886cfd1da6d36118727c3b264f457ee3da6b048","tests/hp.rs":"dab2631fb5a4f47227e05f508eaca4b4aa225bafced60e703e6fd1c329ac6ab1","tests/init.rs":"3cfe8411ca31ad7dfb23822bb1570e1a5b2b334857173bdd7df086b65b81d95a","tests/selfencrypt.rs":"2e0b548fc84f388b0b2367fb8d9e3e0bd25c4814a1e997b13b7849a54a529703"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"d1d39c10caf3e04c20cc084f11c5b1e21f38b39688147e286015361157b679dd","bindings/bindings.toml":"edffd81bae5081805f92fd527fd1fb474abf07a96c7b1536629ed0b2a328b638","bindings/nspr_err.h":"2d5205d017b536c2d838bcf9bc4ec79f96dd50e7bb9b73892328781f1ee6629d","bindings/nspr_error.h":"e41c03c77b8c22046f8618832c9569fbcc7b26d8b9bbc35eea7168f35e346889","bindings/nspr_io.h":"085b289849ef0e77f88512a27b4d9bdc28252bd4d39c6a17303204e46ef45f72","bindings/nspr_time.h":"2e637fd338a5cf0fd3fb0070a47f474a34c2a7f4447f31b6875f5a9928d0a261","bindings/nss_ciphers.h":"95ec6344a607558b3c5ba8510f463b6295f3a2fb3f538a01410531045a5f62d1","bindings/nss_init.h":"ef49045063782fb612aff459172cc6a89340f15005808608ade5320ca9974310","bindings/nss_p11.h":"0b81e64fe6db49b2ecff94edd850be111ef99ec11220e88ceb1c67be90143a78","bindings/nss_secerr.h":"713e8368bdae5159af7893cfa517dabfe5103cede051dee9c9557c850a2defc6","bindings/nss_ssl.h":"af222fb957b989e392e762fa2125c82608a0053aff4fb97e556691646c88c335","bindings/nss_sslerr.h":"24b97f092183d8486f774cdaef5030d0249221c78343570d83a4ee5b594210ae","bindings/nss_sslopt.h":"b7807eb7abdad14db6ad7bc51048a46b065a0ea65a4508c95a12ce90e59d1eea","build.rs":"7b121a109b0c2e32ecb04768d6d6d2f8a04a081aaafce765c4632253239ce44a","min_version.txt":"0f9ddf9ddaeb5137a5ab3d238d06286822f9579b1f46ba76312a8c6d76176500","src/aead.rs":"910485e4098b64d55cac1931ee274798402311355e33eb4708bb617c378b46d8","src/aead_null.rs":"cf86c1066130745869403fe4cfc2688722f16538c21053a4e75a023e821e56be","src/agent.rs":"9f708448b0b34873665b59a8027664c263aca9cf7b438f9a71bf87b9aa8fdda6","src/agentio.rs":"eb13376f2aed4b0b822784d43d341709b3a33f6ba52560ff48ca3e339d1e86da","src/auth.rs":"bbba836237b0c5d079f1348a96bc46b5bb6fb3cd34ca568581c9f7f8800444d1","src/cert.rs":"afecc277b918e9123d6099fc2b7f5a4ef58c9c3c1b3ca9d4790bda0a46665fe3","src/constants.rs":"83606aeb646b2833a8094f9d980c266ecc3e8cb40c93a4820da221988319dd1a","src/ech.rs":"cf6670ce7ceaaa67c8b0f93b5063cf4a0b92a0b176bbbb664b0a58f1b922b710","src/err.rs":"1f616415e76870ee00ed56a81d745f44295cad8657ccc7107b5cd522593947b7","src/exp.rs":"70549c53ce8df99d62d3343697abd2a177d67ff56703a3d26048bdcdc8b87a0d","src/ext.rs":"7082cd7b44ba97275a8aefe0c31c2419d750f9621486c9c017864c82a7580423","src/hkdf.rs":"76c5abc8b2d6ee12d8a86cd730af2cf47a59b2fbfd3b8a635a1826636156794d","src/hp.rs":"28b65cb76b67bb4799c2dd60ca544cd319c6c0ff7969fffed2f01b54d99e7e3e","src/lib.rs":"1c5ad4b2a534040b29a3e89480fef50c158bf58860dc2a6f73c6807521d8f641","src/min_version.rs":"c6e1f98b9f56db0622ac38c1be131c55acf4a0f09ed0d6283f4d6308e2d1301a","src/p11.rs":"129ddff5415978cf4ef1a4a2e6d4a1f1b4b6b4f728dc09312d3d2c41ff1a7378","src/prio.rs":"1858088afd2668e8fbff56959765b7d4df09342371b9282ade27bb4d7bd6ce69","src/replay.rs":"7bf84ce1964658e69d81a810f3b8d71d36d5a7fc336d83c04fb585a6a98e6d33","src/result.rs":"5a76688787741de7a935dbbab4bcb917d481d1c9c50a34df7e510036feb3da17","src/secrets.rs":"b021c91b9c1b63373474c39e817a7d9083681be13b5466c4d2b776db9a65b9f8","src/selfencrypt.rs":"2e8805a162b944667a0ea89207533ce236a16a7a3186f97ea879c065ef6b8e6a","src/ssl.rs":"15bd862df52b119b3df5eb59e50b4f95217c15fed2729121d41bca63560fd90f","src/time.rs":"ca6cdd05473f6c499f2864e3436796243164a499f1c9e98e693d910f59282b86","tests/aead.rs":"e36ae77802df1ea6d17cfd1bd2178a3706089577d6fd1554ca86e748b8b235b9","tests/agent.rs":"81266b780a40f1d8d31edbe1f43a37fd641f2cb44f75365c67b068c0d3442bb3","tests/ext.rs":"40e3bb0e5ea00fe411cfaf1a006fd4b11a22503f66d3738423361a8b7f80fe13","tests/handshake.rs":"7c6dbdf1b2ae74d15f0a3242d9969abf04ea9839eddcf1aae73379142f33a433","tests/hkdf.rs":"1d2098dc8398395864baf13e4886cfd1da6d36118727c3b264f457ee3da6b048","tests/hp.rs":"bcb9e85182da9872dc4db6f7f8701e939f8aa98098577e934af8aa07dd7a89fc","tests/init.rs":"3cfe8411ca31ad7dfb23822bb1570e1a5b2b334857173bdd7df086b65b81d95a","tests/selfencrypt.rs":"2e0b548fc84f388b0b2367fb8d9e3e0bd25c4814a1e997b13b7849a54a529703"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-crypto/Cargo.toml b/third_party/rust/neqo-crypto/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-crypto" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = "build.rs" autolib = false @@ -49,7 +49,7 @@ ignored = [ ] [features] -bench = ["log/release_max_level_info"] +bench = [] disable-encryption = [] disable-random = [] gecko = ["mozbuild"] @@ -164,7 +164,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -172,8 +171,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -226,8 +223,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-crypto/src/aead.rs b/third_party/rust/neqo-crypto/src/aead.rs @@ -13,73 +13,13 @@ use std::{ use crate::{ constants::{Cipher, Version}, - err::{sec::SEC_ERROR_BAD_DATA, Error, Res}, + err::Res, experimental_api, p11::{PK11SymKey, SymKey}, scoped_ptr, ssl::{PRUint16, PRUint64, PRUint8, SSLAeadContext}, }; -/// Trait for AEAD (Authenticated Encryption with Associated Data) operations. -/// -/// This trait provides a common interface for both real and null AEAD implementations, -/// eliminating code duplication and allowing for consistent usage patterns. -pub trait Aead { - /// Create a new AEAD instance. - /// - /// # Errors - /// - /// Returns `Error` when the underlying crypto operations fail. - fn new(version: Version, cipher: Cipher, secret: &SymKey, prefix: &str) -> Res<Self> - where - Self: Sized; - - /// Get the expansion size (authentication tag length) for this AEAD. - fn expansion(&self) -> usize; - - /// Encrypt plaintext with associated data. - /// - /// # Errors - /// - /// Returns `Error` when encryption fails. - fn encrypt<'a>( - &self, - count: u64, - aad: &[u8], - input: &[u8], - output: &'a mut [u8], - ) -> Res<&'a [u8]>; - - /// Encrypt plaintext in place with associated data. - /// - /// # Errors - /// - /// Returns `Error` when encryption fails. - fn encrypt_in_place<'a>(&self, count: u64, aad: &[u8], data: &'a mut [u8]) - -> Res<&'a mut [u8]>; - - /// Decrypt ciphertext with associated data. - /// - /// # Errors - /// - /// Returns `Error` when decryption or authentication fails. - fn decrypt<'a>( - &self, - count: u64, - aad: &[u8], - input: &[u8], - output: &'a mut [u8], - ) -> Res<&'a [u8]>; - - /// Decrypt ciphertext in place with associated data. - /// - /// # Errors - /// - /// Returns `Error` when decryption or authentication fails. - fn decrypt_in_place<'a>(&self, count: u64, aad: &[u8], data: &'a mut [u8]) - -> Res<&'a mut [u8]>; -} - experimental_api!(SSL_MakeAead( version: PRUint16, cipher: PRUint16, @@ -118,6 +58,21 @@ pub struct RealAead { } impl RealAead { + /// Create a new AEAD based on the indicated TLS version and cipher suite. + /// + /// # Errors + /// + /// Returns `Error` when the supporting NSS functions fail. + pub fn new(version: Version, cipher: Cipher, secret: &SymKey, prefix: &str) -> Res<Self> { + let s: *mut PK11SymKey = **secret; + unsafe { Self::from_raw(version, cipher, s, prefix) } + } + + #[must_use] + pub const fn expansion() -> usize { + 16 + } + unsafe fn from_raw( version: Version, cipher: Cipher, @@ -138,19 +93,16 @@ impl RealAead { ctx: AeadContext::from_ptr(ctx)?, }) } -} - -impl Aead for RealAead { - fn new(version: Version, cipher: Cipher, secret: &SymKey, prefix: &str) -> Res<Self> { - let s: *mut PK11SymKey = **secret; - unsafe { Self::from_raw(version, cipher, s, prefix) } - } - fn expansion(&self) -> usize { - 16 - } - - fn encrypt<'a>( + /// Encrypt a plaintext. + /// + /// The space provided in `output` needs to be larger than `input` by + /// the value provided in `Aead::expansion`. + /// + /// # Errors + /// + /// If the input can't be protected or any input is too large for NSS. + pub fn encrypt<'a>( &self, count: u64, aad: &[u8], @@ -174,16 +126,24 @@ impl Aead for RealAead { Ok(&output[..l.try_into()?]) } - fn encrypt_in_place<'a>( + /// Encrypt `data` consisting of `aad` and plaintext `data` in place. + /// + /// The last `Aead::expansion` of `data` is overwritten by the AEAD tag by this function. + /// Therefore, a buffer should be provided that is that much larger than the plaintext. + /// + /// # Panics + /// + /// If `data` is shorter than `<self as Aead>::expansion()`. + /// + /// # Errors + /// + /// If the input can't be protected or any input is too large for NSS. + pub fn encrypt_in_place<'a>( &self, count: u64, aad: &[u8], data: &'a mut [u8], ) -> Res<&'a mut [u8]> { - if data.len() < self.expansion() { - return Err(Error::from(SEC_ERROR_BAD_DATA)); - } - let mut l: c_uint = 0; unsafe { SSL_AeadEncrypt( @@ -192,17 +152,21 @@ impl Aead for RealAead { aad.as_ptr(), c_uint::try_from(aad.len())?, data.as_ptr(), - c_uint::try_from(data.len() - self.expansion())?, - data.as_mut_ptr(), + c_uint::try_from(data.len() - Self::expansion())?, + data.as_ptr(), &mut l, c_uint::try_from(data.len())?, ) }?; - debug_assert_eq!(usize::try_from(l)?, data.len()); - Ok(data) + Ok(&mut data[..l.try_into()?]) } - fn decrypt<'a>( + /// Decrypt a ciphertext. + /// + /// # Errors + /// + /// If the input isn't authenticated or any input is too large for NSS. + pub fn decrypt<'a>( &self, count: u64, aad: &[u8], @@ -229,7 +193,14 @@ impl Aead for RealAead { Ok(&output[..l.try_into()?]) } - fn decrypt_in_place<'a>( + /// Decrypt a ciphertext in place. + /// Returns a subslice of `data` (without the last `<self as Aead>::expansion()` bytes), + /// that has been decrypted in place. + /// + /// # Errors + /// + /// If the input isn't authenticated or any input is too large for NSS. + pub fn decrypt_in_place<'a>( &self, count: u64, aad: &[u8], @@ -247,12 +218,12 @@ impl Aead for RealAead { c_uint::try_from(aad.len())?, data.as_ptr(), c_uint::try_from(data.len())?, - data.as_mut_ptr(), + data.as_ptr(), &mut l, c_uint::try_from(data.len())?, ) }?; - debug_assert_eq!(usize::try_from(l)?, data.len() - self.expansion()); + debug_assert_eq!(usize::try_from(l)?, data.len() - Self::expansion()); Ok(&mut data[..l.try_into()?]) } } diff --git a/third_party/rust/neqo-crypto/src/aead_null.rs b/third_party/rust/neqo-crypto/src/aead_null.rs @@ -4,10 +4,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![expect(clippy::missing_errors_doc, reason = "OK here.")] + use std::fmt; use crate::{ - aead::Aead, constants::{Cipher, Version}, err::{sec::SEC_ERROR_BAD_DATA, Error, Res}, p11::SymKey, @@ -18,39 +19,30 @@ pub const AEAD_NULL_TAG: &[u8] = &[0x0a; 16]; pub struct AeadNull {} impl AeadNull { - fn decrypt_check(&self, _count: u64, _aad: &[u8], input: &[u8]) -> Res<usize> { - if input.len() < self.expansion() { - return Err(Error::from(SEC_ERROR_BAD_DATA)); - } - - let len_encrypted = input - .len() - .checked_sub(self.expansion()) - .ok_or_else(|| Error::from(SEC_ERROR_BAD_DATA))?; - // Check that: - // 1) expansion is all zeros and - // 2) if the encrypted data is also supplied that at least some values are no zero - // (otherwise padding will be interpreted as a valid packet) - if &input[len_encrypted..] == AEAD_NULL_TAG - && (len_encrypted == 0 || input[..len_encrypted].iter().any(|x| *x != 0x0)) - { - Ok(len_encrypted) - } else { - Err(Error::from(SEC_ERROR_BAD_DATA)) - } - } -} - -impl Aead for AeadNull { - fn new(_version: Version, _cipher: Cipher, _secret: &SymKey, _prefix: &str) -> Res<Self> { + #[expect( + clippy::unnecessary_wraps, + reason = "Need to replicate the API of aead::RealAead." + )] + pub const fn new( + _version: Version, + _cipher: Cipher, + _secret: &SymKey, + _prefix: &str, + ) -> Res<Self> { Ok(Self {}) } - fn expansion(&self) -> usize { + #[must_use] + pub const fn expansion() -> usize { AEAD_NULL_TAG.len() } - fn encrypt<'a>( + #[expect( + clippy::unnecessary_wraps, + clippy::unused_self, + reason = "Need to replicate the API of aead::RealAead." + )] + pub fn encrypt<'a>( &self, _count: u64, _aad: &[u8], @@ -59,22 +51,53 @@ impl Aead for AeadNull { ) -> Res<&'a [u8]> { let l = input.len(); output[..l].copy_from_slice(input); - output[l..l + self.expansion()].copy_from_slice(AEAD_NULL_TAG); - Ok(&output[..l + self.expansion()]) + output[l..l + Self::expansion()].copy_from_slice(AEAD_NULL_TAG); + Ok(&output[..l + Self::expansion()]) } - fn encrypt_in_place<'a>( + #[expect( + clippy::unnecessary_wraps, + clippy::unused_self, + reason = "Need to replicate the API of aead::RealAead." + )] + pub fn encrypt_in_place<'a>( &self, _count: u64, _aad: &[u8], data: &'a mut [u8], ) -> Res<&'a mut [u8]> { - let pos = data.len() - self.expansion(); + let pos = data.len() - Self::expansion(); data[pos..].copy_from_slice(AEAD_NULL_TAG); Ok(data) } - fn decrypt<'a>( + #[expect( + clippy::unused_self, + reason = "Need to replicate the API of aead::RealAead." + )] + fn decrypt_check(&self, _count: u64, _aad: &[u8], input: &[u8]) -> Res<usize> { + if input.len() < Self::expansion() { + return Err(Error::from(SEC_ERROR_BAD_DATA)); + } + + let len_encrypted = input + .len() + .checked_sub(Self::expansion()) + .ok_or_else(|| Error::from(SEC_ERROR_BAD_DATA))?; + // Check that: + // 1) expansion is all zeros and + // 2) if the encrypted data is also supplied that at least some values are no zero + // (otherwise padding will be interpreted as a valid packet) + if &input[len_encrypted..] == AEAD_NULL_TAG + && (len_encrypted == 0 || input[..len_encrypted].iter().any(|x| *x != 0x0)) + { + Ok(len_encrypted) + } else { + Err(Error::from(SEC_ERROR_BAD_DATA)) + } + } + + pub fn decrypt<'a>( &self, count: u64, aad: &[u8], @@ -87,7 +110,7 @@ impl Aead for AeadNull { }) } - fn decrypt_in_place<'a>( + pub fn decrypt_in_place<'a>( &self, count: u64, aad: &[u8], diff --git a/third_party/rust/neqo-crypto/src/agent.rs b/third_party/rust/neqo-crypto/src/agent.rs @@ -1452,7 +1452,6 @@ impl From<Server> for Agent { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use crate::ResumptionToken; diff --git a/third_party/rust/neqo-crypto/src/err.rs b/third_party/rust/neqo-crypto/src/err.rs @@ -163,7 +163,6 @@ pub const fn is_blocked(result: &Res<()>) -> bool { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use test_fixture::fixture_init; diff --git a/third_party/rust/neqo-crypto/src/hp.rs b/third_party/rust/neqo-crypto/src/hp.rs @@ -134,12 +134,14 @@ impl Key { /// /// # Errors /// - /// An error is returned if the NSS functions fail. + /// An error is returned if the NSS functions fail; a sample of the + /// wrong size is the obvious cause. /// /// # Panics /// /// When the mechanism for our key is not supported. - pub fn mask(&self, sample: &[u8; Self::SAMPLE_SIZE]) -> Res<[u8; Self::SAMPLE_SIZE]> { + /// Or when the sample provided is not at least `self.sample_size()` bytes. + pub fn mask(&self, sample: &[u8]) -> Res<[u8; Self::SAMPLE_SIZE]> { let mut output = [0; Self::SAMPLE_SIZE]; match self { @@ -151,7 +153,7 @@ impl Key { output.as_mut_ptr(), &mut output_len, c_int::try_from(output.len())?, - sample.as_ptr().cast(), + sample[..Self::SAMPLE_SIZE].as_ptr().cast(), c_int::try_from(Self::SAMPLE_SIZE)?, ) })?; @@ -163,7 +165,7 @@ impl Key { let params: CK_CHACHA20_PARAMS = CK_CHACHA20_PARAMS { pBlockCounter: sample.as_ptr().cast_mut(), blockCounterBits: 32, - pNonce: sample[4..].as_ptr().cast_mut(), + pNonce: sample[4..Self::SAMPLE_SIZE].as_ptr().cast_mut(), ulNonceBits: 96, }; let mut output_len: c_uint = 0; diff --git a/third_party/rust/neqo-crypto/src/lib.rs b/third_party/rust/neqo-crypto/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - mod aead; #[cfg(feature = "disable-encryption")] pub mod aead_null; @@ -39,7 +37,6 @@ pub use self::aead::RealAead; #[cfg(feature = "disable-encryption")] pub use self::aead_null::AeadNull as Aead; pub use self::{ - aead::Aead as AeadTrait, agent::{ Agent, AllowZeroRtt, Client, HandshakeState, Record, RecordList, ResumptionToken, SecretAgent, SecretAgentInfo, SecretAgentPreInfo, Server, ZeroRttCheckResult, diff --git a/third_party/rust/neqo-crypto/src/p11.rs b/third_party/rust/neqo-crypto/src/p11.rs @@ -396,7 +396,6 @@ pub fn random<const N: usize>() -> [u8; N] { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use test_fixture::fixture_init; diff --git a/third_party/rust/neqo-crypto/src/result.rs b/third_party/rust/neqo-crypto/src/result.rs @@ -52,7 +52,6 @@ fn result_helper(rv: ssl::SECStatus, allow_blocked: bool) -> Res<bool> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{result, result_or_blocked}; use crate::{ diff --git a/third_party/rust/neqo-crypto/src/selfencrypt.rs b/third_party/rust/neqo-crypto/src/selfencrypt.rs @@ -9,7 +9,6 @@ use std::mem; use neqo_common::{hex, qinfo, qtrace, Encoder}; use crate::{ - aead::Aead as _, constants::{Cipher, Version}, err::{Error, Res}, hkdf, @@ -85,7 +84,7 @@ impl SelfEncrypt { // AAD covers the entire header, plus the value of the AAD parameter that is provided. let salt = random::<{ Self::SALT_LENGTH }>(); let cipher = self.make_aead(&self.key, &salt)?; - let encoded_len = 2 + salt.len() + plaintext.len() + cipher.expansion(); + let encoded_len = 2 + salt.len() + plaintext.len() + Aead::expansion(); let mut enc = Encoder::with_capacity(encoded_len); enc.encode_byte(Self::VERSION); @@ -129,10 +128,10 @@ impl SelfEncrypt { /// when the keys have been rotated; or when NSS fails. #[expect(clippy::similar_names, reason = "aad is similar to aead.")] pub fn open(&self, aad: &[u8], ciphertext: &[u8]) -> Res<Vec<u8>> { - if *ciphertext.first().ok_or(Error::SelfEncrypt)? != Self::VERSION { + if ciphertext[0] != Self::VERSION { return Err(Error::SelfEncrypt); } - let Some(key) = self.select_key(*ciphertext.get(1).ok_or(Error::SelfEncrypt)?) else { + let Some(key) = self.select_key(ciphertext[1]) else { return Err(Error::SelfEncrypt); }; let offset = 2 + Self::SALT_LENGTH; diff --git a/third_party/rust/neqo-crypto/src/ssl.rs b/third_party/rust/neqo-crypto/src/ssl.rs @@ -124,7 +124,6 @@ experimental_api!(SSL_SetCertificateCompressionAlgorithm( )); #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{SSL_GetNumImplementedCiphers, SSL_NumImplementedCiphers}; diff --git a/third_party/rust/neqo-crypto/src/time.rs b/third_party/rust/neqo-crypto/src/time.rs @@ -204,7 +204,6 @@ impl Default for TimeHolder { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use std::time::{Duration, Instant}; diff --git a/third_party/rust/neqo-crypto/tests/aead.rs b/third_party/rust/neqo-crypto/tests/aead.rs @@ -9,7 +9,7 @@ use neqo_crypto::{ constants::{Cipher, TLS_AES_128_GCM_SHA256, TLS_VERSION_1_3}, - hkdf, Aead, AeadTrait as _, + hkdf, Aead, }; use test_fixture::fixture_init; @@ -120,14 +120,3 @@ fn aead_encrypt_decrypt() { let res = aead.decrypt(1, &scratch[..], ciphertext, plaintext_buf); assert!(res.is_err()); } - -#[test] -fn aead_encrypt_in_place_too_small_buffer() { - let aead = make_aead(TLS_AES_128_GCM_SHA256); - - // Create a buffer that's smaller than the expansion size - let mut small_buffer = vec![0u8; aead.expansion() - 1]; - - let result = aead.encrypt_in_place(1, AAD, &mut small_buffer); - assert!(result.is_err()); -} diff --git a/third_party/rust/neqo-crypto/tests/hp.rs b/third_party/rust/neqo-crypto/tests/hp.rs @@ -67,3 +67,17 @@ fn chacha20_ctr() { hp_test(TLS_CHACHA20_POLY1305_SHA256, EXPECTED); } + +#[test] +#[should_panic(expected = "out of range")] +fn aes_short() { + let hp = make_hp(TLS_AES_128_GCM_SHA256); + drop(hp.mask(&[0; 15])); +} + +#[test] +#[should_panic(expected = "out of range")] +fn chacha20_short() { + let hp = make_hp(TLS_CHACHA20_POLY1305_SHA256); + drop(hp.mask(&[0; 15])); +} diff --git a/third_party/rust/neqo-http3/.cargo-checksum.json b/third_party/rust/neqo-http3/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"4abb2ce74071147cd1486ffc673d1c99a8928eef3c6ff65b38154c16f2d08cce","benches/streams.rs":"99109260f4fbca61b4ac624a4162ba305f476f4fa8de7c3c4a54edf0935f3125","src/buffered_send_stream.rs":"3eb0520b3a207597d6e7e232df8a7fc2c7bce65997af5bf92dbac2f6350d06ca","src/client_events.rs":"6e4b5a3e3a7038ca8a1cae33bf6e050f402c1e415cd53670058d6d99ae9e1b26","src/conn_params.rs":"3994bc99dc2ef77c01cc37e59b7ca91c463b228603958612497313251021a9fa","src/connection.rs":"3a61818868f518e66044b8840c6d7a0bb71236e757f36f8a6e5b1bc3af85e52d","src/connection_client.rs":"8a3be6b03f0496ddf4d6c9d9b7532ca0f141acb09decf583ad06937dbfa3d52b","src/connection_server.rs":"7c49dd96095770258e281a680e1c34af3e1eb46510d0a0b15013de626076bd8b","src/control_stream_local.rs":"df0f7b272897f30dd2fcec9d13895cb8e8b1b453a96e8983fef05a8c878e7bc1","src/control_stream_remote.rs":"652e2bfcc3e020f7a9f4e3a107557e291757a7fc2e30cf9fe95c966d2be8c122","src/features/extended_connect/connect_udp_session.rs":"4a72424b06972f0ef265f33ad93cb008af16746a700c56bca4d95099a8dab26c","src/features/extended_connect/mod.rs":"edb2e04806052a899adb316b06596f1d23a40c8fa847dd2d931bc40332b505b2","src/features/extended_connect/session.rs":"36f3af4b38a18198aacdf81e4dd3d99c98abdfe900211ac3a991083d097be70b","src/features/extended_connect/tests/mod.rs":"fd6aee37243713e80fc526552f21f0222338cec9890409b6575a2a637b17ec1f","src/features/extended_connect/tests/webtransport/datagrams.rs":"16a69b41aaada5339b85153b7194d2c1e9151ce9f25b29e02b0f24bb9500b331","src/features/extended_connect/tests/webtransport/mod.rs":"235101fed8d5c3fddd3e797f724c3013752e02462733f12298d7c9a82f666e3b","src/features/extended_connect/tests/webtransport/negotiation.rs":"b0083f8737bdea9bc0de1940c627d497fee8b79ebc218bbcea0a562ae530527f","src/features/extended_connect/tests/webtransport/sessions.rs":"7bd9fdf099cbe794ed438dc3c85f254c975e319ed2d984214c6a0c29829136d5","src/features/extended_connect/tests/webtransport/streams.rs":"e84374071268ecec302bc1c3e825bc2b7219dc11a7b88043061565f256c48542","src/features/extended_connect/webtransport_session.rs":"de19ee1daa77e83ad7ac3b858602967dcad01acca55cf6de59cc650664fa2423","src/features/extended_connect/webtransport_streams.rs":"4704ab559df3c0dad0602cd887d4cb13a17d812bf2005202ed57bfd4a8f96f8b","src/features/mod.rs":"7424e5f1939324953ed6acce76c5774f2bdfae3d1dfbdd938a4eded8a94d5c9e","src/frames/connect_udp_frame.rs":"112a8b1f848b7f0b1fc0d54aaf3e35560cd54e1ffdc1f1bc01028d798fbd45df","src/frames/hframe.rs":"8fb1e83571df12860e05b47d3e59e4c7815da56186ce6c52fb7a11c58012c513","src/frames/mod.rs":"109b49747bcb9676e8186adc770388abc3c32181430479197172ff8ca6f572b7","src/frames/reader.rs":"468a2f3199b22feda9f8ae937d17c99c89123beb0f7e48b9bb1950e8a61e34b6","src/frames/tests/hframe.rs":"43a7735fc859692633e7f3c031710a9fb635611756cb4b9f387bac0a38c0fa09","src/frames/tests/mod.rs":"3ee262c649cd0ea0120da78943dfcab5b9a08064f433076d70ac399ccf489325","src/frames/tests/reader.rs":"060e2a746fc8bb473da6dca68108048ee428d19b1502ed6c819f5969363f9281","src/frames/tests/wtframe.rs":"c6598d24f5e12972f02de6e1394362671633982db637a07e1c0bb9b56d93ea2a","src/frames/wtframe.rs":"1d6dd2d1270346992cacd72e458bc7c5fe13ba7760d360287842d7e63493fdfe","src/headers_checks.rs":"1ea31e81a501d08f6efdd9ee34a290215166af43c82c6eedb89077ab58672808","src/lib.rs":"814e61abffe9d32c88ed5d63941970bcb6802b02a7b64742aa6d0fe4a7523ae9","src/priority.rs":"5fa28fe1a235c4ffb0ab9a4506e979d7bd1a7d0136f2d525ca083bb81733db96","src/push_controller.rs":"cd05db6143b39b8913ca871bbcd00bb43271b9c9dd8ef53610313b929bbae80a","src/push_id.rs":"bf931466d0490cbe8977cd7a732d1d4970e16220f331899f5e7dab8873ece5de","src/qlog.rs":"9ae732d611f74b99fee124faed5d883ec130b1bd991c4af38608bc5bff274cc6","src/qpack_decoder_receiver.rs":"6f6ce0cf5946688f9811bc09ea69a6c02d7b173ba3a64cac31b4daa970f3004b","src/qpack_encoder_receiver.rs":"db30ea43d4cdb5f0fde2dc49e7d8b8ba12e38acbcb8b4417fe68d2551cefa2ea","src/recv_message.rs":"d008459fc7e75b39f23ef63c5c88bd194c784fbc8902e6dd66bb5439f77fcfe4","src/request_target.rs":"01f05026ea7ad47085ffe462df08401ccd162737e3b7a995e8dece31dd46ada6","src/send_message.rs":"916d93bcf4b38f68ea5fb5dfaea7555aa43a82f946124c85423caf67f74ee3b5","src/server.rs":"3448df84f6af734356e81f5896d2501a399195c85246884499ef3452fc23f68d","src/server_connection_events.rs":"22de5284446d663940d97bbcffb031ea616d6125680eaee8b5bf49b1280e1b26","src/server_events.rs":"8814a8ea3cb68218d05903eb64da7dea1fa5a7f4932ef887daae956b45a9d041","src/settings.rs":"88616d45069d942e08fe0a8ea0e52d5eff7f91998df67aa12d9484bb6f50ec5d","src/stream_type_reader.rs":"5ac672dc9d1faa2781b718016732d2bd9c7d8850989fc2756ae32c9bf29ee186","tests/classic_connect.rs":"bdbc3dece193778f30e8a4df2492eb0efc3ac066ffb18b1d5cb96671dc45da82","tests/connect_udp.rs":"9c45bd7dc96201b42b4fe2bfd6c394d10a599f2162104898d639d7920be2004d","tests/httpconn.rs":"bbf72898d2b06ded382fd5f48e1d48a2f6724a44d752929980910a6ce844b0b6","tests/priority.rs":"b641c791e95e21713697c511a0f15d69ee141f017e1ffc7d9b46caa5ed47737c","tests/send_message.rs":"eabb424f1d068e84c5d53a8e0c04a019720e4ac6e969c175de7d8aba3dbd6ae5","tests/webtransport.rs":"b503cce443ec5212c79ed273b31eee7bf01bfd81ab41c9ac99f3846ad54bcfec"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"b4426ad0990130a5552c377a4b248be4df71e467810aaf85c996be60ecdd2bfd","benches/streams.rs":"99109260f4fbca61b4ac624a4162ba305f476f4fa8de7c3c4a54edf0935f3125","src/buffered_send_stream.rs":"f261f36e92ce9a4a4f06350a2087c169b3644583e83b98cc5682acd0ac28bd40","src/client_events.rs":"1540480a3bf38a47aac4699eceaa3e91a850101b560691396b8784a5bf836d68","src/conn_params.rs":"6b2c6f1394d79f84c4b2141a0838fc95ad53145e56f61e31bc6d10fe374a7ff6","src/connection.rs":"bc7f27e1b88e73b8f892dd7e1833e296f94a5771c96bfc76a5d15dc697afed1b","src/connection_client.rs":"ba2ce59ad751967a31e4f88af039f8b36bf80740907638904768179ac36bdb0a","src/connection_server.rs":"b30250e4861db2a86809bcfc1bedf6c7f174c09cbb75e2e1053eaa0dfe145dc4","src/control_stream_local.rs":"37760e0b42c9c3d7053d4ea3e11fb64d8e51c7ab3f56e656129453d58fb891e8","src/control_stream_remote.rs":"6477605bd2d7c66f1fea408cc1c265bb180d76b1cf40b463ba50c2f0f1a9e408","src/features/extended_connect/connect_udp_session.rs":"fcbe4825ca299d6c76c3bdc8872fd1e8bcdef086974fbe5357810ef0bf5f2c9c","src/features/extended_connect/mod.rs":"28dc55af94fc79591b3e3db5778024094d327df84e1b9945e525190bd69c56c6","src/features/extended_connect/session.rs":"8756a7f6d53596debc6249f861983b93ecdfc95e3216dacde941c5dabd6ab96a","src/features/extended_connect/tests/mod.rs":"fd6aee37243713e80fc526552f21f0222338cec9890409b6575a2a637b17ec1f","src/features/extended_connect/tests/webtransport/datagrams.rs":"16a69b41aaada5339b85153b7194d2c1e9151ce9f25b29e02b0f24bb9500b331","src/features/extended_connect/tests/webtransport/mod.rs":"5adfd5cb1af3f72978212a810d140838226c341f19d7e9a16820f3eb7bc4280f","src/features/extended_connect/tests/webtransport/negotiation.rs":"b0083f8737bdea9bc0de1940c627d497fee8b79ebc218bbcea0a562ae530527f","src/features/extended_connect/tests/webtransport/sessions.rs":"9ab94724bced450d173a7b2a0e8cfba248c568e85eebe086e139196f003671d3","src/features/extended_connect/tests/webtransport/streams.rs":"e84374071268ecec302bc1c3e825bc2b7219dc11a7b88043061565f256c48542","src/features/extended_connect/webtransport_session.rs":"00c70e513a0d0425c5eb3830629b5147b87fbbc82b753c633f1367811e2a03ea","src/features/extended_connect/webtransport_streams.rs":"73b3b08ab152420ae8657641f06788fb0cd9ef99b9399d1c814cd4e06f3581b0","src/features/mod.rs":"7424e5f1939324953ed6acce76c5774f2bdfae3d1dfbdd938a4eded8a94d5c9e","src/frames/connect_udp_frame.rs":"4cd3d958dbad7ac60f469539ecfa029eec1ac930639d6065b877cc44289db18f","src/frames/hframe.rs":"8fb1e83571df12860e05b47d3e59e4c7815da56186ce6c52fb7a11c58012c513","src/frames/mod.rs":"f19dba3b1a70f6cbb84b1ddfd4e7d654d8b3d6fd113599ae5bd9ea064ef18fc9","src/frames/reader.rs":"84d3c09145d0c7dfe9d5b6af1921e024412f2e8dd4f74013ae34a153bd17a44d","src/frames/tests/hframe.rs":"43a7735fc859692633e7f3c031710a9fb635611756cb4b9f387bac0a38c0fa09","src/frames/tests/mod.rs":"4bbdf566a7370605d49373027b38c4bcbd91113f7693efee29b9d91e3914ad98","src/frames/tests/reader.rs":"2d2d49404690a0c545a7b4273d5714c1ea7be2905eccd16f22dcff90b67607e0","src/frames/tests/wtframe.rs":"c6598d24f5e12972f02de6e1394362671633982db637a07e1c0bb9b56d93ea2a","src/frames/wtframe.rs":"1d6dd2d1270346992cacd72e458bc7c5fe13ba7760d360287842d7e63493fdfe","src/headers_checks.rs":"93b69056321eefa8b0260bbfd8ba82064de2fcb915c7fd63e0f2855ea6187eba","src/lib.rs":"17c27be8d41e7841c92b00e35dcc25b16a17fd584a686f2bc86ee20e6fee149d","src/priority.rs":"a9af1fccc467159fd05f488fa2e62ce2efdc95fcc395cd8368554703e100f60d","src/push_controller.rs":"cd05db6143b39b8913ca871bbcd00bb43271b9c9dd8ef53610313b929bbae80a","src/push_id.rs":"bf931466d0490cbe8977cd7a732d1d4970e16220f331899f5e7dab8873ece5de","src/qlog.rs":"30e9b207b695843748b82ca0b001ab4e943c866716c6c69215577d896a01d5c3","src/qpack_decoder_receiver.rs":"452c75d6de4fa6ccc412107223da12f9a1f417fb478717b02df7234efefb0e87","src/qpack_encoder_receiver.rs":"bbbfd06857ecb797c6aeb05a8e30469c863b7d80865400ada6fb38ef84a1b764","src/recv_message.rs":"40c44890ad5a2c3691d93dd65814021c546ad5c1f970a66fee42df1e6ab54b78","src/request_target.rs":"01f05026ea7ad47085ffe462df08401ccd162737e3b7a995e8dece31dd46ada6","src/send_message.rs":"2e2e9b0acecee2d68c18842d75c56a781395f3cf571d387cb59eacc31566c588","src/server.rs":"00df66e2a35466182e8212024c816282ba3078b71f662abf90d9d34b37edbfe1","src/server_connection_events.rs":"a7b2b39e7474af17df784387d308a2afe092999379c85a06bc76b55059fdfae8","src/server_events.rs":"dbdc31dbb385f30e57a2431e790ee075777e5f25a61a2229b6d2f846b6d9be9d","src/settings.rs":"ab1538ea74db40e603513884a2a55c0bb63ef58d57f04aa203f4590db1ecec33","src/stream_type_reader.rs":"145bd4986f573ad0228291392c72848f309dfd5108157440502ac34f0a3017b4","tests/classic_connect.rs":"962940201353e7cdfe21079f2755ec6a64cd8bc29b9652380d80a6f59135980c","tests/connect_udp.rs":"c4c3548ef8e0d112f73e30e2990e7b3d58943e7657bccffc11a1c996b8edc349","tests/httpconn.rs":"16376cd3af501c6f23ef991c85810f2a7a0db532c3bb05755747fd8e6cb41afc","tests/priority.rs":"b641c791e95e21713697c511a0f15d69ee141f017e1ffc7d9b46caa5ed47737c","tests/send_message.rs":"1b56683fc58833ccc106c65bce14edc44f6a3cdbd2e702e3652fcaef11c1d68d","tests/webtransport.rs":"bc424647146f2e24b7d1d2320a35aea841177be8e98cf45413d5b4153bd6f2d1"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-http3/Cargo.toml b/third_party/rust/neqo-http3/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-http3" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = false autolib = false @@ -51,7 +51,6 @@ bench = [ "neqo-crypto/bench", "neqo-qpack/bench", "neqo-transport/bench", - "log/release_max_level_info", ] disable-encryption = [ "neqo-transport/disable-encryption", @@ -182,7 +181,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -190,8 +188,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -244,8 +240,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-http3/src/buffered_send_stream.rs b/third_party/rust/neqo-http3/src/buffered_send_stream.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::time::Instant; - use neqo_common::Encoder; use neqo_transport::{Connection, StreamId}; @@ -63,7 +61,7 @@ impl BufferedStream { /// # Errors /// /// Returns `neqo_transport` errors. - pub fn send_buffer(&mut self, conn: &mut Connection, now: Instant) -> Res<usize> { + pub fn send_buffer(&mut self, conn: &mut Connection) -> Res<usize> { let Self::Initialized { stream_id, buf } = self else { return Ok(0); }; @@ -79,21 +77,16 @@ impl BufferedStream { let b = buf.split_off(sent); *buf = b; } - qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, sent, now); + qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, sent); Ok(sent) } /// # Errors /// /// Returns `neqo_transport` errors. - pub fn send_atomic( - &mut self, - conn: &mut Connection, - to_send: &[u8], - now: Instant, - ) -> Res<bool> { + pub fn send_atomic(&mut self, conn: &mut Connection, to_send: &[u8]) -> Res<bool> { // First try to send anything that is in the buffer. - self.send_buffer(conn, now)?; + self.send_buffer(conn)?; let Self::Initialized { stream_id, buf } = self else { return Ok(false); }; @@ -102,7 +95,7 @@ impl BufferedStream { } let res = conn.stream_send_atomic(*stream_id, to_send)?; if res { - qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, to_send.len(), now); + qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, to_send.len()); } Ok(res) } diff --git a/third_party/rust/neqo-http3/src/client_events.rs b/third_party/rust/neqo-http3/src/client_events.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, collections::VecDeque, rc::Rc}; -use neqo_common::{event::Provider as EventProvider, qtrace, Bytes, Header}; +use neqo_common::{event::Provider as EventProvider, qtrace, Header}; use neqo_crypto::ResumptionToken; use neqo_transport::{AppError, StreamId, StreamType}; @@ -40,7 +40,7 @@ pub enum WebTransportEvent { }, Datagram { session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -62,7 +62,7 @@ pub enum ConnectUdpEvent { }, Datagram { session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -283,7 +283,7 @@ impl ExtendedConnectEvents for Http3ClientEvents { fn new_datagram( &self, session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, connect_type: ExtendedConnectType, ) { let event = match connect_type { diff --git a/third_party/rust/neqo-http3/src/conn_params.rs b/third_party/rust/neqo-http3/src/conn_params.rs @@ -155,7 +155,6 @@ impl Http3Parameters { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_transport::ConnectionParameters; diff --git a/third_party/rust/neqo-http3/src/connection.rs b/third_party/rust/neqo-http3/src/connection.rs @@ -9,12 +9,9 @@ use std::{ fmt::{self, Debug, Display, Formatter}, mem, rc::Rc, - time::Instant, }; -use neqo_common::{ - qdebug, qerror, qinfo, qtrace, qwarn, Bytes, Decoder, Header, MessageType, Role, -}; +use neqo_common::{qdebug, qerror, qinfo, qtrace, qwarn, Decoder, Header, MessageType, Role}; use neqo_qpack as qpack; use neqo_transport::{ streams::SendOrder, AppError, CloseReason, Connection, DatagramTracking, State, StreamId, @@ -397,7 +394,7 @@ impl Http3Connection { /// has data to send it will be added to the `streams_with_pending_data` list. /// /// Control and QPACK streams are handled differently and are never added to the list. - fn send_non_control_streams(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { + fn send_non_control_streams(&mut self, conn: &mut Connection) -> Res<()> { let to_send = mem::take(&mut self.streams_with_pending_data); #[expect( clippy::iter_over_hash_type, @@ -405,7 +402,7 @@ impl Http3Connection { )] for stream_id in to_send { let done = if let Some(s) = &mut self.send_streams.get_mut(&stream_id) { - s.send(conn, now)?; + s.send(conn)?; if s.has_data_to_send() { self.streams_with_pending_data.insert(stream_id); } @@ -422,12 +419,12 @@ impl Http3Connection { /// Call `send` for all streams that need to send data. See explanation for the main structure /// for more details. - pub(crate) fn process_sending(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { + pub(crate) fn process_sending(&mut self, conn: &mut Connection) -> Res<()> { // check if control stream has data to send. self.control_stream_local - .send(conn, &mut self.recv_streams, now)?; + .send(conn, &mut self.recv_streams)?; - self.send_non_control_streams(conn, now)?; + self.send_non_control_streams(conn)?; self.qpack_decoder.borrow_mut().send(conn)?; match self.qpack_encoder.borrow_mut().send_encoder_updates(conn) { @@ -475,16 +472,11 @@ impl Http3Connection { /// The function calls [`RecvStream::receive`] for a stream. It also deals /// with the outcome of a read by calling /// [`Http3Connection::handle_stream_manipulation_output`]. - fn stream_receive( - &mut self, - conn: &mut Connection, - stream_id: StreamId, - now: Instant, - ) -> Res<ReceiveOutput> { + fn stream_receive(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<ReceiveOutput> { qtrace!("[{self}] Readable stream {stream_id}"); if let Some(recv_stream) = self.recv_streams.get_mut(&stream_id) { - let res = recv_stream.receive(conn, now); + let res = recv_stream.receive(conn); return self .handle_stream_manipulation_output(res, stream_id, conn) .map(|(output, _)| output); @@ -496,7 +488,6 @@ impl Http3Connection { &mut self, unblocked_streams: Vec<StreamId>, conn: &mut Connection, - now: Instant, ) -> Res<()> { for stream_id in unblocked_streams { qdebug!("[{self}] Stream {stream_id} is unblocked"); @@ -504,7 +495,7 @@ impl Http3Connection { let res = r .http_stream() .ok_or(Error::HttpInternal(10))? - .header_unblocked(conn, now); + .header_unblocked(conn); let res = self.handle_stream_manipulation_output(res, stream_id, conn)?; debug_assert!(matches!(res, (ReceiveOutput::NoOutput, _))); } @@ -524,17 +515,16 @@ impl Http3Connection { &mut self, conn: &mut Connection, stream_id: StreamId, - now: Instant, ) -> Res<ReceiveOutput> { - let mut output = self.stream_receive(conn, stream_id, now)?; + let mut output = self.stream_receive(conn, stream_id)?; if let ReceiveOutput::NewStream(stream_type) = output { - output = self.handle_new_stream(conn, stream_type, stream_id, now)?; + output = self.handle_new_stream(conn, stream_type, stream_id)?; } match output { ReceiveOutput::UnblockedStreams(unblocked_streams) => { - self.handle_unblocked_streams(unblocked_streams, conn, now)?; + self.handle_unblocked_streams(unblocked_streams, conn)?; Ok(ReceiveOutput::NoOutput) } ReceiveOutput::ControlFrames(control_frames) => { @@ -662,26 +652,18 @@ impl Http3Connection { } } - pub(crate) fn handle_datagram(&mut self, datagram: Vec<u8>) { - let mut decoder = Decoder::new(&datagram); - let Some(id) = decoder.decode_varint() else { - qdebug!("[{self}] handle_datagram: failed to decode session ID"); - return; - }; - let varint_len = decoder.offset(); - - let Some(stream) = self - .recv_streams - .get_mut(&StreamId::from(id * 4)) + pub(crate) fn handle_datagram(&mut self, datagram: &[u8]) { + let mut decoder = Decoder::new(datagram); + let Some(stream) = decoder + .decode_varint() + .and_then(|id| self.recv_streams.get_mut(&StreamId::from(id * 4))) .and_then(|s| s.extended_connect_session()) else { qdebug!("[{self}] handle_datagram for unknown extended connect session"); return; }; - stream - .borrow_mut() - .datagram(Bytes::new(datagram, varint_len)); + stream.borrow_mut().datagram(decoder.as_ref()); } fn check_stream_exists(&self, stream_type: Http3StreamType) -> Res<()> { @@ -706,7 +688,6 @@ impl Http3Connection { conn: &mut Connection, stream_type: NewStreamType, stream_id: StreamId, - now: Instant, ) -> Res<ReceiveOutput> { match stream_type { NewStreamType::Control => { @@ -767,7 +748,7 @@ impl Http3Connection { match stream_type { NewStreamType::Control | NewStreamType::Decoder | NewStreamType::Encoder => { - self.stream_receive(conn, stream_id, now) + self.stream_receive(conn, stream_id) } NewStreamType::Push(_) | NewStreamType::Http(_) @@ -888,7 +869,6 @@ impl Http3Connection { recv_events: Box<dyn HttpRecvStreamEvents>, push_handler: Option<Rc<RefCell<PushController>>>, request: &RequestDescription<T>, - now: Instant, ) -> Res<StreamId> where T: RequestTarget, @@ -899,15 +879,7 @@ impl Http3Connection { request.target, ); let id = self.create_bidi_transport_stream(conn)?; - self.request_with_stream( - id, - conn, - send_events, - recv_events, - push_handler, - request, - now, - )?; + self.request_with_stream(id, conn, send_events, recv_events, push_handler, request)?; Ok(id) } @@ -929,7 +901,6 @@ impl Http3Connection { Ok(id) } - #[expect(clippy::too_many_arguments, reason = "Yes, but they are needed.")] fn request_with_stream<T>( &mut self, stream_id: StreamId, @@ -938,7 +909,6 @@ impl Http3Connection { recv_events: Box<dyn HttpRecvStreamEvents>, push_handler: Option<Rc<RefCell<PushController>>>, request: &RequestDescription<T>, - now: Instant, ) -> Res<()> where T: RequestTarget, @@ -987,7 +957,7 @@ impl Http3Connection { self.send_streams .get_mut(&stream_id) .ok_or(Error::InvalidStreamId)? - .send(conn, now)?; + .send(conn)?; Ok(()) } @@ -1003,14 +973,13 @@ impl Http3Connection { conn: &mut Connection, stream_id: StreamId, buf: &mut [u8], - now: Instant, ) -> Res<(usize, bool)> { qdebug!("[{self}] read_data from stream {stream_id}"); let res = self .recv_streams .get_mut(&stream_id) .ok_or(Error::InvalidStreamId)? - .read_data(conn, buf, now); + .read_data(conn, buf); self.handle_stream_manipulation_output(res, stream_id, conn) } @@ -1133,12 +1102,7 @@ impl Http3Connection { } /// This is called when an application wants to close the sending side of a stream. - pub fn stream_close_send( - &mut self, - conn: &mut Connection, - stream_id: StreamId, - now: Instant, - ) -> Res<()> { + pub fn stream_close_send(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<()> { qdebug!("[{self}] Close the sending side for stream {stream_id}"); debug_assert!(self.state.active()); let send_stream = self @@ -1147,7 +1111,7 @@ impl Http3Connection { .ok_or(Error::InvalidStreamId)?; // The following function may return InvalidStreamId from the transport layer if the stream // has been closed already. It is ok to ignore it here. - drop(send_stream.close(conn, now)); + drop(send_stream.close(conn)); if send_stream.done() { self.remove_send_stream(stream_id, conn); } else if send_stream.has_data_to_send() { @@ -1249,7 +1213,6 @@ impl Http3Connection { stream_id: StreamId, events: Box<dyn ExtendedConnectEvents>, accept_res: &SessionAcceptAction, - now: Instant, ) -> Res<()> { qtrace!("Respond to WebTransport session with accept={accept_res}"); if !self.webtransport_enabled() { @@ -1261,7 +1224,6 @@ impl Http3Connection { events, accept_res, ExtendedConnectType::WebTransport, - now, ) } @@ -1271,7 +1233,6 @@ impl Http3Connection { stream_id: StreamId, events: Box<dyn ExtendedConnectEvents>, accept_res: &SessionAcceptAction, - now: Instant, ) -> Res<()> { qtrace!("Respond to ConnectUdp session with accept={accept_res}"); if !self.connect_udp_enabled() { @@ -1283,7 +1244,6 @@ impl Http3Connection { events, accept_res, ExtendedConnectType::ConnectUdp, - now, ) } @@ -1294,7 +1254,6 @@ impl Http3Connection { events: Box<dyn ExtendedConnectEvents>, accept_res: &SessionAcceptAction, connect_type: ExtendedConnectType, - now: Instant, ) -> Res<()> { let mut recv_stream = self.recv_streams.get_mut(&stream_id); if let Some(r) = &mut recv_stream { @@ -1323,7 +1282,7 @@ impl Http3Connection { .send_headers(headers, conn) .is_ok() { - drop(self.stream_close_send(conn, stream_id, now)); + drop(self.stream_close_send(conn, stream_id)); // TODO issue 1294: add a timer to clean up the recv_stream if the peer does not // do that in a short time. self.streams_with_pending_data.insert(stream_id); @@ -1373,10 +1332,9 @@ impl Http3Connection { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { qtrace!("Close WebTransport session {session_id:?}"); - self.extended_connect_close_session(conn, session_id, error, message, now) + self.extended_connect_close_session(conn, session_id, error, message) } pub(crate) fn connect_udp_close_session( @@ -1385,10 +1343,9 @@ impl Http3Connection { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { qtrace!("Close ConnectUdp session {session_id:?}"); - self.extended_connect_close_session(conn, session_id, error, message, now) + self.extended_connect_close_session(conn, session_id, error, message) } fn extended_connect_close_session( @@ -1397,7 +1354,6 @@ impl Http3Connection { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { let send_stream = self .send_streams @@ -1405,7 +1361,7 @@ impl Http3Connection { .filter(|s| s.stream_type() == Http3StreamType::ExtendedConnect) .ok_or(Error::InvalidStreamId)?; - send_stream.close_with_message(conn, error, message, now)?; + send_stream.close_with_message(conn, error, message)?; if send_stream.done() { self.remove_send_stream(session_id, conn); } else if send_stream.has_data_to_send() { @@ -1866,7 +1822,6 @@ impl Http3Connection { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use url::Url; diff --git a/third_party/rust/neqo-http3/src/connection_client.rs b/third_party/rust/neqo-http3/src/connection_client.rs @@ -508,7 +508,6 @@ impl Http3Client { headers, priority, }, - now, ); if let Err(e) = &output { if e.connection_error() { @@ -550,7 +549,6 @@ impl Http3Client { headers, priority, }, - now, ); if let Err(e) = &output { if e.connection_error() { @@ -589,10 +587,10 @@ impl Http3Client { /// # Errors /// /// An error will be return if stream does not exist. - pub fn stream_close_send(&mut self, stream_id: StreamId, now: Instant) -> Res<()> { + pub fn stream_close_send(&mut self, stream_id: StreamId) -> Res<()> { qdebug!("[{self}] Close sending side stream={stream_id}"); self.base_handler - .stream_close_send(&mut self.conn, stream_id, now) + .stream_close_send(&mut self.conn, stream_id) } /// # Errors @@ -625,7 +623,7 @@ impl Http3Client { /// `process_output` has not been called when needed, and HTTP3 layer has not picked up the /// info that the stream has been closed.) `InvalidInput` if an empty buffer has been /// supplied. - pub fn send_data(&mut self, stream_id: StreamId, buf: &[u8], now: Instant) -> Res<usize> { + pub fn send_data(&mut self, stream_id: StreamId, buf: &[u8]) -> Res<usize> { qinfo!( "[{self}] end_data from stream {stream_id} sending {} bytes", buf.len() @@ -634,7 +632,7 @@ impl Http3Client { .send_streams_mut() .get_mut(&stream_id) .ok_or(Error::InvalidStreamId)? - .send_data(&mut self.conn, buf, now) + .send_data(&mut self.conn, buf) } /// Response data are read directly into a buffer supplied as a parameter of this function to @@ -651,9 +649,7 @@ impl Http3Client { buf: &mut [u8], ) -> Res<(usize, bool)> { qdebug!("[{self}] read_data from stream {stream_id}"); - let res = self - .base_handler - .read_data(&mut self.conn, stream_id, buf, now); + let res = self.base_handler.read_data(&mut self.conn, stream_id, buf); if let Err(e) = &res { if e.connection_error() { self.close(now, e.code(), ""); @@ -769,15 +765,9 @@ impl Http3Client { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { - self.base_handler.webtransport_close_session( - &mut self.conn, - session_id, - error, - message, - now, - ) + self.base_handler + .webtransport_close_session(&mut self.conn, session_id, error, message) } /// Close `ConnectUdp` cleanly @@ -794,10 +784,9 @@ impl Http3Client { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { self.base_handler - .connect_udp_close_session(&mut self.conn, session_id, error, message, now) + .connect_udp_close_session(&mut self.conn, session_id, error, message) } /// # Errors @@ -986,19 +975,19 @@ impl Http3Client { qtrace!("[{self}] Process http3 internal"); match self.base_handler.state() { Http3State::ZeroRtt | Http3State::Connected | Http3State::GoingAway(..) => { - let res = self.check_connection_events(now); + let res = self.check_connection_events(); if self.check_result(now, &res) { return; } self.push_handler .borrow_mut() .maybe_send_max_push_id_frame(&mut self.base_handler); - let res = self.base_handler.process_sending(&mut self.conn, now); + let res = self.base_handler.process_sending(&mut self.conn); self.check_result(now, &res); } Http3State::Closed { .. } => {} _ => { - let res = self.check_connection_events(now); + let res = self.check_connection_events(); _ = self.check_result(now, &res); } } @@ -1094,7 +1083,7 @@ impl Http3Client { /// [1]: https://github.com/mozilla/neqo/blob/main/neqo-http3/src/connection.rs /// [2]: ../neqo_transport/enum.ConnectionEvent.html /// [3]: ../neqo_transport/enum.ConnectionEvent.html#variant.RecvStreamReadable - fn check_connection_events(&mut self, now: Instant) -> Res<()> { + fn check_connection_events(&mut self) -> Res<()> { qtrace!("[{self}] Check connection events"); while let Some(e) = self.conn.next_event() { qdebug!("[{self}] check_connection_events - event {e:?}"); @@ -1113,7 +1102,7 @@ impl Http3Client { } } ConnectionEvent::RecvStreamReadable { stream_id } => { - self.handle_stream_readable(stream_id, now)?; + self.handle_stream_readable(stream_id)?; } ConnectionEvent::RecvStreamReset { stream_id, @@ -1157,7 +1146,7 @@ impl Http3Client { } } ConnectionEvent::Datagram(dgram) => { - self.base_handler.handle_datagram(dgram); + self.base_handler.handle_datagram(&dgram); } ConnectionEvent::SendStreamComplete { .. } | ConnectionEvent::OutgoingDatagramOutcome { .. } @@ -1186,13 +1175,13 @@ impl Http3Client { /// specification. /// /// [1]: https://github.com/mozilla/neqo/blob/main/neqo-http3/src/connection.rs - fn handle_stream_readable(&mut self, stream_id: StreamId, now: Instant) -> Res<()> { + fn handle_stream_readable(&mut self, stream_id: StreamId) -> Res<()> { match self .base_handler - .handle_stream_readable(&mut self.conn, stream_id, now)? + .handle_stream_readable(&mut self.conn, stream_id)? { ReceiveOutput::NewStream(NewStreamType::Push(push_id)) => { - self.handle_new_push_stream(stream_id, push_id, now) + self.handle_new_push_stream(stream_id, push_id) } ReceiveOutput::NewStream(NewStreamType::Http(_)) => Err(Error::HttpStreamCreation), ReceiveOutput::NewStream(NewStreamType::WebTransportStream(session_id)) => { @@ -1202,9 +1191,9 @@ impl Http3Client { Box::new(self.events.clone()), Box::new(self.events.clone()), )?; - let res = - self.base_handler - .handle_stream_readable(&mut self.conn, stream_id, now)?; + let res = self + .base_handler + .handle_stream_readable(&mut self.conn, stream_id)?; debug_assert!(matches!(res, ReceiveOutput::NoOutput)); Ok(()) } @@ -1232,12 +1221,7 @@ impl Http3Client { } } - fn handle_new_push_stream( - &mut self, - stream_id: StreamId, - push_id: PushId, - now: Instant, - ) -> Res<()> { + fn handle_new_push_stream(&mut self, stream_id: StreamId, push_id: PushId) -> Res<()> { if !self.push_handler.borrow().can_receive_push() { return Err(Error::HttpId); } @@ -1278,7 +1262,7 @@ impl Http3Client { ); let res = self .base_handler - .handle_stream_readable(&mut self.conn, stream_id, now)?; + .handle_stream_readable(&mut self.conn, stream_id)?; debug_assert!(matches!(res, ReceiveOutput::NoOutput)); Ok(()) } @@ -1374,7 +1358,6 @@ impl EventProvider for Http3Client { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::time::Duration; @@ -1842,7 +1825,7 @@ mod tests { ) .unwrap(); if close_sending_side { - client.stream_close_send(request_stream_id, now()).unwrap(); + client.stream_close_send(request_stream_id).unwrap(); } request_stream_id } @@ -2781,11 +2764,9 @@ mod tests { // Get DataWritable for the request stream so that we can write the request body. let data_writable = |e| matches!(e, Http3ClientEvent::DataWritable { .. }); assert!(client.events().any(data_writable)); - let sent = client - .send_data(request_stream_id, REQUEST_BODY, now()) - .unwrap(); + let sent = client.send_data(request_stream_id, REQUEST_BODY).unwrap(); assert_eq!(sent, REQUEST_BODY.len()); - client.stream_close_send(request_stream_id, now()).unwrap(); + client.stream_close_send(request_stream_id).unwrap(); let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); @@ -2829,11 +2810,11 @@ mod tests { // Get DataWritable for the request stream so that we can write the request body. let data_writable = |e| matches!(e, Http3ClientEvent::DataWritable { .. }); assert!(client.events().any(data_writable)); - let sent = client.send_data(request_stream_id, request_body, now()); + let sent = client.send_data(request_stream_id, request_body); assert_eq!(sent, Ok(request_body.len())); // Close stream. - client.stream_close_send(request_stream_id, now()).unwrap(); + client.stream_close_send(request_stream_id).unwrap(); // We need to loop a bit until all data has been sent. let mut out = client.process_output(now()); @@ -2917,19 +2898,15 @@ mod tests { assert!(client.events().any(data_writable)); // Send the first frame. - let sent = client.send_data(request_stream_id, first_frame, now()); + let sent = client.send_data(request_stream_id, first_frame); assert_eq!(sent, Ok(first_frame.len())); // The second frame cannot fit. - let sent = client.send_data( - request_stream_id, - &vec![0_u8; INITIAL_RECV_WINDOW_SIZE], - now(), - ); + let sent = client.send_data(request_stream_id, &vec![0_u8; INITIAL_RECV_WINDOW_SIZE]); assert_eq!(sent, Ok(expected_second_data_frame.len())); // Close stream. - client.stream_close_send(request_stream_id, now()).unwrap(); + client.stream_close_send(request_stream_id).unwrap(); let mut out = client.process_output(now()); // We need to loop a bit until all data has been sent. Once for every 1K @@ -3090,7 +3067,7 @@ mod tests { // assert that we cannot send any more request data. assert_eq!( Err(Error::InvalidStreamId), - client.send_data(request_stream_id, &[0_u8; 10], now()) + client.send_data(request_stream_id, &[0_u8; 10]) ); stop_sending = true; } @@ -4428,7 +4405,7 @@ mod tests { assert!(client.events().any(recvd_0rtt_reject)); // ...and the client stream should be gone. - let res = client.stream_close_send(request_stream_id, now()); + let res = client.stream_close_send(request_stream_id); assert!(res.is_err()); assert_eq!(res.unwrap_err(), Error::InvalidStreamId); @@ -6602,7 +6579,7 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); - drop(server.encoder_receiver.receive(&mut server.conn, now())); + drop(server.encoder_receiver.receive(&mut server.conn)); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6651,7 +6628,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); drop(server.conn.process(out.dgram(), now())); - drop(server.encoder_receiver.receive(&mut server.conn, now())); + drop(server.encoder_receiver.receive(&mut server.conn)); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6687,12 +6664,7 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); - drop( - server - .encoder_receiver - .receive(&mut server.conn, now()) - .unwrap(), - ); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6729,12 +6701,7 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); - drop( - server - .encoder_receiver - .receive(&mut server.conn, now()) - .unwrap(), - ); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); } @@ -6795,12 +6762,7 @@ mod tests { let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); - drop( - server - .encoder_receiver - .receive(&mut server.conn, now()) - .unwrap(), - ); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6814,12 +6776,7 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); drop(server.conn.process(out.dgram(), now())); - drop( - server - .encoder_receiver - .receive(&mut server.conn, now()) - .unwrap(), - ); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); } @@ -7395,12 +7352,12 @@ mod tests { Error::InvalidStreamId ); assert_eq!( - client.stream_close_send(stream_id, now()).unwrap_err(), + client.stream_close_send(stream_id).unwrap_err(), Error::InvalidStreamId ); let mut buf = [0; 2]; assert_eq!( - client.send_data(stream_id, &buf, now()).unwrap_err(), + client.send_data(stream_id, &buf).unwrap_err(), Error::InvalidStreamId ); assert_eq!( @@ -7452,9 +7409,7 @@ mod tests { let data_writable = |e| matches!(e, Http3ClientEvent::DataWritable { .. }); assert!(client.events().any(data_writable)); // Send a lot of data to reach the flow control limit - client - .send_data(request_stream_id, &[0; 2000], now()) - .unwrap(); + client.send_data(request_stream_id, &[0; 2000]).unwrap(); // now queue a priority_update packet for that stream assert!(client diff --git a/third_party/rust/neqo-http3/src/connection_server.rs b/third_party/rust/neqo-http3/src/connection_server.rs @@ -67,14 +67,13 @@ impl Http3ServerHandler { stream_id: StreamId, data: &[u8], conn: &mut Connection, - now: Instant, ) -> Res<usize> { let n = self .base_handler .send_streams_mut() .get_mut(&stream_id) .ok_or(Error::InvalidStreamId)? - .send_data(conn, data, now)?; + .send_data(conn, data)?; if n > 0 { self.base_handler.stream_has_pending_data(stream_id); } @@ -106,14 +105,9 @@ impl Http3ServerHandler { /// # Errors /// /// An error will be returned if stream does not exist. - pub fn stream_close_send( - &mut self, - stream_id: StreamId, - conn: &mut Connection, - now: Instant, - ) -> Res<()> { + pub fn stream_close_send(&mut self, stream_id: StreamId, conn: &mut Connection) -> Res<()> { qdebug!("[{self}] Close sending side stream={stream_id}"); - self.base_handler.stream_close_send(conn, stream_id, now)?; + self.base_handler.stream_close_send(conn, stream_id)?; self.needs_processing = true; Ok(()) } @@ -164,7 +158,6 @@ impl Http3ServerHandler { conn: &mut Connection, stream_id: StreamId, accept: &SessionAcceptAction, - now: Instant, ) -> Res<()> { self.needs_processing = true; self.base_handler.webtransport_session_accept( @@ -172,7 +165,6 @@ impl Http3ServerHandler { stream_id, Box::new(self.events.clone()), accept, - now, ) } @@ -182,7 +174,6 @@ impl Http3ServerHandler { conn: &mut Connection, stream_id: StreamId, accept: &SessionAcceptAction, - now: Instant, ) -> Res<()> { self.needs_processing = true; self.base_handler.connect_udp_session_accept( @@ -190,7 +181,6 @@ impl Http3ServerHandler { stream_id, Box::new(self.events.clone()), accept, - now, ) } @@ -209,11 +199,10 @@ impl Http3ServerHandler { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { self.needs_processing = true; self.base_handler - .webtransport_close_session(conn, session_id, error, message, now) + .webtransport_close_session(conn, session_id, error, message) } /// Close `ConnectUdp` cleanly @@ -231,11 +220,10 @@ impl Http3ServerHandler { session_id: StreamId, error: u32, message: &str, - now: Instant, ) -> Res<()> { self.needs_processing = true; self.base_handler - .connect_udp_close_session(conn, session_id, error, message, now) + .connect_udp_close_session(conn, session_id, error, message) } pub fn webtransport_create_stream( @@ -287,7 +275,7 @@ impl Http3ServerHandler { let res = self.check_connection_events(conn, now); if !self.check_result(conn, now, &res) && self.base_handler.state().active() { - let res = self.base_handler.process_sending(conn, now); + let res = self.base_handler.process_sending(conn); self.check_result(conn, now, &res); } } @@ -336,7 +324,7 @@ impl Http3ServerHandler { self.base_handler.add_new_stream(stream_id); } ConnectionEvent::RecvStreamReadable { stream_id } => { - self.handle_stream_readable(conn, stream_id, now)?; + self.handle_stream_readable(conn, stream_id)?; } ConnectionEvent::RecvStreamReset { stream_id, @@ -366,7 +354,7 @@ impl Http3ServerHandler { s.stream_writable(); } } - ConnectionEvent::Datagram(dgram) => self.base_handler.handle_datagram(dgram), + ConnectionEvent::Datagram(dgram) => self.base_handler.handle_datagram(&dgram), ConnectionEvent::AuthenticationNeeded | ConnectionEvent::EchFallbackAuthenticationNeeded { .. } | ConnectionEvent::ZeroRttRejected @@ -380,16 +368,8 @@ impl Http3ServerHandler { Ok(()) } - fn handle_stream_readable( - &mut self, - conn: &mut Connection, - stream_id: StreamId, - now: Instant, - ) -> Res<()> { - match self - .base_handler - .handle_stream_readable(conn, stream_id, now)? - { + fn handle_stream_readable(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<()> { + match self.base_handler.handle_stream_readable(conn, stream_id)? { ReceiveOutput::NewStream(NewStreamType::Push(_)) => Err(Error::HttpStreamCreation), ReceiveOutput::NewStream(NewStreamType::Http(first_frame_type)) => { self.base_handler.add_streams( @@ -414,9 +394,7 @@ impl Http3ServerHandler { PriorityHandler::new(false, Priority::default()), )), ); - let res = self - .base_handler - .handle_stream_readable(conn, stream_id, now)?; + let res = self.base_handler.handle_stream_readable(conn, stream_id)?; assert_eq!(ReceiveOutput::NoOutput, res); Ok(()) } @@ -427,9 +405,7 @@ impl Http3ServerHandler { Box::new(self.events.clone()), Box::new(self.events.clone()), )?; - let res = self - .base_handler - .handle_stream_readable(conn, stream_id, now)?; + let res = self.base_handler.handle_stream_readable(conn, stream_id)?; assert_eq!(ReceiveOutput::NoOutput, res); Ok(()) } @@ -489,7 +465,7 @@ impl Http3ServerHandler { buf: &mut [u8], ) -> Res<(usize, bool)> { qdebug!("[{self}] read_data from stream {stream_id}"); - let res = self.base_handler.read_data(conn, stream_id, buf, now); + let res = self.base_handler.read_data(conn, stream_id, buf); if let Err(e) = &res { if e.connection_error() { self.close(conn, now, e); diff --git a/third_party/rust/neqo-http3/src/control_stream_local.rs b/third_party/rust/neqo-http3/src/control_stream_local.rs @@ -7,7 +7,6 @@ use std::{ collections::VecDeque, fmt::{self, Display, Formatter}, - time::Instant, }; use neqo_common::{qtrace, Encoder}; @@ -54,17 +53,15 @@ impl ControlStreamLocal { &mut self, conn: &mut Connection, recv_conn: &mut HashMap<StreamId, Box<dyn RecvStream>>, - now: Instant, ) -> Res<()> { - self.stream.send_buffer(conn, now)?; - self.send_priority_update(conn, recv_conn, now) + self.stream.send_buffer(conn)?; + self.send_priority_update(conn, recv_conn) } fn send_priority_update( &mut self, conn: &mut Connection, recv_conn: &mut HashMap<StreamId, Box<dyn RecvStream>>, - now: Instant, ) -> Res<()> { // send all necessary priority updates while let Some(update_id) = self.outstanding_priority_update.pop_front() { @@ -84,7 +81,7 @@ impl ControlStreamLocal { if let Some(hframe) = stream.priority_update_frame() { let mut enc = Encoder::new(); hframe.encode(&mut enc); - if self.stream.send_atomic(conn, enc.as_ref(), now)? { + if self.stream.send_atomic(conn, enc.as_ref())? { stream.priority_update_sent()?; } else { self.outstanding_priority_update.push_front(update_id); diff --git a/third_party/rust/neqo-http3/src/control_stream_remote.rs b/third_party/rust/neqo-http3/src/control_stream_remote.rs @@ -4,10 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{ - fmt::{self, Display, Formatter}, - time::Instant, -}; +use std::fmt::{self, Display, Formatter}; use neqo_common::qdebug; use neqo_transport::{Connection, StreamId}; @@ -40,12 +37,14 @@ impl ControlStreamRemote { } /// Check if a stream is the control stream and read received data. - pub fn receive_single(&mut self, conn: &mut Connection, now: Instant) -> Res<Option<HFrame>> { + pub fn receive_single(&mut self, conn: &mut Connection) -> Res<Option<HFrame>> { qdebug!("[{self}] Receiving data"); - match self.frame_reader.receive( - &mut StreamReaderConnectionWrapper::new(conn, self.stream_id), - now, - )? { + match self + .frame_reader + .receive(&mut StreamReaderConnectionWrapper::new( + conn, + self.stream_id, + ))? { (_, true) => Err(Error::HttpClosedCriticalStream), (s, false) => { qdebug!("[{self}] received {s:?}"); @@ -66,11 +65,11 @@ impl RecvStream for ControlStreamRemote { Err(Error::HttpClosedCriticalStream) } - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)> { + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { let mut control_frames = Vec::new(); loop { - if let Some(f) = self.receive_single(conn, now)? { + if let Some(f) = self.receive_single(conn)? { control_frames.push(f); } else { return Ok((ReceiveOutput::ControlFrames(control_frames), false)); diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/connect_udp_session.rs b/third_party/rust/neqo-http3/src/features/extended_connect/connect_udp_session.rs @@ -4,12 +4,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{ - fmt::{self, Display, Formatter}, - time::Instant, -}; +use std::fmt::{self, Display, Formatter}; -use neqo_common::{Bytes, Decoder, Encoder}; +use neqo_common::Encoder; use neqo_transport::{Connection, StreamId}; use crate::{ @@ -53,14 +50,13 @@ impl Protocol for Session { conn: &mut Connection, events: &mut Box<dyn ExtendedConnectEvents>, control_stream_recv: &mut Box<dyn RecvStream>, - now: Instant, ) -> Res<Option<State>> { let (f, fin) = self .frame_reader - .receive::<ConnectUdpFrame>( - &mut StreamReaderRecvStreamWrapper::new(conn, control_stream_recv), - now, - ) + .receive::<ConnectUdpFrame>(&mut StreamReaderRecvStreamWrapper::new( + conn, + control_stream_recv, + )) .map_err(|_| Error::HttpGeneralProtocolStream)?; if let Some(f) = f { @@ -88,14 +84,10 @@ impl Protocol for Session { encoder.encode_varint(0u64); } - fn dgram_context_id(&self, datagram: Bytes) -> Result<Bytes, DgramContextIdError> { - let (context_id, offset) = { - let mut decoder = Decoder::new(datagram.as_ref()); - (decoder.decode_varint(), decoder.offset()) - }; - match context_id { - Some(0) => Ok(datagram.skip(offset)), - Some(context_id) => Err(DgramContextIdError::UnknownIdentifier(context_id)), + fn dgram_context_id<'a>(&self, datagram: &'a [u8]) -> Result<&'a [u8], DgramContextIdError> { + match datagram.split_first() { + Some((0, remainder)) => Ok(remainder), + Some((context_id, _)) => Err(DgramContextIdError::UnknownIdentifier(*context_id)), None => { // > all HTTP Datagrams associated with UDP Proxying request streams start with a Context ID field; // @@ -105,31 +97,3 @@ impl Protocol for Session { } } } - -#[cfg(test)] -mod tests { - use neqo_common::Bytes; - use neqo_transport::StreamId; - - use super::Session; - use crate::features::extended_connect::session::Protocol as _; - - #[test] - fn varint_0_context_id() { - let session = Session::new(StreamId::new(42)); - // Varint [0x00] is 0, i.e. a supported connect-udp context ID. - assert_eq!( - session - .dgram_context_id(Bytes::from(vec![0x00, 0x00, 0x00])) - .unwrap(), - Bytes::from(vec![0x00, 0x00]) - ); - // Varint [0x40 0x00] is 0 as well, thus a supported connect-udp context ID, too. - assert_eq!( - session - .dgram_context_id(Bytes::from(vec![0x40, 0x00, 0x00, 0x00])) - .unwrap(), - Bytes::from(vec![0x00, 0x00]) - ); - } -} diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/mod.rs b/third_party/rust/neqo-http3/src/features/extended_connect/mod.rs @@ -10,12 +10,11 @@ pub(crate) mod webtransport_session; pub(crate) mod webtransport_streams; #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests; use std::{cell::RefCell, fmt::Debug, mem, rc::Rc}; -use neqo_common::{Bytes, Header, Role}; +use neqo_common::{Header, Role}; use neqo_transport::StreamId; use crate::{ @@ -51,7 +50,7 @@ pub(crate) trait ExtendedConnectEvents: Debug { fn new_datagram( &self, session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, connect_type: ExtendedConnectType, ); } @@ -109,44 +108,24 @@ impl ExtendedConnectFeature { } } -#[expect( - clippy::struct_field_names, - reason = "wrapper type, providing additional info" -)] #[derive(Debug, Default)] -struct Headers { - headers: Vec<Header>, - interim: bool, - fin: bool, +struct Listener { + headers: Option<(Vec<Header>, bool, bool)>, } -/// Implementation of [`HttpRecvStreamEvents`]. Registered with the underlying -/// [`RecvMessage`] stream. Listening for [`RecvMessage`] to read -/// incoming headers. -/// -/// [`RecvMessage`]: crate::recv_message::RecvMessage -#[derive(Debug, Default)] -struct HeaderListener { - headers: Option<Headers>, -} - -impl HeaderListener { +impl Listener { fn set_headers(&mut self, headers: Vec<Header>, interim: bool, fin: bool) { - self.headers = Some(Headers { - headers, - interim, - fin, - }); + self.headers = Some((headers, interim, fin)); } - pub fn get_headers(&mut self) -> Option<Headers> { + pub fn get_headers(&mut self) -> Option<(Vec<Header>, bool, bool)> { mem::take(&mut self.headers) } } -impl RecvStreamEvents for Rc<RefCell<HeaderListener>> {} +impl RecvStreamEvents for Rc<RefCell<Listener>> {} -impl HttpRecvStreamEvents for Rc<RefCell<HeaderListener>> { +impl HttpRecvStreamEvents for Rc<RefCell<Listener>> { fn header_ready( &self, _stream_info: &Http3StreamInfo, @@ -160,4 +139,4 @@ impl HttpRecvStreamEvents for Rc<RefCell<HeaderListener>> { } } -impl SendStreamEvents for Rc<RefCell<HeaderListener>> {} +impl SendStreamEvents for Rc<RefCell<Listener>> {} diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/session.rs b/third_party/rust/neqo-http3/src/features/extended_connect/session.rs @@ -9,16 +9,13 @@ use std::{ collections::HashSet, fmt::{self, Debug, Display, Formatter}, rc::Rc, - time::Instant, }; -use neqo_common::{qdebug, qtrace, Bytes, Encoder, Header, MessageType, Role}; +use neqo_common::{qdebug, qtrace, Encoder, Header, MessageType, Role}; use neqo_transport::{AppError, Connection, DatagramTracking, StreamId}; use crate::{ - features::extended_connect::{ - ExtendedConnectEvents, ExtendedConnectType, HeaderListener, Headers, - }, + features::extended_connect::{ExtendedConnectEvents, ExtendedConnectType, Listener}, frames::HFrame, priority::PriorityHandler, recv_message::{RecvMessage, RecvMessageInfo}, @@ -52,7 +49,7 @@ impl From<CloseType> for CloseReason { pub(crate) struct Session { control_stream_recv: Box<dyn RecvStream>, control_stream_send: Box<dyn SendStream>, - stream_event_listener: Rc<RefCell<HeaderListener>>, + stream_event_listener: Rc<RefCell<Listener>>, id: StreamId, state: State, events: Box<dyn ExtendedConnectEvents>, @@ -91,7 +88,7 @@ impl Session { qpack_decoder: Rc<RefCell<neqo_qpack::Decoder>>, connect_type: ExtendedConnectType, ) -> Self { - let stream_event_listener = Rc::new(RefCell::new(HeaderListener::default())); + let stream_event_listener = Rc::new(RefCell::new(Listener::default())); let protocol = connect_type.new_protocol(session_id, role); Self { control_stream_recv: Box::new(RecvMessage::new( @@ -129,7 +126,7 @@ impl Session { mut control_stream_send: Box<dyn SendStream>, connect_type: ExtendedConnectType, ) -> Res<Self> { - let stream_event_listener = Rc::new(RefCell::new(HeaderListener::default())); + let stream_event_listener = Rc::new(RefCell::new(Listener::default())); let protocol = connect_type.new_protocol(session_id, role); control_stream_recv .http_stream() @@ -161,28 +158,24 @@ impl Session { .send_headers(headers, conn) } - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)> { + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { qtrace!("[{self}] receive control data"); - let (out, _) = self.control_stream_recv.receive(conn, now)?; + let (out, _) = self.control_stream_recv.receive(conn)?; debug_assert!(out == ReceiveOutput::NoOutput); self.maybe_check_headers()?; - self.read_control_stream(conn, now)?; + self.read_control_stream(conn)?; Ok((ReceiveOutput::NoOutput, self.state == State::Done)) } - fn header_unblocked( - &mut self, - conn: &mut Connection, - now: Instant, - ) -> Res<(ReceiveOutput, bool)> { + fn header_unblocked(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { let (out, _) = self .control_stream_recv .http_stream() .ok_or(Error::Internal)? - .header_unblocked(conn, now)?; + .header_unblocked(conn)?; debug_assert!(out == ReceiveOutput::NoOutput); self.maybe_check_headers()?; - self.read_control_stream(conn, now)?; + self.read_control_stream(conn)?; Ok((ReceiveOutput::NoOutput, self.state == State::Done)) } @@ -206,8 +199,8 @@ impl Session { .priority_update_sent() } - fn send(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { - self.control_stream_send.send(conn, now)?; + fn send(&mut self, conn: &mut Connection) -> Res<()> { + self.control_stream_send.send(conn)?; if self.control_stream_send.done() { self.state = State::Done; } @@ -235,11 +228,7 @@ impl Session { return Ok(()); } - if let Some(Headers { - headers, - interim, - fin, - }) = self.stream_event_listener.borrow_mut().get_headers() + if let Some((headers, interim, fin)) = self.stream_event_listener.borrow_mut().get_headers() { qtrace!("ExtendedConnect response headers {headers:?}, fin={fin}"); @@ -329,13 +318,12 @@ impl Session { /// # Errors /// /// It may return an error if the frame is not correctly decoded. - pub(crate) fn read_control_stream(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { + pub(crate) fn read_control_stream(&mut self, conn: &mut Connection) -> Res<()> { qdebug!("[{self}]: read_control_stream"); if let Some(new_state) = self.protocol.read_control_stream( conn, &mut self.events, &mut self.control_stream_recv, - now, )? { self.state = new_state; } @@ -351,17 +339,16 @@ impl Session { conn: &mut Connection, error: u32, message: &str, - now: Instant, ) -> Res<()> { qdebug!("[{self}]: close_session"); self.state = State::Done; if let Some(close_frame) = self.protocol.close_frame(error, message) { self.control_stream_send - .send_data_atomic(conn, close_frame.as_ref(), now)?; + .send_data_atomic(conn, close_frame.as_ref())?; } - self.control_stream_send.close(conn, now)?; + self.control_stream_send.close(conn)?; self.state = if self.control_stream_send.done() { State::Done } else { @@ -370,8 +357,8 @@ impl Session { Ok(()) } - fn send_data(&mut self, conn: &mut Connection, buf: &[u8], now: Instant) -> Res<usize> { - self.control_stream_send.send_data(conn, buf, now) + fn send_data(&mut self, conn: &mut Connection, buf: &[u8]) -> Res<usize> { + self.control_stream_send.send_data(conn, buf) } /// # Errors @@ -398,22 +385,20 @@ impl Session { Ok(()) } - pub(crate) fn datagram(&self, datagram: Bytes) { + pub(crate) fn datagram(&self, datagram: &[u8]) { if self.state != State::Active { qdebug!("[{self}]: received datagram on {:?} session.", self.state); return; } - - // dgram_context_id returns the payload after stripping any context ID - match self.protocol.dgram_context_id(datagram) { - Ok(slice) => { - self.events - .new_datagram(self.id, slice, self.protocol.connect_type()); - } + let datagram = match self.protocol.dgram_context_id(datagram) { + Ok(datagram) => datagram, Err(e) => { qdebug!("[{self}]: received datagram with invalid context identifier: {e}"); + return; } - } + }; + self.events + .new_datagram(self.id, datagram.to_vec(), self.protocol.connect_type()); } fn has_data_to_send(&self) -> bool { @@ -432,8 +417,8 @@ impl Stream for Rc<RefCell<Session>> { } impl RecvStream for Rc<RefCell<Session>> { - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)> { - self.borrow_mut().receive(conn, now) + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { + self.borrow_mut().receive(conn) } fn reset(&mut self, close_type: CloseType) -> Res<()> { @@ -451,12 +436,8 @@ impl RecvStream for Rc<RefCell<Session>> { } impl HttpRecvStream for Rc<RefCell<Session>> { - fn header_unblocked( - &mut self, - conn: &mut Connection, - now: Instant, - ) -> Res<(ReceiveOutput, bool)> { - self.borrow_mut().header_unblocked(conn, now) + fn header_unblocked(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { + self.borrow_mut().header_unblocked(conn) } fn maybe_update_priority(&mut self, priority: Priority) -> Res<bool> { @@ -473,12 +454,12 @@ impl HttpRecvStream for Rc<RefCell<Session>> { } impl SendStream for Rc<RefCell<Session>> { - fn send(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { - self.borrow_mut().send(conn, now) + fn send(&mut self, conn: &mut Connection) -> Res<()> { + self.borrow_mut().send(conn) } - fn send_data(&mut self, conn: &mut Connection, buf: &[u8], now: Instant) -> Res<usize> { - self.borrow_mut().send_data(conn, buf, now) + fn send_data(&mut self, conn: &mut Connection, buf: &[u8]) -> Res<usize> { + self.borrow_mut().send_data(conn, buf) } fn has_data_to_send(&self) -> bool { @@ -491,18 +472,12 @@ impl SendStream for Rc<RefCell<Session>> { self.borrow_mut().done() } - fn close(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { - self.borrow_mut().close_session(conn, 0, "", now) + fn close(&mut self, conn: &mut Connection) -> Res<()> { + self.borrow_mut().close_session(conn, 0, "") } - fn close_with_message( - &mut self, - conn: &mut Connection, - error: u32, - message: &str, - now: Instant, - ) -> Res<()> { - self.borrow_mut().close_session(conn, error, message, now) + fn close_with_message(&mut self, conn: &mut Connection, error: u32, message: &str) -> Res<()> { + self.borrow_mut().close_session(conn, error, message) } fn handle_stop_sending(&mut self, close_type: CloseType) { @@ -530,7 +505,6 @@ pub(crate) trait Protocol: Debug + Display { conn: &mut Connection, events: &mut Box<dyn ExtendedConnectEvents>, control_stream_recv: &mut Box<dyn RecvStream>, - now: Instant, ) -> Res<Option<State>>; fn add_stream( @@ -563,7 +537,7 @@ pub(crate) trait Protocol: Debug + Display { fn write_datagram_prefix(&self, encoder: &mut Encoder); - fn dgram_context_id(&self, datagram: Bytes) -> Result<Bytes, DgramContextIdError>; + fn dgram_context_id<'a>(&self, datagram: &'a [u8]) -> Result<&'a [u8], DgramContextIdError>; } #[derive(Debug, Error)] @@ -571,5 +545,5 @@ pub(crate) enum DgramContextIdError { #[error("Missing context identifier")] MissingIdentifier, #[error("Unknown context identifier: {0}")] - UnknownIdentifier(u64), + UnknownIdentifier(u8), } diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs b/third_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs @@ -159,7 +159,7 @@ impl WtTest { headers, }) => { assert_wt(&headers); - session.response(accept, now()).unwrap(); + session.response(accept).unwrap(); wt_server_session = Some(session); } Http3ServerEvent::Data { .. } => { @@ -307,7 +307,7 @@ impl WtTest { fn send_data_client(&mut self, wt_stream_id: StreamId, data: &[u8]) { assert_eq!( - self.client.send_data(wt_stream_id, data, now()).unwrap(), + self.client.send_data(wt_stream_id, data).unwrap(), data.len() ); self.exchange_packets(); @@ -355,7 +355,7 @@ impl WtTest { } fn close_stream_sending_client(&mut self, wt_stream_id: StreamId) { - self.client.stream_close_send(wt_stream_id, now()).unwrap(); + self.client.stream_close_send(wt_stream_id).unwrap(); self.exchange_packets(); } @@ -455,7 +455,7 @@ impl WtTest { } fn send_data_server(&mut self, wt_stream: &Http3OrWebTransportStream, data: &[u8]) { - assert_eq!(wt_stream.send_data(data, now()).unwrap(), data.len()); + assert_eq!(wt_stream.send_data(data).unwrap(), data.len()); self.exchange_packets(); } @@ -499,7 +499,7 @@ impl WtTest { } fn close_stream_sending_server(&mut self, wt_stream: &Http3OrWebTransportStream) { - wt_stream.stream_close_send(now()).unwrap(); + wt_stream.stream_close_send().unwrap(); self.exchange_packets(); } @@ -587,12 +587,12 @@ impl WtTest { pub fn session_close_frame_client(&mut self, session_id: StreamId, error: u32, message: &str) { self.client - .webtransport_close_session(session_id, error, message, now()) + .webtransport_close_session(session_id, error, message) .unwrap(); } pub fn session_close_frame_server(wt_session: &WebTransportRequest, error: u32, message: &str) { - wt_session.close_session(error, message, now()).unwrap(); + wt_session.close_session(error, message).unwrap(); } fn max_datagram_size(&self, stream_id: StreamId) -> Result<u64, Error> { @@ -614,7 +614,7 @@ impl WtTest { Http3ClientEvent::WebTransport(WebTransportEvent::Datagram { session_id, datagram - }) if session_id == expected_stream_id && datagram.as_ref() == expected_dgram + }) if session_id == expected_stream_id && datagram == expected_dgram ) }; assert!(self.client.events().any(wt_datagram_event)); @@ -631,7 +631,7 @@ impl WtTest { Http3ServerEvent::WebTransport(WebTransportServerEvent::Datagram { session, datagram - }) if session.stream_id() == expected_session.stream_id() && datagram.as_ref() == expected_dgram + }) if session.stream_id() == expected_session.stream_id() && datagram == expected_dgram ) }; assert!(self.server.events().any(wt_datagram_event)); diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs b/third_party/rust/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs @@ -63,7 +63,7 @@ fn wt_session_close_server_close_send() { let mut wt = WtTest::new(); let wt_session = wt.create_wt_session(); - wt_session.stream_close_send(now()).unwrap(); + wt_session.stream_close_send().unwrap(); wt.exchange_packets(); wt.check_session_closed_event_client( wt_session.stream_id(), @@ -136,7 +136,7 @@ fn wt_session_response_with_1xx() { .send_headers(&[Header::new(":status", "111")]) .unwrap(); wt_server_session - .response(&SessionAcceptAction::Accept, now()) + .response(&SessionAcceptAction::Accept) .unwrap(); wt.exchange_packets(); @@ -195,9 +195,9 @@ fn wt_session_respone_200_with_fin() { let wt_server_session = wt_server_session.unwrap(); wt_server_session - .response(&SessionAcceptAction::Accept, now()) + .response(&SessionAcceptAction::Accept) .unwrap(); - wt_server_session.stream_close_send(now()).unwrap(); + wt_server_session.stream_close_send().unwrap(); wt.exchange_packets(); @@ -275,9 +275,7 @@ fn wt_unknown_session_frame_client() { enc.encode_varint(UNKNOWN_FRAME_LEN as u64); let mut buf: Vec<_> = enc.into(); buf.resize(UNKNOWN_FRAME_LEN + buf.len(), 0); - wt.client - .send_data(wt_session.stream_id(), &buf, now()) - .unwrap(); + wt.client.send_data(wt_session.stream_id(), &buf).unwrap(); wt.exchange_packets(); // The session is still active @@ -327,9 +325,7 @@ fn wt_close_session_frame_broken_client() { let mut buf: Vec<_> = enc.into(); // Corrupt the string. buf[9] = 0xff; - wt.client - .send_data(wt_session.stream_id(), &buf, now()) - .unwrap(); + wt.client.send_data(wt_session.stream_id(), &buf).unwrap(); wt.exchange_packets(); // check that the webtransport session is closed. @@ -389,7 +385,7 @@ fn wt_close_session_cannot_be_sent_at_once() { Header::new("content-length", BUF.len().to_string()), ]) .unwrap(); - req.send_data(BUF, now()).unwrap(); + req.send_data(BUF).unwrap(); // Now close the session. WtTest::session_close_frame_server(&wt_session, ERROR_NUM, ERROR_MESSAGE); diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/webtransport_session.rs b/third_party/rust/neqo-http3/src/features/extended_connect/webtransport_session.rs @@ -8,10 +8,9 @@ use std::{ collections::HashSet, fmt::{self, Display, Formatter}, mem, - time::Instant, }; -use neqo_common::{qtrace, Bytes, Encoder, Role}; +use neqo_common::{qtrace, Encoder, Role}; use neqo_transport::{Connection, StreamId}; use crate::{ @@ -96,14 +95,13 @@ impl Protocol for Session { conn: &mut Connection, events: &mut Box<dyn ExtendedConnectEvents>, control_stream_recv: &mut Box<dyn RecvStream>, - now: Instant, ) -> Res<Option<State>> { let (f, fin) = self .frame_reader - .receive::<WebTransportFrame>( - &mut StreamReaderRecvStreamWrapper::new(conn, control_stream_recv), - now, - ) + .receive::<WebTransportFrame>(&mut StreamReaderRecvStreamWrapper::new( + conn, + control_stream_recv, + )) .map_err(|_| Error::HttpGeneralProtocolStream)?; qtrace!("[{self}] Received frame: {f:?} fin={fin}"); if let Some(WebTransportFrame::CloseSession { error, message }) = f { @@ -205,7 +203,7 @@ impl Protocol for Session { // WebTransport does not add prefix (i.e. context ID). } - fn dgram_context_id(&self, datagram: Bytes) -> Result<Bytes, DgramContextIdError> { + fn dgram_context_id<'a>(&self, datagram: &'a [u8]) -> Result<&'a [u8], DgramContextIdError> { // WebTransport does not use a prefix (i.e. context ID). Ok(datagram) } diff --git a/third_party/rust/neqo-http3/src/features/extended_connect/webtransport_streams.rs b/third_party/rust/neqo-http3/src/features/extended_connect/webtransport_streams.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cell::RefCell, rc::Rc, time::Instant}; +use std::{cell::RefCell, rc::Rc}; use neqo_common::Encoder; use neqo_transport::{recv_stream, send_stream, Connection, StreamId}; @@ -53,7 +53,7 @@ impl Stream for WebTransportRecvStream { } impl RecvStream for WebTransportRecvStream { - fn receive(&mut self, _conn: &mut Connection, _now: Instant) -> Res<(ReceiveOutput, bool)> { + fn receive(&mut self, _conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { if self.session.as_ref().borrow().is_active() { self.events.data_readable(&self.stream_info); } @@ -68,12 +68,7 @@ impl RecvStream for WebTransportRecvStream { Ok(()) } - fn read_data( - &mut self, - conn: &mut Connection, - buf: &mut [u8], - _now: Instant, - ) -> Res<(usize, bool)> { + fn read_data(&mut self, conn: &mut Connection, buf: &mut [u8]) -> Res<(usize, bool)> { let (amount, fin) = conn.stream_recv(self.stream_id, buf)?; self.fin = fin; if fin { @@ -175,7 +170,7 @@ impl Stream for WebTransportSendStream { } impl SendStream for WebTransportSendStream { - fn send(&mut self, conn: &mut Connection, _now: Instant) -> Res<()> { + fn send(&mut self, conn: &mut Connection) -> Res<()> { if let WebTransportSenderStreamState::SendingInit { ref mut buf, fin } = self.state { let sent = conn.stream_send(self.stream_id, &buf[..])?; if sent == buf.len() { @@ -208,8 +203,8 @@ impl SendStream for WebTransportSendStream { self.state == WebTransportSenderStreamState::Done } - fn send_data(&mut self, conn: &mut Connection, buf: &[u8], now: Instant) -> Res<usize> { - self.send(conn, now)?; + fn send_data(&mut self, conn: &mut Connection, buf: &[u8]) -> Res<usize> { + self.send(conn)?; if self.state == WebTransportSenderStreamState::SendingData { let sent = conn.stream_send(self.stream_id, buf)?; Ok(sent) @@ -222,7 +217,7 @@ impl SendStream for WebTransportSendStream { self.set_done(close_type); } - fn close(&mut self, conn: &mut Connection, _now: Instant) -> Res<()> { + fn close(&mut self, conn: &mut Connection) -> Res<()> { if let WebTransportSenderStreamState::SendingInit { ref mut fin, .. } = self.state { *fin = true; } else { diff --git a/third_party/rust/neqo-http3/src/frames/connect_udp_frame.rs b/third_party/rust/neqo-http3/src/frames/connect_udp_frame.rs @@ -23,7 +23,6 @@ impl FrameDecoder<Self> for Frame { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::*; use crate::frames::reader::FrameDecoder; diff --git a/third_party/rust/neqo-http3/src/frames/mod.rs b/third_party/rust/neqo-http3/src/frames/mod.rs @@ -20,5 +20,4 @@ pub use reader::{FrameReader, StreamReaderConnectionWrapper, StreamReaderRecvStr pub use wtframe::WebTransportFrame; #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests; diff --git a/third_party/rust/neqo-http3/src/frames/reader.rs b/third_party/rust/neqo-http3/src/frames/reader.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cmp::min, fmt::Debug, time::Instant}; +use std::{cmp::min, fmt::Debug}; use neqo_common::{ hex_snip_middle, hex_with_len, qtrace, Decoder, IncrementalDecoderBuffer, @@ -40,7 +40,7 @@ pub trait StreamReader { /// An error may happen while reading a stream, e.g. early close, protocol error, etc. /// Return an error if the stream was closed on the transport layer, but that information is not /// yet consumed on the http/3 layer. - fn read_data(&mut self, buf: &mut [u8], now: Instant) -> Res<(usize, bool)>; + fn read_data(&mut self, buf: &mut [u8]) -> Res<(usize, bool)>; } pub struct StreamReaderConnectionWrapper<'a> { @@ -58,7 +58,7 @@ impl StreamReader for StreamReaderConnectionWrapper<'_> { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. - fn read_data(&mut self, buf: &mut [u8], _now: Instant) -> Res<(usize, bool)> { + fn read_data(&mut self, buf: &mut [u8]) -> Res<(usize, bool)> { let res = self.conn.stream_recv(self.stream_id, buf)?; Ok(res) } @@ -79,8 +79,8 @@ impl StreamReader for StreamReaderRecvStreamWrapper<'_> { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. - fn read_data(&mut self, buf: &mut [u8], now: Instant) -> Res<(usize, bool)> { - self.recv_stream.read_data(self.conn, buf, now) + fn read_data(&mut self, buf: &mut [u8]) -> Res<(usize, bool)> { + self.recv_stream.read_data(self.conn, buf) } } @@ -173,12 +173,11 @@ impl FrameReader { pub fn receive<T: FrameDecoder<T>>( &mut self, stream_reader: &mut dyn StreamReader, - now: Instant, ) -> Res<(Option<T>, bool)> { loop { let to_read = min(self.min_remaining(), self.buffer.len()); let (output, read, fin) = match stream_reader - .read_data(&mut self.buffer[..to_read], now) + .read_data(&mut self.buffer[..to_read]) .map_err(|e| Error::map_stream_recv_errors(&e))? { (0, f) => (None, false, f), diff --git a/third_party/rust/neqo-http3/src/frames/tests/mod.rs b/third_party/rust/neqo-http3/src/frames/tests/mod.rs @@ -44,10 +44,10 @@ pub fn enc_dec<T: FrameDecoder<T>>(d: &Encoder, st: &str, remaining: usize) -> T drop(conn_c.process(out.dgram(), now())); let (frame, fin) = fr - .receive::<T>( - &mut StreamReaderConnectionWrapper::new(&mut conn_c, stream_id), - now(), - ) + .receive::<T>(&mut StreamReaderConnectionWrapper::new( + &mut conn_c, + stream_id, + )) .unwrap(); assert!(!fin); assert!(frame.is_some()); diff --git a/third_party/rust/neqo-http3/src/frames/tests/reader.rs b/third_party/rust/neqo-http3/src/frames/tests/reader.rs @@ -43,10 +43,10 @@ impl FrameReaderTest { drop(self.conn_c.process(out.dgram(), now())); let (frame, fin) = self .fr - .receive::<T>( - &mut StreamReaderConnectionWrapper::new(&mut self.conn_c, self.stream_id), - now(), - ) + .receive::<T>(&mut StreamReaderConnectionWrapper::new( + &mut self.conn_c, + self.stream_id, + )) .ok()?; assert!(!fin); frame @@ -247,10 +247,10 @@ fn test_reading_frame<T: FrameDecoder<T> + PartialEq + Debug>( drop(fr.conn_c.process(out.dgram(), now())); } - let rv = fr.fr.receive::<T>( - &mut StreamReaderConnectionWrapper::new(&mut fr.conn_c, fr.stream_id), - now(), - ); + let rv = fr.fr.receive::<T>(&mut StreamReaderConnectionWrapper::new( + &mut fr.conn_c, + fr.stream_id, + )); match expected_result { FrameReadingTestExpect::Error => assert_eq!(Err(Error::HttpFrame), rv), @@ -498,10 +498,11 @@ fn frame_reading_when_stream_is_closed_before_sending_data() { drop(fr.conn_s.process(out.dgram(), now())); assert_eq!( Ok((None, true)), - fr.fr.receive::<HFrame>( - &mut StreamReaderConnectionWrapper::new(&mut fr.conn_s, fr.stream_id), - now() - ) + fr.fr + .receive::<HFrame>(&mut StreamReaderConnectionWrapper::new( + &mut fr.conn_s, + fr.stream_id + )) ); } @@ -520,9 +521,10 @@ fn wt_frame_reading_when_stream_is_closed_before_sending_data() { drop(fr.conn_s.process(out.dgram(), now())); assert_eq!( Ok((None, true)), - fr.fr.receive::<WebTransportFrame>( - &mut StreamReaderConnectionWrapper::new(&mut fr.conn_s, fr.stream_id), - now() - ) + fr.fr + .receive::<WebTransportFrame>(&mut StreamReaderConnectionWrapper::new( + &mut fr.conn_s, + fr.stream_id + )) ); } diff --git a/third_party/rust/neqo-http3/src/headers_checks.rs b/third_party/rust/neqo-http3/src/headers_checks.rs @@ -169,7 +169,6 @@ pub fn trailers_valid(headers: &[Header]) -> Res<()> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::Header; diff --git a/third_party/rust/neqo-http3/src/lib.rs b/third_party/rust/neqo-http3/src/lib.rs @@ -4,9 +4,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - /*! + # The HTTP/3 protocol This crate implements [RFC9114](https://datatracker.ietf.org/doc/html/rfc9114). @@ -159,7 +158,7 @@ mod server_events; mod settings; mod stream_type_reader; -use std::{cell::RefCell, fmt::Debug, rc::Rc, time::Instant}; +use std::{cell::RefCell, fmt::Debug, rc::Rc}; use buffered_send_stream::BufferedStream; pub use client_events::{ConnectUdpEvent, Http3ClientEvent, WebTransportEvent}; @@ -438,7 +437,7 @@ trait RecvStream: Stream { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)>; + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)>; /// # Errors /// @@ -452,12 +451,7 @@ trait RecvStream: Stream { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. - fn read_data( - &mut self, - _conn: &mut Connection, - _buf: &mut [u8], - _now: Instant, - ) -> Res<(usize, bool)> { + fn read_data(&mut self, _conn: &mut Connection, _buf: &mut [u8]) -> Res<(usize, bool)> { Err(Error::InvalidStreamId) } @@ -483,11 +477,7 @@ trait HttpRecvStream: RecvStream { /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. - fn header_unblocked( - &mut self, - conn: &mut Connection, - now: Instant, - ) -> Res<(ReceiveOutput, bool)>; + fn header_unblocked(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)>; fn maybe_update_priority(&mut self, priority: Priority) -> Res<bool>; fn priority_update_frame(&mut self) -> Option<HFrame>; @@ -554,7 +544,7 @@ trait SendStream: Stream { /// # Errors /// /// Error may occur during sending data, e.g. protocol error, etc. - fn send(&mut self, conn: &mut Connection, now: Instant) -> Res<()>; + fn send(&mut self, conn: &mut Connection) -> Res<()>; fn has_data_to_send(&self) -> bool; fn stream_writable(&self); fn done(&self) -> bool; @@ -562,12 +552,12 @@ trait SendStream: Stream { /// # Errors /// /// Error may occur during sending data, e.g. protocol error, etc. - fn send_data(&mut self, _conn: &mut Connection, _buf: &[u8], now: Instant) -> Res<usize>; + fn send_data(&mut self, _conn: &mut Connection, _buf: &[u8]) -> Res<usize>; /// # Errors /// /// It may happen that the transport stream is already closed. This is unlikely. - fn close(&mut self, conn: &mut Connection, now: Instant) -> Res<()>; + fn close(&mut self, conn: &mut Connection) -> Res<()>; /// # Errors /// @@ -577,7 +567,6 @@ trait SendStream: Stream { _conn: &mut Connection, _error: u32, _message: &str, - _now: Instant, ) -> Res<()> { Err(Error::InvalidStreamId) } @@ -592,7 +581,7 @@ trait SendStream: Stream { /// # Errors /// /// It may happen that the transport stream is already closed. This is unlikely. - fn send_data_atomic(&mut self, _conn: &mut Connection, _buf: &[u8], _now: Instant) -> Res<()> { + fn send_data_atomic(&mut self, _conn: &mut Connection, _buf: &[u8]) -> Res<()> { Err(Error::InvalidStreamId) } diff --git a/third_party/rust/neqo-http3/src/priority.rs b/third_party/rust/neqo-http3/src/priority.rs @@ -145,7 +145,6 @@ impl PriorityHandler { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use neqo_transport::StreamId; diff --git a/third_party/rust/neqo-http3/src/qlog.rs b/third_party/rust/neqo-http3/src/qlog.rs @@ -6,44 +6,42 @@ // Functions that handle capturing QLOG traces. -use std::time::Instant; - use neqo_common::qlog::Qlog; use neqo_transport::StreamId; use qlog::events::{DataRecipient, EventData}; -pub fn h3_data_moved_up(qlog: &Qlog, stream_id: StreamId, amount: usize, now: Instant) { - qlog.add_event_data_with_instant( - || { - let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved { - stream_id: Some(stream_id.as_u64()), - offset: None, - length: Some(u64::try_from(amount).expect("usize fits in u64")), - from: Some(DataRecipient::Transport), - to: Some(DataRecipient::Application), - raw: None, - }); +/// Uses [`Qlog::add_event_data_now`] instead of +/// [`Qlog::add_event_data_with_instant`], given that `now` is not available +/// on call-site. See docs on [`Qlog::add_event_data_now`] for details. +pub fn h3_data_moved_up(qlog: &Qlog, stream_id: StreamId, amount: usize) { + qlog.add_event_data_now(|| { + let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved { + stream_id: Some(stream_id.as_u64()), + offset: None, + length: Some(u64::try_from(amount).expect("usize fits in u64")), + from: Some(DataRecipient::Transport), + to: Some(DataRecipient::Application), + raw: None, + }); - Some(ev_data) - }, - now, - ); + Some(ev_data) + }); } -pub fn h3_data_moved_down(qlog: &Qlog, stream_id: StreamId, amount: usize, now: Instant) { - qlog.add_event_data_with_instant( - || { - let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved { - stream_id: Some(stream_id.as_u64()), - offset: None, - length: Some(u64::try_from(amount).expect("usize fits in u64")), - from: Some(DataRecipient::Application), - to: Some(DataRecipient::Transport), - raw: None, - }); +/// Uses [`Qlog::add_event_data_now`] instead of +/// [`Qlog::add_event_data_with_instant`], given that `now` is not available +/// on call-site. See docs on [`Qlog::add_event_data_now`] for details. +pub fn h3_data_moved_down(qlog: &Qlog, stream_id: StreamId, amount: usize) { + qlog.add_event_data_now(|| { + let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved { + stream_id: Some(stream_id.as_u64()), + offset: None, + length: Some(u64::try_from(amount).expect("usize fits in u64")), + from: Some(DataRecipient::Application), + to: Some(DataRecipient::Transport), + raw: None, + }); - Some(ev_data) - }, - now, - ); + Some(ev_data) + }); } diff --git a/third_party/rust/neqo-http3/src/qpack_decoder_receiver.rs b/third_party/rust/neqo-http3/src/qpack_decoder_receiver.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cell::RefCell, rc::Rc, time::Instant}; +use std::{cell::RefCell, rc::Rc}; use neqo_qpack as qpack; use neqo_transport::{Connection, StreamId}; @@ -34,7 +34,7 @@ impl RecvStream for DecoderRecvStream { Err(Error::HttpClosedCriticalStream) } - fn receive(&mut self, conn: &mut Connection, _now: Instant) -> Res<(ReceiveOutput, bool)> { + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { Ok(( ReceiveOutput::UnblockedStreams( self.decoder.borrow_mut().receive(conn, self.stream_id)?, diff --git a/third_party/rust/neqo-http3/src/qpack_encoder_receiver.rs b/third_party/rust/neqo-http3/src/qpack_encoder_receiver.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cell::RefCell, rc::Rc, time::Instant}; +use std::{cell::RefCell, rc::Rc}; use neqo_qpack as qpack; use neqo_transport::{Connection, StreamId}; @@ -34,10 +34,8 @@ impl RecvStream for EncoderRecvStream { Err(Error::HttpClosedCriticalStream) } - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)> { - self.encoder - .borrow_mut() - .receive(conn, self.stream_id, now)?; + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { + self.encoder.borrow_mut().receive(conn, self.stream_id)?; Ok((ReceiveOutput::NoOutput, false)) } } diff --git a/third_party/rust/neqo-http3/src/recv_message.rs b/third_party/rust/neqo-http3/src/recv_message.rs @@ -10,7 +10,6 @@ use std::{ collections::VecDeque, fmt::{self, Debug, Display, Formatter}, rc::Rc, - time::Instant, }; use neqo_common::{header::HeadersExt as _, qdebug, qinfo, qtrace, Header}; @@ -260,12 +259,7 @@ impl RecvMessage { Ok(()) } - fn receive_internal( - &mut self, - conn: &mut Connection, - post_readable_event: bool, - now: Instant, - ) -> Res<()> { + fn receive_internal(&mut self, conn: &mut Connection, post_readable_event: bool) -> Res<()> { loop { qdebug!("[{self}] state={:?}", self.state); match &mut self.state { @@ -273,10 +267,10 @@ impl RecvMessage { RecvMessageState::WaitingForResponseHeaders { frame_reader } | RecvMessageState::WaitingForData { frame_reader } | RecvMessageState::WaitingForFinAfterTrailers { frame_reader } => { - match frame_reader.receive( - &mut StreamReaderConnectionWrapper::new(conn, self.stream_id), - now, - )? { + match frame_reader.receive(&mut StreamReaderConnectionWrapper::new( + conn, + self.stream_id, + ))? { (None, true) => { break self.set_state_to_close_pending(post_readable_event); } @@ -381,8 +375,8 @@ impl Stream for RecvMessage { } impl RecvStream for RecvMessage { - fn receive(&mut self, conn: &mut Connection, now: Instant) -> Res<(ReceiveOutput, bool)> { - self.receive_internal(conn, true, now)?; + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { + self.receive_internal(conn, true)?; Ok(( ReceiveOutput::NoOutput, matches!(self.state, RecvMessageState::Closed), @@ -400,12 +394,7 @@ impl RecvStream for RecvMessage { Ok(()) } - fn read_data( - &mut self, - conn: &mut Connection, - buf: &mut [u8], - now: Instant, - ) -> Res<(usize, bool)> { + fn read_data(&mut self, conn: &mut Connection, buf: &mut [u8]) -> Res<(usize, bool)> { let mut written = 0; loop { match self.state { @@ -416,7 +405,7 @@ impl RecvStream for RecvMessage { let (amount, fin) = conn .stream_recv(self.stream_id, &mut buf[written..written + to_read]) .map_err(|e| Error::map_stream_recv_errors(&Error::from(e)))?; - qlog::h3_data_moved_up(conn.qlog_mut(), self.stream_id, amount, now); + qlog::h3_data_moved_up(conn.qlog_mut(), self.stream_id, amount); debug_assert!(amount <= to_read); *remaining_data_len -= amount; @@ -432,7 +421,7 @@ impl RecvStream for RecvMessage { self.state = RecvMessageState::WaitingForData { frame_reader: FrameReader::new(), }; - self.receive_internal(conn, false, now)?; + self.receive_internal(conn, false)?; } else { break Ok((written, false)); } @@ -452,11 +441,7 @@ impl RecvStream for RecvMessage { } impl HttpRecvStream for RecvMessage { - fn header_unblocked( - &mut self, - conn: &mut Connection, - now: Instant, - ) -> Res<(ReceiveOutput, bool)> { + fn header_unblocked(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { while let Some(p) = self.blocked_push_promise.front() { if let Some(headers) = self .qpack_decoder @@ -474,7 +459,7 @@ impl HttpRecvStream for RecvMessage { } } - self.receive(conn, now) + self.receive(conn) } fn maybe_update_priority(&mut self, priority: Priority) -> Res<bool> { diff --git a/third_party/rust/neqo-http3/src/send_message.rs b/third_party/rust/neqo-http3/src/send_message.rs @@ -10,7 +10,6 @@ use std::{ fmt::{self, Debug, Display, Formatter}, num::NonZeroUsize, rc::Rc, - time::Instant, }; use neqo_common::{qdebug, qtrace, Buffer, Encoder, Header, MessageType}; @@ -169,12 +168,12 @@ impl Stream for SendMessage { } } impl SendStream for SendMessage { - fn send_data(&mut self, conn: &mut Connection, buf: &[u8], now: Instant) -> Res<usize> { + fn send_data(&mut self, conn: &mut Connection, buf: &[u8]) -> Res<usize> { qtrace!("[{self}] send_body: len={}", buf.len()); self.state.new_data()?; - self.stream.send_buffer(conn, now)?; + self.stream.send_buffer(conn)?; if self.stream.has_buffered_data() { return Ok(0); } @@ -213,13 +212,13 @@ impl SendStream for SendMessage { data_frame.encode(&mut enc); let sent_fh = self .stream - .send_atomic(conn, enc.as_ref(), now) + .send_atomic(conn, enc.as_ref()) .map_err(|e| Error::map_stream_send_errors(&e))?; debug_assert!(sent_fh); let sent = self .stream - .send_atomic(conn, &buf[..to_send], now) + .send_atomic(conn, &buf[..to_send]) .map_err(|e| Error::map_stream_send_errors(&e))?; debug_assert!(sent); Ok(to_send) @@ -246,8 +245,8 @@ impl SendStream for SendMessage { /// `TransportStreamDoesNotExist` if the transport stream does not exist (this may happen if /// `process_output` has not been called when needed, and HTTP3 layer has not picked up the /// info that the stream has been closed.) - fn send(&mut self, conn: &mut Connection, now: Instant) -> Res<()> { - let sent = Error::map_error(self.stream.send_buffer(conn, now), Error::HttpInternal(5))?; + fn send(&mut self, conn: &mut Connection) -> Res<()> { + let sent = Error::map_error(self.stream.send_buffer(conn), Error::HttpInternal(5))?; qtrace!("[{self}] {sent} bytes sent"); if !self.stream.has_buffered_data() { @@ -274,7 +273,7 @@ impl SendStream for SendMessage { self.stream.has_buffered_data() } - fn close(&mut self, conn: &mut Connection, _now: Instant) -> Res<()> { + fn close(&mut self, conn: &mut Connection) -> Res<()> { self.state.fin()?; if !self.stream.has_buffered_data() { conn.stream_close_send(self.stream_id())?; @@ -295,13 +294,13 @@ impl SendStream for SendMessage { Some(self) } - fn send_data_atomic(&mut self, conn: &mut Connection, buf: &[u8], now: Instant) -> Res<()> { + fn send_data_atomic(&mut self, conn: &mut Connection, buf: &[u8]) -> Res<()> { let data_frame = HFrame::Data { len: buf.len() as u64, }; self.stream.encode_with(|e| data_frame.encode(e)); self.stream.buffer(buf); - _ = self.stream.send_buffer(conn, now)?; + _ = self.stream.send_buffer(conn)?; Ok(()) } } diff --git a/third_party/rust/neqo-http3/src/server.rs b/third_party/rust/neqo-http3/src/server.rs @@ -381,7 +381,6 @@ fn prepare_data( } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{ collections::HashMap, @@ -1004,7 +1003,7 @@ mod tests { Header::new("content-length", "3"), ]) .unwrap(); - stream.send_data(RESPONSE_BODY, now()).unwrap(); + stream.send_data(RESPONSE_BODY).unwrap(); data_received += 1; } Http3ServerEvent::DataWritable { .. } @@ -1052,7 +1051,7 @@ mod tests { Header::new("content-length", "3"), ]) .unwrap(); - stream.send_data(RESPONSE_BODY, now()).unwrap(); + stream.send_data(RESPONSE_BODY).unwrap(); } Http3ServerEvent::Data { .. } => { panic!("We should not have a Data event"); diff --git a/third_party/rust/neqo-http3/src/server_connection_events.rs b/third_party/rust/neqo-http3/src/server_connection_events.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, collections::VecDeque, rc::Rc}; -use neqo_common::{header::HeadersExt as _, Bytes, Header}; +use neqo_common::{header::HeadersExt as _, Header}; use neqo_transport::{AppError, StreamId}; use crate::{ @@ -64,7 +64,7 @@ pub enum WebTransportEvent { NewStream(Http3StreamInfo), Datagram { session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -81,7 +81,7 @@ pub enum ConnectUdpEvent { }, Datagram { session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -220,7 +220,7 @@ impl ExtendedConnectEvents for Http3ServerConnEvents { fn new_datagram( &self, session_id: StreamId, - datagram: Bytes, + datagram: Vec<u8>, connect_type: ExtendedConnectType, ) { let event = match connect_type { diff --git a/third_party/rust/neqo-http3/src/server_events.rs b/third_party/rust/neqo-http3/src/server_events.rs @@ -10,10 +10,9 @@ use std::{ fmt::{self, Display, Formatter}, ops::Deref, rc::Rc, - time::Instant, }; -use neqo_common::{qdebug, Bytes, Encoder, Header}; +use neqo_common::{qdebug, Encoder, Header}; use neqo_transport::{ server::ConnectionRef, AppError, Connection, DatagramTracking, StreamId, StreamType, }; @@ -75,10 +74,10 @@ impl StreamHandler { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn send_data(&self, buf: &[u8], now: Instant) -> Res<usize> { + pub fn send_data(&self, buf: &[u8]) -> Res<usize> { self.handler .borrow_mut() - .send_data(self.stream_id(), buf, &mut self.conn.borrow_mut(), now) + .send_data(self.stream_id(), buf, &mut self.conn.borrow_mut()) } /// Bytes sendable on stream at the QUIC layer. @@ -99,12 +98,10 @@ impl StreamHandler { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn stream_close_send(&self, now: Instant) -> Res<()> { - self.handler.borrow_mut().stream_close_send( - self.stream_id(), - &mut self.conn.borrow_mut(), - now, - ) + pub fn stream_close_send(&self) -> Res<()> { + self.handler + .borrow_mut() + .stream_close_send(self.stream_id(), &mut self.conn.borrow_mut()) } /// Request a peer to stop sending a stream. @@ -196,9 +193,9 @@ impl Http3OrWebTransportStream { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn send_data(&self, data: &[u8], now: Instant) -> Res<usize> { + pub fn send_data(&self, data: &[u8]) -> Res<usize> { qdebug!("[{self}] Set new response"); - self.stream_handler.send_data(data, now) + self.stream_handler.send_data(data) } /// Close sending side. @@ -206,9 +203,9 @@ impl Http3OrWebTransportStream { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn stream_close_send(&self, now: Instant) -> Res<()> { + pub fn stream_close_send(&self) -> Res<()> { qdebug!("[{self}] Set new response"); - self.stream_handler.stream_close_send(now) + self.stream_handler.stream_close_send() } } @@ -269,7 +266,7 @@ impl WebTransportRequest { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn response(&self, accept: &SessionAcceptAction, now: Instant) -> Res<()> { + pub fn response(&self, accept: &SessionAcceptAction) -> Res<()> { qdebug!("[{self}] Set a response for a WebTransport session"); self.stream_handler .handler @@ -278,7 +275,6 @@ impl WebTransportRequest { &mut self.stream_handler.conn.borrow_mut(), self.stream_handler.stream_info.stream_id(), accept, - now, ) } @@ -287,7 +283,7 @@ impl WebTransportRequest { /// It may return `InvalidStreamId` if a stream does not exist anymore. /// Also return an error if the stream was closed on the transport layer, /// but that information is not yet consumed on the http/3 layer. - pub fn close_session(&self, error: u32, message: &str, now: Instant) -> Res<()> { + pub fn close_session(&self, error: u32, message: &str) -> Res<()> { self.stream_handler .handler .borrow_mut() @@ -296,7 +292,6 @@ impl WebTransportRequest { self.stream_handler.stream_info.stream_id(), error, message, - now, ) } @@ -412,7 +407,7 @@ impl ConnectUdpRequest { /// # Errors /// /// It may return `InvalidStreamId` if a stream does not exist anymore. - pub fn response(&self, accept: &SessionAcceptAction, now: Instant) -> Res<()> { + pub fn response(&self, accept: &SessionAcceptAction) -> Res<()> { qdebug!("[{self}] Set a response for a ConnectUdp session"); self.stream_handler .handler @@ -421,7 +416,6 @@ impl ConnectUdpRequest { &mut self.stream_handler.conn.borrow_mut(), self.stream_handler.stream_info.stream_id(), accept, - now, ) } @@ -430,7 +424,7 @@ impl ConnectUdpRequest { /// It may return `InvalidStreamId` if a stream does not exist anymore. /// Also return an error if the stream was closed on the transport layer, /// but that information is not yet consumed on the http/3 layer. - pub fn close_session(&self, error: u32, message: &str, now: Instant) -> Res<()> { + pub fn close_session(&self, error: u32, message: &str) -> Res<()> { self.stream_handler .handler .borrow_mut() @@ -439,7 +433,6 @@ impl ConnectUdpRequest { self.stream_handler.stream_info.stream_id(), error, message, - now, ) } @@ -508,7 +501,7 @@ pub enum WebTransportServerEvent { NewStream(Http3OrWebTransportStream), Datagram { session: WebTransportRequest, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -525,7 +518,7 @@ pub enum ConnectUdpServerEvent { }, Datagram { session: ConnectUdpRequest, - datagram: Bytes, + datagram: Vec<u8>, }, } @@ -724,12 +717,12 @@ impl Http3ServerEvents { )); } - pub(crate) fn webtransport_datagram(&self, session: WebTransportRequest, datagram: Bytes) { + pub(crate) fn webtransport_datagram(&self, session: WebTransportRequest, datagram: Vec<u8>) { self.insert(Http3ServerEvent::WebTransport( WebTransportServerEvent::Datagram { session, datagram }, )); } - pub(crate) fn connect_udp_datagram(&self, session: ConnectUdpRequest, datagram: Bytes) { + pub(crate) fn connect_udp_datagram(&self, session: ConnectUdpRequest, datagram: Vec<u8>) { self.insert(Http3ServerEvent::ConnectUdp( ConnectUdpServerEvent::Datagram { session, datagram }, )); diff --git a/third_party/rust/neqo-http3/src/settings.rs b/third_party/rust/neqo-http3/src/settings.rs @@ -329,7 +329,6 @@ impl ZeroRttChecker for HttpZeroRttChecker { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::Encoder; diff --git a/third_party/rust/neqo-http3/src/stream_type_reader.rs b/third_party/rust/neqo-http3/src/stream_type_reader.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cmp::min, time::Instant}; +use std::cmp::min; use neqo_common::{qtrace, Decoder, IncrementalDecoderUint, Role}; use neqo_qpack::{decoder::QPACK_UNI_STREAM_TYPE_DECODER, encoder::QPACK_UNI_STREAM_TYPE_ENCODER}; @@ -230,7 +230,7 @@ impl RecvStream for NewStreamHeadReader { Ok(()) } - fn receive(&mut self, conn: &mut Connection, _now: Instant) -> Res<(ReceiveOutput, bool)> { + fn receive(&mut self, conn: &mut Connection) -> Res<(ReceiveOutput, bool)> { let t = self.get_type(conn)?; Ok(( t.map_or(ReceiveOutput::NoOutput, ReceiveOutput::NewStream), @@ -240,7 +240,6 @@ impl RecvStream for NewStreamHeadReader { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::{Encoder, Role}; use neqo_qpack::{ @@ -297,7 +296,7 @@ mod tests { let out = self.conn_s.process_output(now()); drop(self.conn_c.process(out.dgram(), now())); assert_eq!( - self.decoder.receive(&mut self.conn_c, now()).unwrap(), + self.decoder.receive(&mut self.conn_c).unwrap(), (ReceiveOutput::NoOutput, false) ); assert!(!self.decoder.done()); @@ -310,7 +309,7 @@ mod tests { } let out = self.conn_s.process_output(now()); drop(self.conn_c.process(out.dgram(), now())); - assert_eq!(&self.decoder.receive(&mut self.conn_c, now()), outcome); + assert_eq!(&self.decoder.receive(&mut self.conn_c), outcome); assert_eq!(self.decoder.done(), done); } diff --git a/third_party/rust/neqo-http3/tests/classic_connect.rs b/third_party/rust/neqo-http3/tests/classic_connect.rs @@ -26,7 +26,7 @@ fn classic_connect() { let stream_id = client .connect(now(), AUTHORITY, &[], Priority::default()) .unwrap(); - client.send_data(stream_id, b"ping", now()).unwrap(); + client.send_data(stream_id, b"ping").unwrap(); exchange_packets(&mut client, &mut server, false, None); let Some(Http3ServerEvent::Headers { headers, .. }) = server.next_event() else { @@ -56,7 +56,7 @@ fn classic_connect() { stream .send_headers(&[Header::new(":status", "200")]) .unwrap(); - stream.send_data(b"pong", now()).unwrap(); + stream.send_data(b"pong").unwrap(); exchange_packets(&mut client, &mut server, false, None); // Ignore some client events. diff --git a/third_party/rust/neqo-http3/tests/connect_udp.rs b/third_party/rust/neqo-http3/tests/connect_udp.rs @@ -84,9 +84,7 @@ fn establish_new_session() -> ( && headers.contains_header(":protocol", "connect-udp") ); - session - .response(&SessionAcceptAction::Accept, now()) - .unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); Some(session) } else { None @@ -139,7 +137,7 @@ fn exchange_packets_through_proxy( let server_dgrams = proxy.events().filter_map(|event| match event { Http3ServerEvent::ConnectUdp(ConnectUdpServerEvent::Datagram { datagram, session }) => { assert_eq!(session.stream_id(), connect_udp_session_id); - Some(Datagram::from_bytes( + Some(Datagram::new( DEFAULT_ADDR, DEFAULT_ADDR, Tos::default(), @@ -180,7 +178,7 @@ fn exchange_packets_through_proxy( }) = event { assert_eq!(session_id, connect_udp_session_id); - Some(Datagram::from_bytes( + Some(Datagram::new( DEFAULT_ADDR, DEFAULT_ADDR, Tos::default(), @@ -220,7 +218,7 @@ fn session_lifecycle(client_closes: bool) { }) .unwrap(); assert_eq!(session_id, id); - assert_eq!(&datagram, PING); + assert_eq!(datagram, PING); proxy_session.send_datagram(PONG, None).unwrap(); @@ -242,11 +240,11 @@ fn session_lifecycle(client_closes: bool) { .unwrap(); assert_eq!(session_id, id); - assert_eq!(&datagram, PONG); + assert_eq!(datagram, PONG); if client_closes { client - .connect_udp_close_session(session_id, 0, "kthxbye", now()) + .connect_udp_close_session(session_id, 0, "kthxbye") .unwrap(); exchange_packets(&mut client, &mut proxy, false, None); @@ -264,7 +262,7 @@ fn session_lifecycle(client_closes: bool) { }) .unwrap(); } else { - proxy_session.close_session(0, "kthxbye", now()).unwrap(); + proxy_session.close_session(0, "kthxbye").unwrap(); exchange_packets(&mut client, &mut proxy, false, None); @@ -389,7 +387,7 @@ fn server_datagram_before_accept() { }) .unwrap(); proxy_session - .response(&SessionAcceptAction::Accept, now()) + .response(&SessionAcceptAction::Accept) .unwrap(); let proxy_accept = proxy.process_output(now()).dgram().unwrap(); assert!(proxy.process_output(now()).dgram().is_none()); @@ -489,7 +487,7 @@ fn connect_udp_operation_on_fetch_stream() { ); assert_eq!( - client.connect_udp_close_session(fetch_stream, 0, "kthxbye", now()), + client.connect_udp_close_session(fetch_stream, 0, "kthxbye"), Err(Error::InvalidStreamId) ); } diff --git a/third_party/rust/neqo-http3/tests/httpconn.rs b/third_party/rust/neqo-http3/tests/httpconn.rs @@ -44,20 +44,20 @@ fn receive_request(server: &Http3Server) -> Option<Http3OrWebTransportStream> { None } -fn set_response(request: &Http3OrWebTransportStream, now: Instant) { +fn set_response(request: &Http3OrWebTransportStream) { request .send_headers(&[ Header::new(":status", "200"), Header::new("content-length", "3"), ]) .unwrap(); - request.send_data(RESPONSE_DATA, now).unwrap(); - request.stream_close_send(now).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); + request.stream_close_send().unwrap(); } -fn process_server_events(server: &Http3Server, now: Instant) { +fn process_server_events(server: &Http3Server) { let request = receive_request(server).unwrap(); - set_response(&request, now); + set_response(&request); } fn process_client_events(conn: &mut Http3Client) { @@ -159,12 +159,12 @@ fn fetch() { ) .unwrap(); assert_eq!(req, 0); - hconn_c.stream_close_send(req, now()).unwrap(); + hconn_c.stream_close_send(req).unwrap(); let out = hconn_c.process(dgram, now()); qtrace!("-----server"); let out = hconn_s.process(out.dgram(), now()); drop(hconn_c.process(out.dgram(), now())); - process_server_events(&hconn_s, now()); + process_server_events(&hconn_s); let out = hconn_s.process(None::<Datagram>, now()); qtrace!("-----client"); @@ -188,7 +188,7 @@ fn response_103() { ) .unwrap(); assert_eq!(req, 0); - hconn_c.stream_close_send(req, now()).unwrap(); + hconn_c.stream_close_send(req).unwrap(); let out = hconn_c.process(dgram, now()); let out = hconn_s.process(out.dgram(), now()); @@ -211,7 +211,7 @@ fn response_103() { }; assert!(hconn_c.events().any(info_headers_event)); - set_response(&request, now()); + set_response(&request); let out = hconn_s.process(None::<Datagram>, now()); drop(hconn_c.process(out.dgram(), now())); process_client_events(&mut hconn_c); @@ -240,7 +240,7 @@ fn data_writable_events_low_watermark() -> Result<(), Box<dyn std::error::Error> &[], Priority::default(), )?; - hconn_c.stream_close_send(stream_id, now())?; + hconn_c.stream_close_send(stream_id)?; exchange_packets(&mut hconn_c, &mut hconn_s, false, None); // Server receives GET and responds with headers. @@ -263,7 +263,7 @@ fn data_writable_events_low_watermark() -> Result<(), Box<dyn std::error::Error> // Have server fill entire send buffer minus 1 byte. let all_but_one = request.available()? - DATA_FRAME_HEADER_SIZE - 1; let buf = vec![1; all_but_one]; - let sent = request.send_data(&buf, now())?; + let sent = request.send_data(&buf)?; assert_eq!(sent, all_but_one); assert_eq!(request.available()?, 1); @@ -275,7 +275,7 @@ fn data_writable_events_low_watermark() -> Result<(), Box<dyn std::error::Error> // Sending more fails, given that each data frame needs to be preceded by a // header, i.e. needs more than 1 byte of send space to send 1 byte payload. assert_eq!(request.available()?, 1); - assert_eq!(request.send_data(&buf, now())?, 0); + assert_eq!(request.send_data(&buf)?, 0); // Have the client read all the pending data. let mut recv_buf = vec![0_u8; all_but_one]; @@ -316,7 +316,7 @@ fn data_writable_events() { Priority::default(), ) .unwrap(); - hconn_c.stream_close_send(req, now()).unwrap(); + hconn_c.stream_close_send(req).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); let request = receive_request(&hconn_s).unwrap(); @@ -330,7 +330,7 @@ fn data_writable_events() { // Send a lot of data let buf = &[1; DATA_AMOUNT]; - let mut sent = request.send_data(buf, now()).unwrap(); + let mut sent = request.send_data(buf).unwrap(); assert!(sent < DATA_AMOUNT); // Exchange packets and read the data on the client side. @@ -352,7 +352,7 @@ fn data_writable_events() { // Make sure we have a DataWritable event. assert!(hconn_s.events().any(data_writable)); // Data can be sent again. - let s = request.send_data(&buf[sent..], now()).unwrap(); + let s = request.send_data(&buf[sent..]).unwrap(); assert!(s > 0); sent += s; @@ -368,7 +368,7 @@ fn data_writable_events() { // One more DataWritable event. assert!(hconn_s.events().any(data_writable)); // Send more data. - let s = request.send_data(&buf[sent..], now()).unwrap(); + let s = request.send_data(&buf[sent..]).unwrap(); assert!(s > 0); sent += s; assert_eq!(sent, DATA_AMOUNT); @@ -420,7 +420,7 @@ fn zerortt() { Priority::default(), ) .unwrap(); - hconn_c.stream_close_send(req, now()).unwrap(); + hconn_c.stream_close_send(req).unwrap(); let out = hconn_c.process(dgram, now()); let out2 = hconn_c.process_output(now()); @@ -463,7 +463,7 @@ fn zerortt() { let request_stream = request_stream.unwrap(); // Send a response - set_response(&request_stream, now()); + set_response(&request_stream); // Receive the response exchange_packets(&mut hconn_c, &mut hconn_s, false, out.dgram()); @@ -491,7 +491,7 @@ fn fetch_noresponse_will_idletimeout() { ) .unwrap(); assert_eq!(req, 0); - hconn_c.stream_close_send(req, now).unwrap(); + hconn_c.stream_close_send(req).unwrap(); let _out = hconn_c.process(dgram, now); qtrace!("-----server"); diff --git a/third_party/rust/neqo-http3/tests/send_message.rs b/third_party/rust/neqo-http3/tests/send_message.rs @@ -152,7 +152,7 @@ fn send_and_receive_request( Priority::default(), ) .unwrap(); - hconn_c.stream_close_send(req, now()).unwrap(); + hconn_c.stream_close_send(req).unwrap(); exchange_packets(hconn_c, hconn_s, false, None); receive_request(hconn_s).unwrap() @@ -168,9 +168,9 @@ fn connect_send_and_receive_request() -> (Http3Client, Http3Server, Http3OrWebTr fn response_trailers1() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); send_trailers(&request).unwrap(); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -179,10 +179,10 @@ fn response_trailers1() { fn response_trailers2() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); send_trailers(&request).unwrap(); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -191,11 +191,11 @@ fn response_trailers2() { fn response_trailers3() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); send_trailers(&request).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -207,7 +207,7 @@ fn response_trailers_no_data() { exchange_packets(&mut hconn_c, &mut hconn_s, false, None); send_trailers(&request).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events_no_data(&mut hconn_c); } @@ -216,14 +216,14 @@ fn response_trailers_no_data() { fn multiple_response_trailers() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); send_trailers(&request).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); assert_eq!(send_trailers(&request), Err(Error::InvalidInput)); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -232,17 +232,14 @@ fn multiple_response_trailers() { fn data_after_trailer() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); send_trailers(&request).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); - assert_eq!( - request.send_data(RESPONSE_DATA, now()), - Err(Error::InvalidInput) - ); + assert_eq!(request.send_data(RESPONSE_DATA), Err(Error::InvalidInput)); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -251,8 +248,8 @@ fn data_after_trailer() { fn trailers_after_close() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); - request.stream_close_send(now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); + request.stream_close_send().unwrap(); assert_eq!(send_trailers(&request), Err(Error::InvalidStreamId)); @@ -270,7 +267,7 @@ fn multiple_response_headers() { Err(Error::InvalidHeader) ); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events_no_data(&mut hconn_c); } @@ -285,7 +282,7 @@ fn informational_after_response_headers() { Err(Error::InvalidHeader) ); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events_no_data(&mut hconn_c); } @@ -295,14 +292,11 @@ fn data_after_informational() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_informational_headers(&request).unwrap(); - assert_eq!( - request.send_data(RESPONSE_DATA, now()), - Err(Error::InvalidInput) - ); + assert_eq!(request.send_data(RESPONSE_DATA), Err(Error::InvalidInput)); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); - request.stream_close_send(now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -311,7 +305,7 @@ fn data_after_informational() { fn non_trailers_headers_after_data() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); assert_eq!( @@ -319,7 +313,7 @@ fn non_trailers_headers_after_data() { Err(Error::InvalidHeader) ); - request.stream_close_send(now()).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -327,14 +321,11 @@ fn non_trailers_headers_after_data() { #[test] fn data_before_headers() { let (mut hconn_c, mut hconn_s, request) = connect_send_and_receive_request(); - assert_eq!( - request.send_data(RESPONSE_DATA, now()), - Err(Error::InvalidInput) - ); + assert_eq!(request.send_data(RESPONSE_DATA), Err(Error::InvalidInput)); send_headers(&request).unwrap(); - request.send_data(RESPONSE_DATA, now()).unwrap(); - request.stream_close_send(now()).unwrap(); + request.send_data(RESPONSE_DATA).unwrap(); + request.stream_close_send().unwrap(); exchange_packets(&mut hconn_c, &mut hconn_s, false, None); process_client_events(&mut hconn_c); } @@ -344,12 +335,12 @@ fn server_send_single_udp_datagram() { let (mut hconn_c, mut hconn_s, request_1) = connect_send_and_receive_request(); send_headers(&request_1).unwrap(); - request_1.send_data(RESPONSE_DATA, now()).unwrap(); + request_1.send_data(RESPONSE_DATA).unwrap(); let request_2 = send_and_receive_request(&mut hconn_c, &mut hconn_s); // Request 1 has no pending data. This call goes straight to the QUIC layer. - request_1.stream_close_send(now()).unwrap(); + request_1.stream_close_send().unwrap(); // This adds pending data to request 2 on the HTTP/3 layer. send_headers(&request_2).unwrap(); diff --git a/third_party/rust/neqo-http3/tests/webtransport.rs b/third_party/rust/neqo-http3/tests/webtransport.rs @@ -94,9 +94,7 @@ fn create_wt_session(client: &mut Http3Client, server: &mut Http3Server) -> WebT headers.contains_header(":method", "CONNECT") && headers.contains_header(":protocol", "webtransport") ); - session - .response(&SessionAcceptAction::Accept, now()) - .unwrap(); + session.response(&SessionAcceptAction::Accept).unwrap(); wt_server_session = Some(session); } Http3ServerEvent::Data { .. } => { @@ -135,10 +133,7 @@ fn send_data_client( wt_stream_id: StreamId, data: &[u8], ) { - assert_eq!( - client.send_data(wt_stream_id, data, now()).unwrap(), - data.len() - ); + assert_eq!(client.send_data(wt_stream_id, data).unwrap(), data.len()); exchange_packets(client, server, false, None); } @@ -148,7 +143,7 @@ fn send_data_server( wt_stream: &Http3OrWebTransportStream, data: &[u8], ) { - assert_eq!(wt_stream.send_data(data, now()).unwrap(), data.len()); + assert_eq!(wt_stream.send_data(data).unwrap(), data.len()); exchange_packets(client, server, false, None); } @@ -361,7 +356,7 @@ fn wt_race_condition_server_stream_before_confirmation() { }) .expect("Should receive WebTransport session request"); wt_server_session - .response(&SessionAcceptAction::Accept, now) + .response(&SessionAcceptAction::Accept) .unwrap(); let server_accept_dgram = server .process_output(now) @@ -371,7 +366,7 @@ fn wt_race_condition_server_stream_before_confirmation() { // Server creates a stream, but hold back the UDP datagram. let wt_server_stream = wt_server_session.create_stream(StreamType::UniDi).unwrap(); - assert_eq!(wt_server_stream.send_data(&[42], now).unwrap(), 1); + assert_eq!(wt_server_stream.send_data(&[42]).unwrap(), 1); let server_stream_dgram = server .process_output(now) .dgram() @@ -464,7 +459,7 @@ fn wt_session_ok_and_wt_datagram_in_same_udp_datagram() { }) .expect("Should receive WebTransport session request"); wt_server_session - .response(&SessionAcceptAction::Accept, now) + .response(&SessionAcceptAction::Accept) .unwrap(); wt_server_session.send_datagram(b"PING", None).unwrap(); let accept_and_wt_datagram = server @@ -490,7 +485,7 @@ fn wt_session_ok_and_wt_datagram_in_same_udp_datagram() { client.events().next(), Some(Http3ClientEvent::WebTransport( WebTransportEvent::Datagram{ session_id, datagram } - )) if session_id == wt_server_session.stream_id() && &datagram == b"PING", + )) if session_id == wt_server_session.stream_id() && datagram == b"PING", ), "Should receive datagram" ); diff --git a/third_party/rust/neqo-qpack/.cargo-checksum.json b/third_party/rust/neqo-qpack/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"01d72f086015ac3fad0dd8e9e601551413adac9bea5b91151aa6d73446cd6eb8","src/decoder.rs":"1c5321b14c250bb53dc5435f0cb1b6e3c27029f3bcb149f00e1146702bc1e9ca","src/decoder_instructions.rs":"6b36eea01fdf92088ddac6b6988a239c28ddeb3cc7ecb16abf302f5d1ca8191a","src/encoder.rs":"f3e8002fdf690e820a850013fe288ba9c3279aa0034992a3547e060af8bd4f17","src/encoder_instructions.rs":"1cf1ba5ab2bbfc8f77ecfbc2bc59e40f77e12f85af5c10d0db2652000a8ff102","src/header_block.rs":"6c25b488a72864d8e0ad756af56607020b80bade8e660f701b3271d2e9d4a75f","src/huffman.rs":"c3740084c71580a5270c73cae4b7c5035fae913f533474f4a9cbc39b1f29adb7","src/huffman_decode_helper.rs":"c799b85c7738cdf6a1f6ea039062d2ea5ce0b4f08789d64e90a8712d57040d2b","src/huffman_table.rs":"aaa9ee17b8bceb47877d41fdf12fd29d49662a12db183acdb6b06c6e2ad182d9","src/lib.rs":"7b357e2ac248c392415f19b916373979272c33fa082d9158be4dd1ef5240cc1a","src/prefix.rs":"31bfb11d334a6df619bcc2720621e44a656be2514fad9033531a712d47dbe672","src/qlog.rs":"1ca9bdbc974024b32515af6b6529f5a69e80eae3f7d74445af304dc341a0eda1","src/qpack_send_buf.rs":"cec9b34cc0f2cd3a38eb15111c5f0418e31875d3ee20ecc1ed14f076da80979d","src/reader.rs":"6d698e21260d94c742b929c4112151b2ef6f2250f13564586e0ca0b9082115b5","src/static_table.rs":"6e5ec26e2b6bd63375d2d77e72748151d430d1629a8e497ec0d0ea21c078524a","src/stats.rs":"cb01723249f60e15a5cd7efd9cbab409fddc588d1df655ed06ba8c80e3d5d28e","src/table.rs":"f19b3016bffee54f8e3f52034e2eb36fc8f83a04b203074a8d4cec65367d3c32"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"560152ae2f0a82c5351f606551d856a71df0409a9a28249b234361995c0a980a","src/decoder.rs":"65d73d1d871640b32fe1604cf5da59a3a313b86836d4392510fd1b16c6746b2c","src/decoder_instructions.rs":"f6afa2c7a0c105d2b70f1595563b1b98c3f841bd20d9d29c44f4fa260c4587a5","src/encoder.rs":"1b215a06b4e338095494200b1e024e6dfc432c29e6e7971b37c058274e482e67","src/encoder_instructions.rs":"04723b0219836e31b52d80968c599daf8818fa6436c204e365e774acfa238bcf","src/header_block.rs":"96801a554082f6f9b44880ae45a972dbebaccb705752633bb6d005b610c56804","src/huffman.rs":"e9ad617f3973a7779d594b69f32416aaea0f6422f24e0051bcc623e9e3adf9bf","src/huffman_decode_helper.rs":"c799b85c7738cdf6a1f6ea039062d2ea5ce0b4f08789d64e90a8712d57040d2b","src/huffman_table.rs":"aaa9ee17b8bceb47877d41fdf12fd29d49662a12db183acdb6b06c6e2ad182d9","src/lib.rs":"5a939473062c0a6e1c46ae31814b958763c0896d9a1e71dcb691425b470fd9a4","src/prefix.rs":"31bfb11d334a6df619bcc2720621e44a656be2514fad9033531a712d47dbe672","src/qlog.rs":"9b1d880bf29f6245e1af02cefa0d4aceba10cb10f457c78f3041197d789e8e14","src/qpack_send_buf.rs":"e0d1001e565e8f8bdbb047da9db1016d8f6396ce0c0a67705a89e26ea130622c","src/reader.rs":"a1a107780d75a84b399da2d76da698dcc39c308660f56b62253d3314e2fe96f6","src/static_table.rs":"6e5ec26e2b6bd63375d2d77e72748151d430d1629a8e497ec0d0ea21c078524a","src/stats.rs":"cb01723249f60e15a5cd7efd9cbab409fddc588d1df655ed06ba8c80e3d5d28e","src/table.rs":"926a616160589b9e6cd80dcf18fba6cae3de6ae770836434a500e90dedb134c5"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-qpack/Cargo.toml b/third_party/rust/neqo-qpack/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-qpack" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = false autolib = false @@ -46,7 +46,6 @@ ignored = ["log"] bench = [ "neqo-common/bench", "neqo-transport/bench", - "log/release_max_level_info", ] [lib] @@ -108,7 +107,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -116,8 +114,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -170,8 +166,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-qpack/src/decoder.rs b/third_party/rust/neqo-qpack/src/decoder.rs @@ -276,7 +276,6 @@ fn map_error(err: &Error) -> Error { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::Header; use neqo_transport::{StreamId, StreamType}; diff --git a/third_party/rust/neqo-qpack/src/decoder_instructions.rs b/third_party/rust/neqo-qpack/src/decoder_instructions.rs @@ -141,7 +141,6 @@ impl DecoderInstructionReader { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use neqo_transport::StreamId; diff --git a/third_party/rust/neqo-qpack/src/encoder.rs b/third_party/rust/neqo-qpack/src/encoder.rs @@ -8,7 +8,6 @@ use std::{ cmp::min, collections::VecDeque, fmt::{self, Display, Formatter}, - time::Instant, }; use neqo_common::{qdebug, qerror, qlog::Qlog, qtrace, Header}; @@ -127,22 +126,17 @@ impl Encoder { /// /// May return: `ClosedCriticalStream` if stream has been closed or `DecoderStream` /// in case of any other transport error. - pub fn receive(&mut self, conn: &mut Connection, stream_id: StreamId, now: Instant) -> Res<()> { - self.read_instructions(conn, stream_id, now) + pub fn receive(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<()> { + self.read_instructions(conn, stream_id) .map_err(|e| map_error(&e)) } - fn read_instructions( - &mut self, - conn: &mut Connection, - stream_id: StreamId, - now: Instant, - ) -> Res<()> { + fn read_instructions(&mut self, conn: &mut Connection, stream_id: StreamId) -> Res<()> { qdebug!("[{self}] read a new instruction"); loop { let mut recv = ReceiverConnWrapper::new(conn, stream_id); match self.instruction_reader.read_instructions(&mut recv) { - Ok(instruction) => self.call_instruction(instruction, conn.qlog_mut(), now)?, + Ok(instruction) => self.call_instruction(instruction, conn.qlog_mut())?, Err(Error::NeedMoreData) => break Ok(()), Err(e) => break Err(e), } @@ -222,12 +216,7 @@ impl Encoder { } } - fn call_instruction( - &mut self, - instruction: DecoderInstruction, - qlog: &Qlog, - now: Instant, - ) -> Res<()> { + fn call_instruction(&mut self, instruction: DecoderInstruction, qlog: &Qlog) -> Res<()> { qdebug!("[{self}] call instruction {instruction:?}"); match instruction { DecoderInstruction::InsertCountIncrement { increment } => { @@ -235,7 +224,6 @@ impl Encoder { qlog, increment, &increment.to_be_bytes(), - now, ); self.insert_count_instruction(increment) @@ -549,10 +537,7 @@ fn map_stream_send_atomic_error(err: &TransportError) -> Error { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { - use std::time::Instant; - use neqo_transport::{ConnectionParameters, StreamId, StreamType}; use test_fixture::{ default_client, default_server, handshake, new_server, now, CountingConnectionIdGenerator, @@ -658,16 +643,16 @@ mod tests { connect_generic(true, Some(max_data)) } - fn recv_instruction(encoder: &mut TestEncoder, decoder_instruction: &[u8], now: Instant) { + fn recv_instruction(encoder: &mut TestEncoder, decoder_instruction: &[u8]) { encoder .peer_conn .stream_send(encoder.recv_stream_id, decoder_instruction) .unwrap(); - let out = encoder.peer_conn.process_output(now); - drop(encoder.conn.process(out.dgram(), now)); + let out = encoder.peer_conn.process_output(now()); + drop(encoder.conn.process(out.dgram(), now())); assert!(encoder .encoder - .read_instructions(&mut encoder.conn, encoder.recv_stream_id, now) + .read_instructions(&mut encoder.conn, encoder.recv_stream_id) .is_ok()); } @@ -927,7 +912,7 @@ mod tests { encoder.send_instructions(&[]); // receive an insert count increment. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // insert "content-length: 12345 again it will succeed. let res = @@ -958,7 +943,7 @@ mod tests { encoder.send_instructions(HEADER_CONTENT_LENGTH_VALUE_1_NAME_LITERAL); // receive an insert count increment. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // send a header block let buf = encoder.encoder.encode_header_block( @@ -980,10 +965,10 @@ mod tests { if wait == 0 { // receive a header_ack. - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1); } else { // receive a stream canceled - recv_instruction(&mut encoder, STREAM_CANCELED_ID_1, now()); + recv_instruction(&mut encoder, STREAM_CANCELED_ID_1); } // insert "content-length: 12345 again it will succeed. @@ -1204,7 +1189,7 @@ mod tests { assert_eq!(encoder.encoder.blocked_stream_cnt(), 1); // receive a header_ack for the first header block. - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1); // The stream is still blocking because the second header block is not acked. assert_eq!(encoder.encoder.blocked_stream_cnt(), 1); @@ -1244,7 +1229,7 @@ mod tests { assert_eq!(encoder.encoder.blocked_stream_cnt(), 1); // receive a header_ack for the first header block. - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1); // The stream is not blocking anymore because header ack also ACKs the instruction. assert_eq!(encoder.encoder.blocked_stream_cnt(), 0); @@ -1284,7 +1269,7 @@ mod tests { assert_eq!(encoder.encoder.blocked_stream_cnt(), 2); // receive a header_ack for the second header block. This will ack the first as well - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_2, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_2); // The stream is not blocking anymore because header ack also ACKs the instruction. assert_eq!(encoder.encoder.blocked_stream_cnt(), 0); @@ -1326,7 +1311,7 @@ mod tests { // receive a stream cancel for the first stream. // This will remove the first stream as blocking but it will not mark the instruction as // acked. and the second steam will still be blocking. - recv_instruction(&mut encoder, STREAM_CANCELED_ID_1, now()); + recv_instruction(&mut encoder, STREAM_CANCELED_ID_1); // The stream is not blocking anymore because header ack also ACKs the instruction. assert_eq!(encoder.encoder.blocked_stream_cnt(), 1); @@ -1378,7 +1363,7 @@ mod tests { // stream 1 is block on entries 1 and 2; stream 2 is block only on 1. // receive an Insert Count Increment for the first entry. // After that only stream 1 will be blocking. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); assert_eq!(encoder.encoder.blocked_stream_cnt(), 1); } @@ -1415,13 +1400,13 @@ mod tests { assert!(encoder.change_capacity(10).is_err()); // receive an Insert Count Increment for the entry. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // trying to evict the entry will failed. The stream is still referring to it. assert!(encoder.change_capacity(10).is_err()); // receive a header_ack for the header block. - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1); // now entry can be evicted. assert!(encoder.change_capacity(10).is_ok()); @@ -1459,13 +1444,13 @@ mod tests { assert!(encoder.change_capacity(10).is_err()); // receive an Insert Count Increment for the entry. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // trying to evict the entry will failed. The stream is still referring to it. assert!(encoder.change_capacity(10).is_err()); // receive a stream cancelled. - recv_instruction(&mut encoder, STREAM_CANCELED_ID_1, now()); + recv_instruction(&mut encoder, STREAM_CANCELED_ID_1); // now entry can be evicted. assert!(encoder.change_capacity(10).is_ok()); @@ -1495,7 +1480,7 @@ mod tests { assert!(encoder.change_capacity(10).is_err()); // receive an Insert Count Increment for the entry. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // now entry can be evicted. assert!(encoder.change_capacity(10).is_ok()); @@ -1534,7 +1519,7 @@ mod tests { assert!(encoder.change_capacity(10).is_err()); // receive a header_ack for the header block. This will also ack the instruction. - recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1, now()); + recv_instruction(&mut encoder, HEADER_ACK_STREAM_ID_1); // now entry can be evicted. assert!(encoder.change_capacity(10).is_ok()); @@ -1571,7 +1556,6 @@ mod tests { ); // Assert that the first header is encoded as an index to the dynamic table (a post form). - assert!(buf1.len() > 3); assert_eq!(buf1[2], 0x10); // Assert that the second header is encoded as a literal with a name literal assert_eq!(buf1[3] & 0xf0, 0x20); @@ -1606,7 +1590,6 @@ mod tests { StreamId::new(3), ); // Assert that the first header is encoded as an index to the dynamic table (a post form). - assert!(buf3.len() > 3); assert_eq!(buf3[2], 0x10); // Assert that the second header is encoded as a literal with a name literal assert_eq!(buf3[3] & 0xf0, 0x20); @@ -1643,7 +1626,7 @@ mod tests { let out = encoder.conn.process_output(now()); drop(encoder.peer_conn.process(out.dgram(), now())); // receive an insert count increment. - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); // The first header will use the table entry and the second will use the literal // encoding because the first entry is referred to and cannot be evicted. @@ -1692,8 +1675,8 @@ mod tests { ); // receive a stream canceled instruction. - recv_instruction(&mut encoder, STREAM_CANCELED_ID_1, now()); + recv_instruction(&mut encoder, STREAM_CANCELED_ID_1); - recv_instruction(&mut encoder, &[0x01], now()); + recv_instruction(&mut encoder, &[0x01]); } } diff --git a/third_party/rust/neqo-qpack/src/encoder_instructions.rs b/third_party/rust/neqo-qpack/src/encoder_instructions.rs @@ -294,7 +294,6 @@ impl EncoderInstructionReader { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use super::{Data, EncoderInstruction, EncoderInstructionReader}; diff --git a/third_party/rust/neqo-qpack/src/header_block.rs b/third_party/rust/neqo-qpack/src/header_block.rs @@ -394,7 +394,6 @@ impl<'a> HeaderDecoder<'a> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{HeaderDecoder, HeaderDecoderResult, HeaderEncoder, HeaderTable}; diff --git a/third_party/rust/neqo-qpack/src/huffman.rs b/third_party/rust/neqo-qpack/src/huffman.rs @@ -161,7 +161,6 @@ pub fn encode(input: &[u8]) -> Vec<u8> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{decode, encode, Error}; diff --git a/third_party/rust/neqo-qpack/src/lib.rs b/third_party/rust/neqo-qpack/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - pub mod decoder; mod decoder_instructions; pub mod encoder; diff --git a/third_party/rust/neqo-qpack/src/qlog.rs b/third_party/rust/neqo-qpack/src/qlog.rs @@ -6,37 +6,30 @@ // Functions that handle capturing QLOG traces. -use std::time::Instant; - use neqo_common::{hex, qlog::Qlog}; use qlog::events::{ qpack::{QPackInstruction, QpackInstructionParsed, QpackInstructionTypeName}, EventData, RawInfo, }; -pub fn qpack_read_insert_count_increment_instruction( - qlog: &Qlog, - increment: u64, - data: &[u8], - now: Instant, -) { - qlog.add_event_data_with_instant( - || { - let raw = RawInfo { - length: Some(8), - payload_length: None, - data: Some(hex(data)), - }; - let ev_data = EventData::QpackInstructionParsed(QpackInstructionParsed { - instruction: QPackInstruction::InsertCountIncrementInstruction { - instruction_type: QpackInstructionTypeName::InsertCountIncrementInstruction, - increment, - }, - raw: Some(raw), - }); +/// Uses [`Qlog::add_event_data_now`] instead of +/// [`Qlog::add_event_data_with_instant`], given that `now` is not available +/// on call-site. See docs on [`Qlog::add_event_data_now`] for details. +pub fn qpack_read_insert_count_increment_instruction(qlog: &Qlog, increment: u64, data: &[u8]) { + qlog.add_event_data_now(|| { + let raw = RawInfo { + length: Some(8), + payload_length: None, + data: Some(hex(data)), + }; + let ev_data = EventData::QpackInstructionParsed(QpackInstructionParsed { + instruction: QPackInstruction::InsertCountIncrementInstruction { + instruction_type: QpackInstructionTypeName::InsertCountIncrementInstruction, + increment, + }, + raw: Some(raw), + }); - Some(ev_data) - }, - now, - ); + Some(ev_data) + }); } diff --git a/third_party/rust/neqo-qpack/src/qpack_send_buf.rs b/third_party/rust/neqo-qpack/src/qpack_send_buf.rs @@ -104,7 +104,6 @@ impl Deref for Data { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::{Data, Prefix}; diff --git a/third_party/rust/neqo-qpack/src/reader.rs b/third_party/rust/neqo-qpack/src/reader.rs @@ -335,7 +335,6 @@ pub fn parse_utf8(v: &[u8]) -> Res<&str> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] pub(crate) mod test_receiver { use std::collections::VecDeque; @@ -377,7 +376,6 @@ pub(crate) mod test_receiver { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use test_receiver::TestReceiver; @@ -422,7 +420,6 @@ mod tests { #[test] fn read_prefixed_int_slow_writer() { let (buf, prefix_len, value) = &TEST_CASES_NUMBERS[4]; - assert!(buf.len() > 1); let mut reader = IntReader::new(buf[0], *prefix_len); let mut test_receiver: TestReceiver = TestReceiver::default(); diff --git a/third_party/rust/neqo-qpack/src/table.rs b/third_party/rust/neqo-qpack/src/table.rs @@ -383,7 +383,6 @@ impl HeaderTable { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use super::*; diff --git a/third_party/rust/neqo-transport/.cargo-checksum.json b/third_party/rust/neqo-transport/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"18d6d094175cae157be8f05543dd2b2d9347d2817894a8596865b1ec0647e333","benches/min_bandwidth.rs":"73f9a222b9eb8edac291d1957df61a516bb9491fa6bd81a4cb5546184b76b94d","benches/range_tracker.rs":"37a921fa4aa6375ff9cb785adde24df537a18ab624afda6478bbf848c58b0e8d","benches/rx_stream_orderer.rs":"a40e50b0f4e28465b1b65ebcf95570a116c2635eea790d4196fb73f1b3977e63","benches/sent_packets.rs":"aa9f67da4cd54bca1f69030ed3359ee0c77b31e07a586d59ece933d11fcc88b3","benches/transfer.rs":"de2c47025256db1d9af3622b52a5232f7c36683605b273db16089d3bd9c28aac","build.rs":"78ec79c93bf13c3a40ceef8bba1ea2eada61c8f2dfc15ea7bf117958d367949c","src/ackrate.rs":"08f7f4777b7ac1ec85afb4c8cd1cab99a39bd2cb023628193e99325c8c0e34e2","src/addr_valid.rs":"1290915bae733962952f8f92300593587dc4372fce3520dedfe05e51e533275a","src/cc/classic_cc.rs":"f34b06504e030225b3c024d4d7c149cd643950326cd7b28ce8a44c53d4a9b961","src/cc/cubic.rs":"d33721578a236c3cad13410b1baac33439f1bab70e826211341ecb19e2976764","src/cc/mod.rs":"af7b073e05769c2dee7a7f1346c4287ed498c9fb276f03eed49a151b86aed20d","src/cc/new_reno.rs":"278e6caa6164e69a30e84f1eb32358d5f4fac05a05addfa129cc6006c1e856c9","src/cc/tests/cubic.rs":"e6121b610a9e18463ae7d38a933db2f1151ce873586fcf4d67ad985e0f2a41ff","src/cc/tests/mod.rs":"017bf402a9a8c71b5c43343677635644babb57a849d81d0affc328b4b4b9cebb","src/cc/tests/new_reno.rs":"34899c87b6175fe9bf8d0f3f9bb1164a0fbab1f9435840f07f56e21ca467762f","src/cid.rs":"caf814af49d25891a9b79e1f97c741fac41d4062c3e923e4b0e0d5ed0d471077","src/connection/idle.rs":"7fffb026530f17604ac41b28c71cf3b3554e6b1958db96436478d9332b65217c","src/connection/mod.rs":"23e9d68604da238427f0b19d0058a00021e6661253d089a17e0077765d565249","src/connection/params.rs":"c15fbdf4ad42487d6a93285529f6fb74d854d338df236ae75ca9b5e4a27f887c","src/connection/state.rs":"76d1bbe9b6230c88ff948b631feefd9b1e556d57fc5e3eee4f2e7e4151278c20","src/connection/test_internal.rs":"25814d143b745c50c67708cd82aeecbc1e6f123e067b69c5021b9ba653c0c6c2","src/connection/tests/ackrate.rs":"4b7325b5798817d971c14f76ca79c1d7f677aee8e579c97623f49eb87727bd6f","src/connection/tests/cc.rs":"7b113bb1713d440a03bf34bcd42b146dd201c2110140650ee1d98b136d7cec48","src/connection/tests/close.rs":"4c266cf15fe2ad2ae3a7ef77e44586ec5cc6c3c79239184fcf32dd67146ec810","src/connection/tests/datagram.rs":"38e76aaf790d9091e0c50fb875458e8702cae904619c37cfff8fda5e4fb04448","src/connection/tests/ecn.rs":"df46cc993abb99d8d7a2187bb80bc5528763929ee1a888db5a0f53069c9d60bd","src/connection/tests/handshake.rs":"aa55e7bfb03fad6b813709a2874d5c92b2d4e5797f25fb671d7d4e898837716e","src/connection/tests/idle.rs":"903c3b45b89df9bd7cefa216e58df09f24e9f6a5b42b6de2762a5b737f7c7632","src/connection/tests/keys.rs":"c3f93b5410d1b402901d8d18bfbf673fd4ca473136ac2777ede61bdd94e7e29c","src/connection/tests/migration.rs":"c8abfd6577662b7b549b004173fb3d2ab2499a1974f576e92c5e124c31ecf754","src/connection/tests/mod.rs":"5613c937845552291d70811120135ea3c57534fcac0d0ca4f3c0402fd0256c84","src/connection/tests/null.rs":"d39d34c895c40ea88bcc137cba43c34386ef9759c6f66f3487ffd41a5099feb8","src/connection/tests/pmtud.rs":"e9ea01eaf021720ebd656e49c94bb7665e624609dd6914cbf8299d71b9a2291f","src/connection/tests/priority.rs":"00fb90881299fb93b9ad628840585852422676a6db0dbeee348a51ea3029456d","src/connection/tests/recovery.rs":"f3d148f48c7d67982fdf6a1f30428efbc39859d2d51c9d0698fbb0e4d350013c","src/connection/tests/resumption.rs":"93ec8439d8cc05df77e21566b06c2948ab7ea4e8c7518228de328bc19a88815b","src/connection/tests/stream.rs":"771296f838e06337bf7e7b29b14fe68c99e31b21dc028da75b2f337c576158d4","src/connection/tests/vn.rs":"a2e69ad687ebc433e849c6dbb125eec25e5ac2a4f3945af94d9ef04034d2b1fb","src/connection/tests/zerortt.rs":"94a5a705283c31f50f68a74c49d4bba4ba2a51d8122d9e50a14a831a902f8578","src/crypto.rs":"9cb60f094f3c8051e1b0048648e19cda3e642592bc813716a55ecfb8216a3d2f","src/ecn.rs":"66411888a79d3fbe7445418cafcc1ad7c1ca2a466341fb8de6240ff2cef25a77","src/events.rs":"17cff113f464cf44d49a6a1f958a6d709252657ac6d6c0bad73ef1fdfc2e061b","src/fc.rs":"fc37c8cb9cf35657810f104b7803b7951633e8d97bc5fbb88749229abac978fd","src/frame.rs":"caad40490f7f12e4b6eed911a7525468bdda74af504deb3c1f6a1414dae1c18b","src/lib.rs":"51b26e65e15e0f1e25db6e2761f8dfc7b0d0100d6b8b0fbf62ea610144abc9a5","src/pace.rs":"e6be7801d2e4ee0c4883716564a3717a3bf14e9782c9fc1470d78ed78c50ead7","src/packet/metadata.rs":"7a3f520af2932e1ba26197df37bcc706293600cf94c7b559a5192a6f05f6b728","src/packet/mod.rs":"d9500d8972e0b9df85e5c834f515812e117c0b2abe915cbed43b5d0b366c3d95","src/packet/retry.rs":"df1c7874ff3d3c478ca95a6c7adcb9b1d988894bf6467cee9afe9607ef0a7a20","src/path.rs":"d1b9c08d82153f7bdc331ee1c8f8642b1938a248dd515eefb42113a65dd4eceb","src/pmtud.rs":"ecbcad8aa2262672271612fa984c183ebbd5a8b859a1fd23fc377656a4eb33b0","src/qlog.rs":"e5a0a93f19959b235dab7f741b088d4a37aabde62b18d54493eac1418bae6321","src/quic_datagrams.rs":"fd2a665f1febc211571cb4505729f1639eb4b76e8f1a0588749c16f2b646fd5e","src/recovery/mod.rs":"25fcbd567d3a8f77cfbcb8ecbcc26a84d2cf4b8ccf85321c8b17a692dad1d1c8","src/recovery/sent.rs":"c84643c5929c3a8db954500fc859054cfc19770c851354152ddfce292d0be28c","src/recovery/token.rs":"667c827df3d321ee61689e6cda78d9c27656525ab2978282754a78b2370a9a2f","src/recv_stream.rs":"019664ee7b77c679a8ce6fb3743b86fb0da66eb9ddd527baba6aaf967c423722","src/rtt.rs":"ab74c7618f1c200c095bb6f9feda5e8e164738de9196561673d0ea52e7117c90","src/saved.rs":"55c0d1c415079138674974a46d8c6ecbcda49ce4070bf0920286b1401c161078","src/send_stream.rs":"941616ce02608d9a9278f07eda8231a9dda3c9e8b2a2c9e6c6c7bcd1531e3f9a","src/sender.rs":"d49b4d014e27b7120e0c3edc3ce43edbc25acea8394cd7cf15e460cf25cde225","src/server.rs":"bda1165f157cfdc4c7b9a02f8e2c32775cdb6a8b2962ee2524ae242869e378e6","src/sni.rs":"34361fd7a19fa7c8b33519ba1bdefc32a2cadec0b9cbcf1073a2e75f0c1730ae","src/stats.rs":"1e7a212af18c86093e6e25a76c806da701a6bb5c42c61d67b0af8a3ddef426da","src/stream_id.rs":"a6a44d6f02967feeed3250dadc658861f20e00373a0f239685776b2fa72a59e4","src/streams.rs":"17bea7b2f899e096f7a72aeafb74349f27cebc655ff6d304226f1006e90fe024","src/tparams.rs":"0c401dc2d825150b804690d64b2b0e75de22026f876af140a6dd3abf5c88f896","src/tracking.rs":"f81786cf0cdbc84e5e4c196e0e575a1a465928160a0c9c0ecd4896213eefbe55","src/version.rs":"76b8d3ec0464a749849280756b5acd243543e8cb43185936802ba552a207aeca","tests/common/mod.rs":"d1f96c024543cab68d09e2847990ffdf83568835c6ac740bf9cb765e7a661e1d","tests/conn_vectors.rs":"0e4a1b92c02b527842c127b789e70f6c4372c2b61b1a59a8e695f744ce155e2a","tests/connection.rs":"db4ef75e8e73e2c67307f9c445c7a89bdf4b048b1b69ab86e0c39d8ffe4280ae","tests/network.rs":"2173d8347543d457a236817d219d2865315dbd005e1d19c2277e3a34d5cca759","tests/retry.rs":"0343ac640ea785655678f8d66ef5ce7c95b8dc584065ae1d606293a0860cb92b","tests/server.rs":"2dc921b4973d6c7875cd52874857526873d4cbcf5ebc2b2a60debcde7791bf4c","tests/sni.rs":"5cf5c6ec0601712596fdfd589eb346af599e45c80849adf31879ba4ba3640f38","tests/stats.rs":"af8c1da46e984b55b172118aff4ad33be2375443f405e297d40981e65eb4d0cf"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"96d4214d35b2dac2ab505b38acc3e897a8b1a77b02043e4e695c6ef81daa5302","benches/min_bandwidth.rs":"73f9a222b9eb8edac291d1957df61a516bb9491fa6bd81a4cb5546184b76b94d","benches/range_tracker.rs":"37a921fa4aa6375ff9cb785adde24df537a18ab624afda6478bbf848c58b0e8d","benches/rx_stream_orderer.rs":"a40e50b0f4e28465b1b65ebcf95570a116c2635eea790d4196fb73f1b3977e63","benches/sent_packets.rs":"aa9f67da4cd54bca1f69030ed3359ee0c77b31e07a586d59ece933d11fcc88b3","benches/transfer.rs":"de2c47025256db1d9af3622b52a5232f7c36683605b273db16089d3bd9c28aac","build.rs":"78ec79c93bf13c3a40ceef8bba1ea2eada61c8f2dfc15ea7bf117958d367949c","src/ackrate.rs":"08f7f4777b7ac1ec85afb4c8cd1cab99a39bd2cb023628193e99325c8c0e34e2","src/addr_valid.rs":"2cd83617dbe30dc4a1dd6acb6cf8dabe5b71ca84705fd4173d3c4756b27e0c0a","src/cc/classic_cc.rs":"876aadcee445a829c8b355a13443302c137f6df7ecb2479f059018433027282d","src/cc/cubic.rs":"58506f1dfd2b816ce0b7e8d3f11f84f9959c9dd56a6e68203f5b6179473ac6cc","src/cc/mod.rs":"0ae30886247c845dcb86aeb18195e0c710ac4aeb8c21d532aaf02713c01b82fd","src/cc/new_reno.rs":"278e6caa6164e69a30e84f1eb32358d5f4fac05a05addfa129cc6006c1e856c9","src/cc/tests/cubic.rs":"6060ffda33984c78b0cdee0c9d8be6f09d443a8123aff3314de6ce0075a30cb6","src/cc/tests/mod.rs":"017bf402a9a8c71b5c43343677635644babb57a849d81d0affc328b4b4b9cebb","src/cc/tests/new_reno.rs":"34899c87b6175fe9bf8d0f3f9bb1164a0fbab1f9435840f07f56e21ca467762f","src/cid.rs":"e2770b78f664f44490257fe8ea98bdea2a813ff586d4147fca9f55dac4889ac3","src/connection/idle.rs":"7fffb026530f17604ac41b28c71cf3b3554e6b1958db96436478d9332b65217c","src/connection/mod.rs":"1a2b9e91dd1186af5c75a4df99117c1baefa125821eacb5f8a7ec6214e2bae8c","src/connection/params.rs":"aec63d00e7ffecba0b19ad897a30da889db4db2921928efbe1ba0a2268920944","src/connection/state.rs":"76d1bbe9b6230c88ff948b631feefd9b1e556d57fc5e3eee4f2e7e4151278c20","src/connection/test_internal.rs":"25814d143b745c50c67708cd82aeecbc1e6f123e067b69c5021b9ba653c0c6c2","src/connection/tests/ackrate.rs":"4b7325b5798817d971c14f76ca79c1d7f677aee8e579c97623f49eb87727bd6f","src/connection/tests/cc.rs":"f8d1300587d43f1ed8b51c0902b665461f67d4f7862fc4772f5dff7261f27772","src/connection/tests/close.rs":"4c266cf15fe2ad2ae3a7ef77e44586ec5cc6c3c79239184fcf32dd67146ec810","src/connection/tests/datagram.rs":"bf5f23394a3559ab18f3c05aeee91288f0210ac69ffcd32cb03107f266d0a751","src/connection/tests/ecn.rs":"df46cc993abb99d8d7a2187bb80bc5528763929ee1a888db5a0f53069c9d60bd","src/connection/tests/handshake.rs":"ec2cd90eb39ffc40dfcb7d758016f5eca3354cae9cbe993a37980f187180bca4","src/connection/tests/idle.rs":"9eb6abbf50abd1fe56a60e082a5603a150741a7d355089575f99d2abf61fa94e","src/connection/tests/keys.rs":"c3f93b5410d1b402901d8d18bfbf673fd4ca473136ac2777ede61bdd94e7e29c","src/connection/tests/migration.rs":"c8abfd6577662b7b549b004173fb3d2ab2499a1974f576e92c5e124c31ecf754","src/connection/tests/mod.rs":"c3f95c3af400ca4460a38f129cf56cd4c4e1f834e04b63c474804b0c1ee8cf44","src/connection/tests/null.rs":"d39d34c895c40ea88bcc137cba43c34386ef9759c6f66f3487ffd41a5099feb8","src/connection/tests/pmtud.rs":"e9ea01eaf021720ebd656e49c94bb7665e624609dd6914cbf8299d71b9a2291f","src/connection/tests/priority.rs":"00fb90881299fb93b9ad628840585852422676a6db0dbeee348a51ea3029456d","src/connection/tests/recovery.rs":"695e87e014f036a4f93da6b786776275a947b9e5fd65c6e8e9a2b0cc4f8f9bd2","src/connection/tests/resumption.rs":"8ee76b73fd5a0799a7c38221caa54d4b1543563e86b517b6d47394120cb989d4","src/connection/tests/stream.rs":"771296f838e06337bf7e7b29b14fe68c99e31b21dc028da75b2f337c576158d4","src/connection/tests/vn.rs":"a2e69ad687ebc433e849c6dbb125eec25e5ac2a4f3945af94d9ef04034d2b1fb","src/connection/tests/zerortt.rs":"94a5a705283c31f50f68a74c49d4bba4ba2a51d8122d9e50a14a831a902f8578","src/crypto.rs":"2ef694a233eac5269c30f6e1bc0104c0993c99bb5deeb675b585cc58ed54f593","src/ecn.rs":"fed6a2ff767018f25be8f9649208cf82b6339b4efd56cbc17503610786522ece","src/events.rs":"23829dc80dbf30510f99d317eb4e9c205ad9100b1268ff40d00ea0768a3e5fe9","src/fc.rs":"ebb5206b1dcc75f148f83dd1da68ff76ab632618b2ae61b810a19a14b9972cff","src/frame.rs":"f711125ca1dddbab1e6738186bd2b32e1388ae3ecb3676b9f7dea4bb6ceb76d3","src/lib.rs":"1365149b2bbcb5f6836cbc8f1520a8d68c1b69907f310b6ba289a6eb4bacb16a","src/pace.rs":"a6c6754a21b59b7955a570162f12015bdc65c5f0e497ce650062a5a92d5abb06","src/packet/metadata.rs":"7a3f520af2932e1ba26197df37bcc706293600cf94c7b559a5192a6f05f6b728","src/packet/mod.rs":"3f7d57d69ddfd0c30945123d69f5fb6f35b80d2eb3e4da0b42f3ee01a4978f37","src/packet/retry.rs":"1aa9ed711a587a626e40d01539c754d2941e9bcc00f82b7a7ffe9af3ef5eb4b3","src/path.rs":"d1b9c08d82153f7bdc331ee1c8f8642b1938a248dd515eefb42113a65dd4eceb","src/pmtud.rs":"4e2d779d1e217c0752aa30d2ebe1190de3a3ebec810a23abd64cdb603b7583a0","src/qlog.rs":"85d9b2b2851d857e64e55e0d229bbf3905c581ecc5dd3891cacc95412f1ac317","src/quic_datagrams.rs":"6f067765820a63ceab8c6adf4755df0491062c6c750755eda7c4a758d530920c","src/recovery/mod.rs":"3557c28abec3f90565efe0ae7a8534bf0f05245afb685fddd6ef5f8dbeb31db4","src/recovery/sent.rs":"4e9a0a46556fb0b582c4aa60fecbd913621137ddcaf6c8cf69e60f62fc92fd0e","src/recovery/token.rs":"667c827df3d321ee61689e6cda78d9c27656525ab2978282754a78b2370a9a2f","src/recv_stream.rs":"d3edd857522c943788e8a5d21fc113ab05b15a2721e6ca4b127e92ca17e86f8f","src/rtt.rs":"4b08c284311c926c656c2ea9b9b8be827facf4aa3c69781d7040c631028264cb","src/saved.rs":"55c0d1c415079138674974a46d8c6ecbcda49ce4070bf0920286b1401c161078","src/send_stream.rs":"d49e83c77cdae1ac001da10e2f179449403b1f27fd521fde6fb00e5b99b27665","src/sender.rs":"d49b4d014e27b7120e0c3edc3ce43edbc25acea8394cd7cf15e460cf25cde225","src/server.rs":"c8ee7d148ee034207731af2ade46bac3aabc715082fe3bed39844748c60c1fa3","src/sni.rs":"1cbfd737226ad9b28887fb96793056e1f9e747b3769aea6cfd77da986d8cf2e1","src/stats.rs":"1e7a212af18c86093e6e25a76c806da701a6bb5c42c61d67b0af8a3ddef426da","src/stream_id.rs":"3d894ffd86f1f465053cbb5ea3ed2851c3cd132cd0e46b98443b7ff891395ead","src/streams.rs":"17bea7b2f899e096f7a72aeafb74349f27cebc655ff6d304226f1006e90fe024","src/tparams.rs":"936ce813bd7c75eb4f66ffbb8f7775dcc81dbdd65c5a9d9598d41eb53b34c06e","src/tracking.rs":"e13962b9dd821a9c0c024c333fd61d182aca9cf6847ff74aa171a853001c3a77","src/version.rs":"76b8d3ec0464a749849280756b5acd243543e8cb43185936802ba552a207aeca","tests/common/mod.rs":"d1f96c024543cab68d09e2847990ffdf83568835c6ac740bf9cb765e7a661e1d","tests/conn_vectors.rs":"0e4a1b92c02b527842c127b789e70f6c4372c2b61b1a59a8e695f744ce155e2a","tests/connection.rs":"e6d88fefe7e9863546cf6b296eaa28f326c7f19a205f7a694ee2bca084fc7523","tests/network.rs":"2173d8347543d457a236817d219d2865315dbd005e1d19c2277e3a34d5cca759","tests/retry.rs":"48a48e115eb02ad528606930f96313b1c8bc2c6e7486bafefd4931e35baedbcc","tests/server.rs":"20c7ad05a1d4707002c9c184e8a1cf37a8bd673f76d24a5d2e824774743996da","tests/sni.rs":"5cf5c6ec0601712596fdfd589eb346af599e45c80849adf31879ba4ba3640f38","tests/stats.rs":"af8c1da46e984b55b172118aff4ad33be2375443f405e297d40981e65eb4d0cf"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-transport/Cargo.toml b/third_party/rust/neqo-transport/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-transport" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = "build.rs" autolib = false @@ -43,7 +43,6 @@ repository = "https://github.com/mozilla/neqo/" bench = [ "neqo-common/bench", "neqo-crypto/bench", - "log/release_max_level_info", ] build-fuzzing-corpus = [ "neqo-common/build-fuzzing-corpus", @@ -209,7 +208,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -217,8 +215,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -271,8 +267,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-transport/src/addr_valid.rs b/third_party/rust/neqo-transport/src/addr_valid.rs @@ -443,7 +443,6 @@ impl NewTokenSender { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::Role; diff --git a/third_party/rust/neqo-transport/src/cc/classic_cc.rs b/third_party/rust/neqo-transport/src/cc/classic_cc.rs @@ -16,7 +16,14 @@ use ::qlog::events::{quic::CongestionStateUpdated, EventData}; use neqo_common::{const_max, const_min, qdebug, qinfo, qlog::Qlog, qtrace}; use super::CongestionControl; -use crate::{packet, qlog, recovery::sent, rtt::RttEstimate, sender::PACING_BURST_SIZE, Pmtud}; +use crate::{ + packet, + qlog::{self, QlogMetric}, + recovery::sent, + rtt::RttEstimate, + sender::PACING_BURST_SIZE, + Pmtud, +}; pub const CWND_INITIAL_PKTS: usize = 10; const PERSISTENT_CONG_THRESH: u32 = 3; @@ -203,7 +210,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { if self.state.in_recovery() { self.set_state(State::CongestionAvoidance, now); - qlog::metrics_updated(&self.qlog, &[qlog::Metric::InRecovery(false)], now); + qlog::metrics_updated(&self.qlog, &[QlogMetric::InRecovery(false)], now); } new_acked += pkt.len(); @@ -259,8 +266,8 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { qlog::metrics_updated( &self.qlog, &[ - qlog::Metric::CongestionWindow(self.congestion_window), - qlog::Metric::BytesInFlight(self.bytes_in_flight), + QlogMetric::CongestionWindow(self.congestion_window), + QlogMetric::BytesInFlight(self.bytes_in_flight), ], now, ); @@ -292,7 +299,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { } qlog::metrics_updated( &self.qlog, - &[qlog::Metric::BytesInFlight(self.bytes_in_flight)], + &[QlogMetric::BytesInFlight(self.bytes_in_flight)], now, ); @@ -339,7 +346,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { self.bytes_in_flight -= pkt.len(); qlog::metrics_updated( &self.qlog, - &[qlog::Metric::BytesInFlight(self.bytes_in_flight)], + &[QlogMetric::BytesInFlight(self.bytes_in_flight)], now, ); qtrace!("[{self}] Ignore pkt with size {}", pkt.len()); @@ -350,7 +357,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { self.bytes_in_flight = 0; qlog::metrics_updated( &self.qlog, - &[qlog::Metric::BytesInFlight(self.bytes_in_flight)], + &[QlogMetric::BytesInFlight(self.bytes_in_flight)], now, ); } @@ -381,7 +388,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> { ); qlog::metrics_updated( &self.qlog, - &[qlog::Metric::BytesInFlight(self.bytes_in_flight)], + &[QlogMetric::BytesInFlight(self.bytes_in_flight)], now, ); } @@ -513,7 +520,7 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> { self.set_state(State::PersistentCongestion, now); qlog::metrics_updated( &self.qlog, - &[qlog::Metric::CongestionWindow(self.congestion_window)], + &[QlogMetric::CongestionWindow(self.congestion_window)], now, ); return true; @@ -561,9 +568,9 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> { qlog::metrics_updated( &self.qlog, &[ - qlog::Metric::CongestionWindow(self.congestion_window), - qlog::Metric::SsThresh(self.ssthresh), - qlog::Metric::InRecovery(true), + QlogMetric::CongestionWindow(self.congestion_window), + QlogMetric::SsThresh(self.ssthresh), + QlogMetric::InRecovery(true), ], now, ); @@ -589,7 +596,6 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::time::{Duration, Instant}; diff --git a/third_party/rust/neqo-transport/src/cc/cubic.rs b/third_party/rust/neqo-transport/src/cc/cubic.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! CUBIC congestion control (RFC 9438) +//! CUBIC congestion control use std::{ fmt::{self, Display}, @@ -15,68 +15,46 @@ use neqo_common::qtrace; use crate::cc::classic_cc::WindowAdjustment; -/// > Constant that determines the aggressiveness of CUBIC in competing with other congestion -/// > control algorithms in high-BDP networks. +/// > C is a constant fixed to determine the aggressiveness of window +/// > increase in high BDP networks. /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-constants-of-interest> +/// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.1> /// -/// See section 5.1 of RFC9438 for discussion on how to set the concrete value: +/// See discussion for rational for concrete value. /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-fairness-to-reno> +/// <https://datatracker.ietf.org/doc/html/rfc8312#section-5.1> pub const CUBIC_C: f64 = 0.4; -/// > CUBIC additive increase factor used in the Reno-friendly region \[to achieve approximately the -/// > same average congestion window size as Reno\]. +/// TCP-friendly region additive factor /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-constants-of-interest> -/// -/// > The model used to calculate CUBIC_ALPHA is not absolutely precise, -/// > but analysis and simulation \[...\], as well as over a decade of experience with -/// > CUBIC in the public Internet, show that this approach produces acceptable -/// > levels of rate fairness between CUBIC and Reno flows. -/// -/// Formula: -/// -/// `CUBIC_ALPHA = 3.0 * (1.0 - CUBIC_BETA) / (1.0 + CUBIC_BETA)` -/// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-reno-friendly-region> -pub const CUBIC_ALPHA: f64 = 3.0 * (1.0 - 0.7) / (1.0 + 0.7); // with CUBIC_BETA = 0.7 +/// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.2> +pub const CUBIC_ALPHA: f64 = 3.0 * (1.0 - 0.7) / (1.0 + 0.7); + /// `CUBIC_BETA` = 0.7; /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-constants-of-interest> -/// -/// > To balance between the scalability and convergence speed, CUBIC sets the multiplicative window -/// > decrease factor to 0.7 while Standard TCP uses 0.5. While this improves the scalability of -/// > CUBIC, a side effect of this decision is slower convergence, especially under low statistical +/// > Principle 4: To balance between the scalability and convergence speed, +/// > CUBIC sets the multiplicative window decrease factor to 0.7 while Standard +/// > TCP uses 0.5. While this improves the scalability of CUBIC, a side effect +/// > of this decision is slower convergence, especially under low statistical /// > multiplexing environments. /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-principle-4-for-the-cubic-d> -/// -/// For implementation reasons neqo uses a dividend and divisor approach with `usize` typing to -/// construct `CUBIC_BETA = 0.7`. +/// <https://datatracker.ietf.org/doc/html/rfc8312#section-3> pub const CUBIC_BETA_USIZE_DIVIDEND: usize = 7; -/// > CUBIC multiplicative decrease factor -/// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-constants-of-interest> -/// -/// > To balance between the scalability and convergence speed, CUBIC sets the multiplicative window -/// > decrease factor to 0.7 while Standard TCP uses 0.5. While this improves the scalability of -/// > CUBIC, a side effect of this decision is slower convergence, especially under low statistical -/// > multiplexing environments. -/// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-principle-4-for-the-cubic-d> -/// -/// For implementation reasons neqo uses a dividend and divisor approach with `usize` typing to -/// construct `CUBIC_BETA = 0.7` pub const CUBIC_BETA_USIZE_DIVISOR: usize = 10; -/// This is the factor that is used by fast convergence to further reduce the next `W_max` when a -/// congestion event occurs while `cwnd < W_max`. This speeds up the bandwidth release for when a -/// new flow joins the network. +/// The fast convergence ratio further reduces the congestion window when a +/// congestion event occurs before reaching the previous `W_max`. /// -/// The calculation assumes `CUBIC_BETA = 0.7`. +/// See formula defined below. /// -/// <https://datatracker.ietf.org/doc/html/rfc9438#name-fast-convergence> -pub const CUBIC_FAST_CONVERGENCE_FACTOR: f64 = (1.0 + 0.7) / 2.0; +/// <https://www.rfc-editor.org/rfc/rfc8312#section-4.6> +pub const CUBIC_FAST_CONVERGENCE: f64 = 0.85; // (1.0 + CUBIC_BETA) / 2.0; + +/// The minimum number of multiples of the datagram size that need +/// to be received to cause an increase in the congestion window. +/// When there is no loss, Cubic can return to exponential increase, but +/// this value reduces the magnitude of the resulting growth by a constant factor. +/// A value of 1.0 would mean a return to the rate used in slow start. +const EXPONENTIAL_GROWTH_REDUCTION: f64 = 2.0; /// Convert an integer congestion window value into a floating point value. /// This has the effect of reducing larger values to `1<<53`. @@ -92,145 +70,110 @@ pub fn convert_to_f64(v: usize) -> f64 { #[derive(Debug, Default)] pub struct Cubic { - /// > An estimate for the congestion window \[...\] in the Reno-friendly region -- that - /// > is, an estimate for the congestion window of Reno. + /// Maximum Window size two congestion events ago. /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-variables-of-interest> + /// > With fast convergence, when a congestion event occurs, before the + /// > window reduction of the congestion window, a flow remembers the last + /// > value of W_max before it updates W_max for the current congestion + /// > event. /// - /// > Reno performs well in certain types of networks -- for example, under short RTTs and - /// > small bandwidths (or small BDPs). In these networks, CUBIC remains in the Reno-friendly - /// > region to achieve at least the same throughput as Reno. + /// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.6> + last_max_cwnd: f64, + /// Estimate of Standard TCP congestion window for Cubic's TCP-friendly + /// Region. /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-reno-friendly-region> - w_est: f64, - /// > The time period in seconds it takes to increase the congestion window size - /// > at the beginning of the current congestion avoidance stage to `w_max`. + /// > Standard TCP performs well in certain types of networks, for example, + /// > under short RTT and small bandwidth (or small BDP) networks. In + /// > these networks, we use the TCP-friendly region to ensure that CUBIC + /// > achieves at least the same throughput as Standard TCP. /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-variables-of-interest> + /// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.2> + estimated_tcp_cwnd: f64, + /// > K is the time period that the above function takes to increase the + /// > current window size to W_max if there are no further congestion events /// - /// Formula: - /// - /// `k = cubic_root((w_max - cwnd_epoch) / C)` - /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-window-increase-function> + /// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.1> k: f64, - /// > Size of `cwnd` in \[bytes\] just before `cwnd` was reduced in the last congestion - /// > event \[...\]. \[With\] fast convergence enabled, `w_max` may be further reduced based on - /// > the current saturation point. - /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-variables-of-interest> - /// - /// `w_max` acts as the plateau for the cubic function where it switches from the concave to - /// the convex region. + /// > W_max is the window size just before the window is reduced in the last + /// > congestion event. /// - /// It is calculated with the following logic: - /// - /// ```pseudo - /// if (w_max > cwnd) { - /// w_max = cwnd * FAST_CONVERGENCE_FACTOR; - /// } else { - /// w_max = cwnd; - /// } - /// ``` - /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-fast-convergence> + /// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.1> w_max: f64, - /// > The time in seconds at which the current congestion avoidance stage started. - /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#name-variables-of-interest> + /// > the elapsed time from the beginning of the current congestion + /// > avoidance /// - /// This also is reset on being application limited. - t_epoch: Option<Instant>, - /// New and unused leftover acked bytes for calculating the reno region increases to `w_est`. - reno_acked_bytes: f64, + /// <https://datatracker.ietf.org/doc/html/rfc8312#section-4.1> + ca_epoch_start: Option<Instant>, + /// Number of bytes acked since the last Standard TCP congestion window increase. + tcp_acked_bytes: f64, } impl Display for Cubic { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, - "Cubic [w_max: {}, k: {}, t_epoch: {:?}]", - self.w_max, self.k, self.t_epoch + "Cubic [last_max_cwnd: {}, k: {}, w_max: {}, ca_epoch_start: {:?}]", + self.last_max_cwnd, self.k, self.w_max, self.ca_epoch_start )?; Ok(()) } } +#[expect(clippy::doc_markdown, reason = "Not doc items; names from RFC.")] impl Cubic { - /// Original equation is: + /// Original equations is: + /// K = cubic_root(W_max*(1-beta_cubic)/C) (Eq. 2 RFC8312) + /// W_max is number of segments of the maximum segment size (MSS). /// - /// `k = cubic_root((w_max - cwnd_epoch)/C)` + /// K is actually the time that W_cubic(t) = C*(t-K)^3 + W_max (Eq. 1) would + /// take to increase to W_max. We use bytes not MSS units, therefore this + /// equation will be: W_cubic(t) = C*MSS*(t-K)^3 + W_max. /// - /// with `cwnd_epoch` being the congestion window at the start of the current congestion - /// avoidance stage (so at time `t_epoch`). + /// From that equation we can calculate K as: + /// K = cubic_root((W_max - W_cubic) / C / MSS); /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#figure-2> - /// - /// Taking into account that neqo is using bytes but the formula assumes segments for both - /// `w_max` and `cwnd_epoch` it becomes: - /// - /// `k = cubic_root((w_max - cwnd_epoch)/SMSS/C)` - fn calc_k(&self, cwnd_epoch: f64, max_datagram_size: f64) -> f64 { - ((self.w_max - cwnd_epoch) / max_datagram_size / CUBIC_C).cbrt() + /// <https://www.rfc-editor.org/rfc/rfc8312#section-4.1> + fn calc_k(&self, curr_cwnd: f64, max_datagram_size: f64) -> f64 { + ((self.w_max - curr_cwnd) / CUBIC_C / max_datagram_size).cbrt() } - /// `w_cubic(t) = C*(t-K)^3 + w_max` - /// - /// with `t = t_current - t_epoch`. + /// W_cubic(t) = C*(t-K)^3 + W_max (Eq. 1) + /// t is relative to the start of the congestion avoidance phase and it is in seconds. /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#figure-1> - /// - /// Taking into account that neqo is using bytes and the formula returns segments and that - /// `w_max` already is in bytes the formula becomes: - /// - /// `w_cubic(t) = (C*(t-K)^3) * SMSS + w_max` + /// <https://www.rfc-editor.org/rfc/rfc8312#section-4.1> fn w_cubic(&self, t: f64, max_datagram_size: f64) -> f64 { (CUBIC_C * (t - self.k).powi(3)).mul_add(max_datagram_size, self.w_max) } - /// Sets `w_est`, `k`, `t_epoch` and `reno_acked_bytes` at the start of a new epoch - /// (new congestion avoidance stage) according to RFC 9438. The `w_max` variable has - /// been set in `reduce_cwnd()` prior to this call. - /// - /// > `w_est` is set equal to `cwnd_epoch` at the start of the congestion avoidance stage. - /// - /// <https://datatracker.ietf.org/doc/html/rfc9438#section-4.3-9> - /// - /// Also initializes `k` and `w_max` if we start an epoch without having ever had - /// a congestion event, which can happen upon exiting slow start. fn start_epoch( &mut self, curr_cwnd: f64, - new_acked_bytes: f64, + new_acked: f64, max_datagram_size: f64, now: Instant, ) { - self.t_epoch = Some(now); - self.reno_acked_bytes = new_acked_bytes; - self.w_est = curr_cwnd; - // If `w_max < cwnd_epoch` we take the cubic root from a negative value in `calc_k()`. That - // could only happen if somehow `cwnd` get's increased between calling `reduce_cwnd()` and - // `start_epoch()`. This could happen if we exit slow start without packet loss, thus never - // had a congestion event and called `reduce_cwnd()` which means `w_max` was never set and - // is still it's default `0.0` value. For those cases we reset/initialize `w_max` here and - // appropiately set `k` to `0.0` (`k` is the time for `cwnd` to reach `w_max`). - self.k = if self.w_max <= curr_cwnd { + self.ca_epoch_start = Some(now); + // reset tcp_acked_bytes and estimated_tcp_cwnd; + self.tcp_acked_bytes = new_acked; + self.estimated_tcp_cwnd = curr_cwnd; + if self.last_max_cwnd <= curr_cwnd { self.w_max = curr_cwnd; - 0.0 + self.k = 0.0; } else { - self.calc_k(curr_cwnd, max_datagram_size) - }; + self.w_max = self.last_max_cwnd; + self.k = self.calc_k(curr_cwnd, max_datagram_size); + } qtrace!("[{self}] New epoch"); } #[cfg(test)] - pub const fn w_max(&self) -> f64 { - self.w_max + pub const fn last_max_cwnd(&self) -> f64 { + self.last_max_cwnd } #[cfg(test)] - pub fn set_w_max(&mut self, w_max: f64) { - self.w_max = w_max; + pub fn set_last_max_cwnd(&mut self, last_max_cwnd: f64) { + self.last_max_cwnd = last_max_cwnd; } } @@ -248,132 +191,71 @@ impl WindowAdjustment for Cubic { max_datagram_size: usize, now: Instant, ) -> usize { - let curr_cwnd = convert_to_f64(curr_cwnd); - let new_acked_bytes = convert_to_f64(new_acked_bytes); - let max_datagram_size = convert_to_f64(max_datagram_size); - - let t_epoch = if let Some(t) = self.t_epoch { - self.reno_acked_bytes += new_acked_bytes; - t + let curr_cwnd_f64 = convert_to_f64(curr_cwnd); + let new_acked_f64 = convert_to_f64(new_acked_bytes); + let max_datagram_size_f64 = convert_to_f64(max_datagram_size); + if self.ca_epoch_start.is_none() { + // This is a start of a new congestion avoidance phase. + self.start_epoch(curr_cwnd_f64, new_acked_f64, max_datagram_size_f64, now); } else { - // If we get here with `self.t_epoch == None` this is a new congestion - // avoidance stage. It's been set to `None` by - // [`super::ClassicCongestionControl::reduce_cwnd`] or needs to be - // initialized after slow start. It could also have been reset by - // [`super::ClassicCongestionControl::on_app_limited`] in which case we also start a - // new congestion avoidance stage for the purpose of resetting - // timing as per RFC 9438 section 5.8. - // - // <https://datatracker.ietf.org/doc/html/rfc9438#app-limited> - self.start_epoch(curr_cwnd, new_acked_bytes, max_datagram_size, now); - self.t_epoch - .expect("unwrapping `None` value -- it should've been set by `start_epoch`") - }; + self.tcp_acked_bytes += new_acked_f64; + } - // Calculate `target_cubic` for the concave or convex region - // - // > Upon receiving a new ACK during congestion avoidance, CUBIC computes the target - // > congestion window size after the next RTT [...], where RTT is the - // > smoothed round-trip time. The lower and upper bounds below ensure that CUBIC's - // > congestion window increase rate is non-decreasing and is less than the increase rate of - // > slow start. + // Cubic concave or convex region // - // <https://datatracker.ietf.org/doc/html/rfc9438#section-4.2-10> - // - // In neqo the target congestion window is in bytes. - let t = now.saturating_duration_since(t_epoch); - // cwnd <= target_cubic <= cwnd * 1.5 - let target_cubic = f64::clamp( - self.w_cubic((t + min_rtt).as_secs_f64(), max_datagram_size), - curr_cwnd, - curr_cwnd * 1.5, - ); + // <https://datatracker.ietf.org/doc/html/rfc8312#section-4.3> + // <https://datatracker.ietf.org/doc/html/rfc8312#section-4.4> + let time_ca = self + .ca_epoch_start + .map_or(min_rtt, |t| { + if now + min_rtt < t { + // This only happens when processing old packets + // that were saved and replayed with old timestamps. + min_rtt + } else { + now + min_rtt - t + } + }) + .as_secs_f64(); + let target_cubic = self.w_cubic(time_ca, max_datagram_size_f64); - // Calculate w_est for the Reno-friendly region with a slightly adjusted formula per the - // below: - // - // > Note that this equation uses segments_acked and cwnd is measured in segments. An - // > implementation that measures cwnd in bytes should adjust the equation accordingly - // > using the number of acknowledged bytes and the SMSS. - // - // Formula: w_est += (alpha * bytes_acked / cwnd) * SMSS + // Cubic TCP-friendly region // - // <https://datatracker.ietf.org/doc/html/rfc9438#section-4.3-9> - - // We first calculate the increase in segments and floor it to only include whole segments. - let increase = (CUBIC_ALPHA * self.reno_acked_bytes / curr_cwnd).floor(); - - // Only apply the increase if it is at least by one segment. - if increase > 0.0 { - self.w_est += increase * max_datagram_size; - // Because we floored the increase to whole segments we cannot just zero - // `reno_acked_bytes` but have to calculate the actual bytes used. - let acked_bytes_used = increase * curr_cwnd / CUBIC_ALPHA; - self.reno_acked_bytes -= acked_bytes_used; + // <https://datatracker.ietf.org/doc/html/rfc8312#section-4.2> + let tcp_cnt = self.estimated_tcp_cwnd / CUBIC_ALPHA; + let incr = (self.tcp_acked_bytes / tcp_cnt).floor(); + if incr > 0.0 { + self.tcp_acked_bytes -= incr * tcp_cnt; + self.estimated_tcp_cwnd += incr * max_datagram_size_f64; } - // > When receiving a new ACK in congestion avoidance (where cwnd could be greater than - // > or less than w_max), CUBIC checks whether W_cubic(t) is less than w_est. If so, CUBIC - // > is in the Reno-friendly region and cwnd SHOULD be set to w_est at each reception of a - // > new ACK. - // - // <https://datatracker.ietf.org/doc/html/rfc9438#section-4.3-8> + // Take the larger cwnd of Cubic concave or convex and Cubic + // TCP-friendly region. // - // While the RFC specifies that we should compare `w_cubic(t)` with `w_est` we are rather - // comparing the previously calculated `target` here (`w_cubic(t + min_rtt)` with clamping - // to `cwnd <= target <= cwnd * 1.5` applied), since that is the value that would actually - // be used if we are in the cubic region. + // > When receiving an ACK in congestion avoidance (cwnd could be + // > greater than or less than W_max), CUBIC checks whether W_cubic(t) is + // > less than W_est(t). If so, CUBIC is in the TCP-friendly region and + // > cwnd SHOULD be set to W_est(t) at each reception of an ACK. // - // That is in line with what e.g. the Linux Kernel CUBIC implementation is doing. - // - // <https://github.com/torvalds/linux/blob/d7ee5bdce7892643409dea7266c34977e651b479/net/ipv4/tcp_cubic.c#L313> - let target = target_cubic.max(self.w_est); - - let cwnd_increase = target - curr_cwnd; + // <https://datatracker.ietf.org/doc/html/rfc8312#section-4.2> + let target_cwnd = target_cubic.max(self.estimated_tcp_cwnd); // Calculate the number of bytes that would need to be acknowledged for an increase - // of `max_datagram_size` to match `cwnd_increase`, that is the increase from the current - // congestion window to `target`. - // The amount of acked data required therefore reduces asymptotically as the target - // increases. - // - // RFC 9438 tells us to increase cwnd by `cwnd_increase/cwnd` which would amount to the - // increase in segments per congestion window acked. - // - // (https://datatracker.ietf.org/doc/html/rfc9438#section-4.4-2.1) - // - // Since we want to know how much we need to ack to increase by 1 segment we need the - // inverse of that, which would be `cwnd/cwnd_increase`. - // (E.g. if we'd increase by `1/4 * mss` per cwnd acked then we need to ack `4 * cwnd` to - // increase by `1 * mss`) - // - // The RFC only applies this increase per acked cwnd to the Cubic (concave/convex) region. - // We also apply it to the Reno region, as that is what the Linux Kernel CUBIC - // implementation does, too. - // - // <https://github.com/torvalds/linux/blob/d7ee5bdce7892643409dea7266c34977e651b479/net/ipv4/tcp_cubic.c#L311-L315> - // - // We multiply by `max_datagram_size` as our `curr_cwnd` value is in bytes and prevent - // division by zero by setting `cwnd_increase` to `1` for the `target == curr_cwnd` case. - (max_datagram_size * curr_cwnd / cwnd_increase.max(1.0)) as usize + // of `max_datagram_size_f64` to match the increase of `target - cwnd / cwnd` as defined + // in the specification (Sections 4.4 and 4.5). + // The amount of data required therefore reduces asymptotically as the target increases. + // If the target is not significantly higher than the congestion window, require a very + // large amount of acknowledged data (effectively block increases). + let mut acked_to_increase = + max_datagram_size_f64 * curr_cwnd_f64 / (target_cwnd - curr_cwnd_f64).max(1.0); + + // Limit increase to max 1 MSS per EXPONENTIAL_GROWTH_REDUCTION ack packets. + // This effectively limits target_cwnd to (1 + 1 / EXPONENTIAL_GROWTH_REDUCTION) cwnd. + acked_to_increase = + acked_to_increase.max(EXPONENTIAL_GROWTH_REDUCTION * max_datagram_size_f64); + acked_to_increase as usize } - // CUBIC RFC 9438 changes the logic for multiplicative decrease, most notably setting the - // minimum congestion window to 1*SMSS under some circumstances while keeping ssthresh at - // 2*SMSS. - // - // <https://datatracker.ietf.org/doc/html/rfc9438#section-4.6> - // - // QUIC has a minimum congestion window of 2*SMSS as per RFC 9002. - // - // <https://datatracker.ietf.org/doc/html/rfc9002#section-4.8> - // - // For that reason we diverge from CUBIC RFC 9438 here retaining the 2*SMSS minimum for the - // congestion window. - // - // This function only returns the value for `cwnd * CUBIC_BETA` and sets some variables for the - // start of a new congestion avoidance phase. Actually setting the congestion window happens in - // [`super::ClassicCongestionControl::on_congestion_event`] where this function is called. fn reduce_cwnd( &mut self, curr_cwnd: usize, @@ -383,28 +265,19 @@ impl WindowAdjustment for Cubic { let curr_cwnd_f64 = convert_to_f64(curr_cwnd); // Fast Convergence // - // > During a congestion event, if the current cwnd is less than w_max, this indicates - // > that the saturation point experienced by this flow is getting reduced because of - // > a change in available bandwidth. This flow can then release more bandwidth by - // > reducing w_max further. This action effectively lengthens the time for this flow - // > to increase its congestion window, because the reduced w_max forces the flow to - // > plateau earlier. This allows more time for the new flow to catch up to its - // > congestion window size. - // - // <https://datatracker.ietf.org/doc/html/rfc9438#name-fast-convergence> + // If congestion event occurs before the maximum congestion window before the last + // congestion event, we reduce the the maximum congestion window and thereby W_max. + // check cwnd + MAX_DATAGRAM_SIZE instead of cwnd because with cwnd in bytes, cwnd may be + // slightly off. // - // From the old implementation: - // - // "Check cwnd + MAX_DATAGRAM_SIZE instead of cwnd because with cwnd in bytes, cwnd may be - // slightly off." - self.w_max = if curr_cwnd_f64 + convert_to_f64(max_datagram_size) < self.w_max { - curr_cwnd_f64 * CUBIC_FAST_CONVERGENCE_FACTOR - } else { - curr_cwnd_f64 - }; - - // Reducing the congestion window and resetting time - self.t_epoch = None; + // <https://www.rfc-editor.org/rfc/rfc8312#section-4.6> + self.last_max_cwnd = + if curr_cwnd_f64 + convert_to_f64(max_datagram_size) < self.last_max_cwnd { + curr_cwnd_f64 * CUBIC_FAST_CONVERGENCE + } else { + curr_cwnd_f64 + }; + self.ca_epoch_start = None; ( curr_cwnd * CUBIC_BETA_USIZE_DIVIDEND / CUBIC_BETA_USIZE_DIVISOR, acked_bytes * CUBIC_BETA_USIZE_DIVIDEND / CUBIC_BETA_USIZE_DIVISOR, @@ -412,8 +285,8 @@ impl WindowAdjustment for Cubic { } fn on_app_limited(&mut self) { - // Reset t_epoch. Let it start again when the congestion controller + // Reset ca_epoch_start. Let it start again when the congestion controller // exits the app-limited period. - self.t_epoch = None; + self.ca_epoch_start = None; } } diff --git a/third_party/rust/neqo-transport/src/cc/mod.rs b/third_party/rust/neqo-transport/src/cc/mod.rs @@ -102,5 +102,4 @@ impl FromStr for CongestionControlAlgorithm { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests; diff --git a/third_party/rust/neqo-transport/src/cc/tests/cubic.rs b/third_party/rust/neqo-transport/src/cc/tests/cubic.rs @@ -23,7 +23,7 @@ use crate::{ classic_cc::ClassicCongestionControl, cubic::{ convert_to_f64, Cubic, CUBIC_ALPHA, CUBIC_BETA_USIZE_DIVIDEND, - CUBIC_BETA_USIZE_DIVISOR, CUBIC_C, CUBIC_FAST_CONVERGENCE_FACTOR, + CUBIC_BETA_USIZE_DIVISOR, CUBIC_C, CUBIC_FAST_CONVERGENCE, }, CongestionControl as _, }, @@ -200,9 +200,11 @@ fn tcp_phase() { fn cubic_phase() { let mut cubic = ClassicCongestionControl::new(Cubic::default(), Pmtud::new(IP_ADDR, MTU)); let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); - // Set w_max to a higher number make sure that cc is the cubic phase (cwnd is calculated + // Set last_max_cwnd to a higher number make sure that cc is the cubic phase (cwnd is calculated // by the cubic equation). - cubic.cc_algorithm_mut().set_w_max(cwnd_initial_f64 * 10.0); + cubic + .cc_algorithm_mut() + .set_last_max_cwnd(cwnd_initial_f64 * 10.0); // Set ssthresh to something small to make sure that cc is in the congection avoidance phase. cubic.set_ssthresh(1); let mut now = now(); @@ -258,7 +260,7 @@ fn congestion_event_slow_start() { _ = fill_cwnd(&mut cubic, 0, now()); ack_packet(&mut cubic, 0, now()); - assert_within(cubic.cc_algorithm().w_max(), 0.0, f64::EPSILON); + assert_within(cubic.cc_algorithm().last_max_cwnd(), 0.0, f64::EPSILON); // cwnd is increased by 1 in slow start phase, after an ack. assert_eq!( @@ -269,10 +271,10 @@ fn congestion_event_slow_start() { // Trigger a congestion_event in slow start phase packet_lost(&mut cubic, 1); - // w_max is equal to cwnd before decrease. + // last_max_cwnd is equal to cwnd before decrease. let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); assert_within( - cubic.cc_algorithm().w_max(), + cubic.cc_algorithm().last_max_cwnd(), cwnd_initial_f64 + convert_to_f64(cubic.max_datagram_size()), f64::EPSILON, ); @@ -289,12 +291,12 @@ fn congestion_event_congestion_avoidance() { // Set ssthresh to something small to make sure that cc is in the congection avoidance phase. cubic.set_ssthresh(1); - // Set w_max to something smaller than cwnd so that the fast convergence is not + // Set last_max_cwnd to something smaller than cwnd so that the fast convergence is not // triggered. let max_datagram_size_f64 = convert_to_f64(cubic.max_datagram_size()); cubic .cc_algorithm_mut() - .set_w_max(3.0 * max_datagram_size_f64); + .set_last_max_cwnd(3.0 * max_datagram_size_f64); _ = fill_cwnd(&mut cubic, 0, now()); ack_packet(&mut cubic, 0, now()); @@ -305,26 +307,32 @@ fn congestion_event_congestion_avoidance() { packet_lost(&mut cubic, 1); let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); - assert_within(cubic.cc_algorithm().w_max(), cwnd_initial_f64, f64::EPSILON); + assert_within( + cubic.cc_algorithm().last_max_cwnd(), + cwnd_initial_f64, + f64::EPSILON, + ); assert_eq!(cubic.cwnd(), cwnd_after_loss(cubic.cwnd_initial())); } #[test] -fn congestion_event_congestion_avoidance_fast_convergence() { +fn congestion_event_congestion_avoidance_2() { let mut cubic = ClassicCongestionControl::new(Cubic::default(), Pmtud::new(IP_ADDR, MTU)); // Set ssthresh to something small to make sure that cc is in the congection avoidance phase. cubic.set_ssthresh(1); - // Set w_max to something higher than cwnd so that the fast convergence is triggered. + // Set last_max_cwnd to something higher than cwnd so that the fast convergence is triggered. let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); - cubic.cc_algorithm_mut().set_w_max(cwnd_initial_f64 * 10.0); + cubic + .cc_algorithm_mut() + .set_last_max_cwnd(cwnd_initial_f64 * 10.0); _ = fill_cwnd(&mut cubic, 0, now()); ack_packet(&mut cubic, 0, now()); assert_within( - cubic.cc_algorithm().w_max(), + cubic.cc_algorithm().last_max_cwnd(), cwnd_initial_f64 * 10.0, f64::EPSILON, ); @@ -334,8 +342,8 @@ fn congestion_event_congestion_avoidance_fast_convergence() { packet_lost(&mut cubic, 1); assert_within( - cubic.cc_algorithm().w_max(), - cwnd_initial_f64 * CUBIC_FAST_CONVERGENCE_FACTOR, + cubic.cc_algorithm().last_max_cwnd(), + cwnd_initial_f64 * CUBIC_FAST_CONVERGENCE, f64::EPSILON, ); assert_eq!(cubic.cwnd(), cwnd_after_loss(cubic.cwnd_initial())); @@ -349,15 +357,17 @@ fn congestion_event_congestion_avoidance_no_overflow() { // Set ssthresh to something small to make sure that cc is in the congection avoidance phase. cubic.set_ssthresh(1); - // Set w_max to something higher than cwnd so that the fast convergence is triggered. + // Set last_max_cwnd to something higher than cwnd so that the fast convergence is triggered. let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); - cubic.cc_algorithm_mut().set_w_max(cwnd_initial_f64 * 10.0); + cubic + .cc_algorithm_mut() + .set_last_max_cwnd(cwnd_initial_f64 * 10.0); _ = fill_cwnd(&mut cubic, 0, now()); ack_packet(&mut cubic, 1, now()); assert_within( - cubic.cc_algorithm().w_max(), + cubic.cc_algorithm().last_max_cwnd(), cwnd_initial_f64 * 10.0, f64::EPSILON, ); diff --git a/third_party/rust/neqo-transport/src/cid.rs b/third_party/rust/neqo-transport/src/cid.rs @@ -613,7 +613,6 @@ impl ConnectionIdManager { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use test_fixture::fixture_init; diff --git a/third_party/rust/neqo-transport/src/connection/mod.rs b/third_party/rust/neqo-transport/src/connection/mod.rs @@ -43,7 +43,7 @@ use crate::{ packet::{self}, path::{Path, PathRef, Paths}, qlog, - quic_datagrams::{DatagramTracking, QuicDatagrams, DATAGRAM_FRAME_TYPE_VARINT_LEN}, + quic_datagrams::{DatagramTracking, QuicDatagrams}, recovery::{self, sent, SendProfile}, recv_stream, rtt::{RttEstimate, GRANULARITY}, @@ -70,7 +70,6 @@ mod idle; pub mod params; mod state; #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] pub mod test_internal; use idle::IdleTimeout; @@ -2656,15 +2655,6 @@ impl Connection { let grease_quic_bit = self.can_grease_quic_bit(); let version = self.version(); - // Determine the size limit and padding for this UDP datagram. - let limit = if path.borrow().pmtud().needs_probe() { - needs_padding = true; - debug_assert!(path.borrow().pmtud().probe_size() >= profile.limit()); - path.borrow().pmtud().probe_size() - } else { - profile.limit() - }; - // Frames for different epochs must go in different packets, but then these // packets can go in a single datagram for space in PacketNumberSpace::iter() { @@ -2673,10 +2663,19 @@ impl Connection { else { continue; }; - let aead_expansion = tx.expansion(); + let aead_expansion = CryptoDxState::expansion(); let header_start = encoder.len(); + // Configure the limits and padding for this packet. + let limit = if path.borrow().pmtud().needs_probe() { + needs_padding = true; + debug_assert!(path.borrow().pmtud().probe_size() >= profile.limit()); + path.borrow().pmtud().probe_size() - aead_expansion + } else { + profile.limit() - aead_expansion + }; + let (pt, mut builder) = Self::build_packet_header( &path.borrow(), epoch, @@ -2685,9 +2684,7 @@ impl Connection { &self.address_validation, version, grease_quic_bit, - // Limit the packet builder further to leave space for AEAD - // expansion added in `builder.build` below. - limit - aead_expansion, + limit, ); let pn = Self::add_packet_number( &mut builder, @@ -3847,9 +3844,8 @@ impl Connection { .largest_acknowledged_pn(PacketNumberSpace::ApplicationData), ); - let data_len_possible = u64::try_from( - mtu.saturating_sub(tx.expansion() + builder.len() + DATAGRAM_FRAME_TYPE_VARINT_LEN), - )?; + let data_len_possible = + u64::try_from(mtu.saturating_sub(CryptoDxState::expansion() + builder.len() + 1))?; Ok(min(data_len_possible, max_dgram_size)) } @@ -3930,5 +3926,4 @@ impl Display for Connection { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests; diff --git a/third_party/rust/neqo-transport/src/connection/params.rs b/third_party/rust/neqo-transport/src/connection/params.rs @@ -32,8 +32,6 @@ use crate::{ const LOCAL_MAX_DATA: u64 = MAX_VARINT; const LOCAL_STREAM_LIMIT_BIDI: u64 = 16; const LOCAL_STREAM_LIMIT_UNI: u64 = 16; -// Maximum size of a QUIC DATAGRAM frame, as specified in https://datatracker.ietf.org/doc/html/rfc9221#section-3-4. -const MAX_DATAGRAM_FRAME_SIZE: u64 = 65535; const MAX_QUEUED_DATAGRAMS_DEFAULT: usize = 10; /// What to do with preferred addresses. @@ -117,7 +115,7 @@ impl Default for ConnectionParameters { ack_ratio: Self::DEFAULT_ACK_RATIO, idle_timeout: Self::DEFAULT_IDLE_TIMEOUT, preferred_address: PreferredAddressConfig::Default, - datagram_size: MAX_DATAGRAM_FRAME_SIZE, + datagram_size: 1200, outgoing_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT, incoming_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT, initial_rtt: DEFAULT_INITIAL_RTT, diff --git a/third_party/rust/neqo-transport/src/connection/tests/cc.rs b/third_party/rust/neqo-transport/src/connection/tests/cc.rs @@ -261,11 +261,7 @@ fn cc_cong_avoidance_recovery_period_to_cong_avoidance(cc_algorithm: CongestionC client.process_input(s_ack, now); } - assert!( - cwnd_before_loss < cwnd(&client), - "cwnd_before_loss = {cwnd_before_loss} cwnd(&client) = {}", - cwnd(&client) - ); + assert!(cwnd_before_loss < cwnd(&client)); } #[test] diff --git a/third_party/rust/neqo-transport/src/connection/tests/datagram.rs b/third_party/rust/neqo-transport/src/connection/tests/datagram.rs @@ -10,7 +10,8 @@ use neqo_common::event::Provider as _; use static_assertions::const_assert; use super::{ - assert_error, connect_force_idle, default_server, new_client, new_server, now, AT_LEAST_PTO, + assert_error, connect_force_idle, default_client, default_server, new_client, new_server, now, + AT_LEAST_PTO, }; use crate::{ connection::tests::DEFAULT_ADDR, @@ -393,6 +394,21 @@ fn datagram_sent_once() { } #[test] +fn dgram_no_allowed() { + let mut client = default_client(); + let mut server = default_server(); + connect_force_idle(&mut client, &mut server); + + let out = server + .test_write_frames(InsertDatagram { data: DATA_MTU }, now()) + .dgram() + .unwrap(); + client.process_input(out, now()); + + assert_error(&client, &CloseReason::Transport(Error::ProtocolViolation)); +} + +#[test] fn dgram_too_big() { let mut client = new_client(ConnectionParameters::default().datagram_size(DATAGRAM_LEN_SMALLER_THAN_MTU)); diff --git a/third_party/rust/neqo-transport/src/connection/tests/handshake.rs b/third_party/rust/neqo-transport/src/connection/tests/handshake.rs @@ -1494,14 +1494,7 @@ fn server_initial_retransmits_identical() { // Server is amplification-limited now. let pto = server.process_output(now).callback(); - assert_eq!( - pto, - server - .conn_params - .get_idle_timeout() - .checked_sub(total_ptos) - .expect("doesn't underflow") - ); + assert_eq!(pto, server.conn_params.get_idle_timeout() - total_ptos); } #[test] diff --git a/third_party/rust/neqo-transport/src/connection/tests/idle.rs b/third_party/rust/neqo-transport/src/connection/tests/idle.rs @@ -190,7 +190,7 @@ fn idle_send_packet1() { // Still connected after 39 seconds because idle timer reset by the // outgoing packet. - now += default_timeout().checked_sub(DELTA).unwrap(); + now += default_timeout() - DELTA; let dgram = client.process_output(now).dgram(); assert!(dgram.is_some()); // PTO assert!(client.state().connected()); @@ -225,7 +225,7 @@ fn idle_send_packet2() { assert!((GAP * 2 + DELTA) < default_timeout()); // Still connected just before GAP + default_timeout(). - now += default_timeout().checked_sub(DELTA).unwrap(); + now += default_timeout() - DELTA; let dgram = client.process_output(now).dgram(); assert!(dgram.is_some()); // PTO assert!(matches!(client.state(), State::Confirmed)); @@ -268,7 +268,7 @@ fn idle_recv_packet() { assert!(matches!(client.state(), State::Confirmed)); // Add a little less than the idle timeout and we're still connected. - now += default_timeout().checked_sub(FUDGE).unwrap(); + now += default_timeout() - FUDGE; drop(client.process_output(now)); assert!(matches!(client.state(), State::Confirmed)); @@ -476,11 +476,7 @@ fn keep_alive_lost() { // return some small timeout for the recovery although it does not have // any outstanding data. Therefore we call it after AT_LEAST_PTO. now += AT_LEAST_PTO; - assert_idle( - &mut server, - now, - keep_alive_timeout().checked_sub(AT_LEAST_PTO).unwrap(), - ); + assert_idle(&mut server, now, keep_alive_timeout() - AT_LEAST_PTO); } /// The other peer can also keep it alive. @@ -718,11 +714,11 @@ fn keep_alive_with_ack_eliciting_packet_lost() { // The next callback should be for an idle PING. assert_eq!( client.process_output(now).callback(), - (IDLE_TIMEOUT / 2).checked_sub(pto).unwrap() + IDLE_TIMEOUT / 2 - pto ); // Wait that long and the client should send a PING frame. - now += (IDLE_TIMEOUT / 2).checked_sub(pto).unwrap(); + now += IDLE_TIMEOUT / 2 - pto; let pings_before = client.stats().frame_tx.ping; let ping = client.process_output(now).dgram(); assert!(ping.is_some()); @@ -740,10 +736,10 @@ fn keep_alive_with_ack_eliciting_packet_lost() { // The next callback will be an idle timeout. assert_eq!( client.process_output(now).callback(), - (IDLE_TIMEOUT / 2).checked_sub(2 * pto).unwrap() + IDLE_TIMEOUT / 2 - 2 * pto ); - now += (IDLE_TIMEOUT / 2).checked_sub(2 * pto).unwrap(); + now += IDLE_TIMEOUT / 2 - 2 * pto; let out = client.process_output(now); assert!(matches!(out, Output::None)); assert!(matches!(client.state(), State::Closed(_))); diff --git a/third_party/rust/neqo-transport/src/connection/tests/mod.rs b/third_party/rust/neqo-transport/src/connection/tests/mod.rs @@ -336,7 +336,7 @@ fn assert_idle(client: &mut Connection, server: &mut Connection, rtt: Duration, // Client started its idle period half an RTT before now. assert_eq!( client.process_output(now), - Output::Callback(idle_timeout.checked_sub(rtt / 2).unwrap()) + Output::Callback(idle_timeout - rtt / 2) ); assert_eq!(server.process_output(now), Output::Callback(idle_timeout)); } diff --git a/third_party/rust/neqo-transport/src/connection/tests/recovery.rs b/third_party/rust/neqo-transport/src/connection/tests/recovery.rs @@ -829,9 +829,7 @@ fn fast_pto() { let mut now = connect_rtt_idle(&mut client, &mut server, DEFAULT_RTT); let res = client.process_output(now); - let idle_timeout = ConnectionParameters::DEFAULT_IDLE_TIMEOUT - .checked_sub(DEFAULT_RTT / 2) - .unwrap(); + let idle_timeout = ConnectionParameters::DEFAULT_IDLE_TIMEOUT - (DEFAULT_RTT / 2); assert_eq!(res, Output::Callback(idle_timeout)); // Send data on two streams @@ -874,9 +872,7 @@ fn fast_pto_persistent_congestion() { let mut now = connect_rtt_idle(&mut client, &mut server, DEFAULT_RTT); let res = client.process_output(now); - let idle_timeout = ConnectionParameters::DEFAULT_IDLE_TIMEOUT - .checked_sub(DEFAULT_RTT / 2) - .unwrap(); + let idle_timeout = ConnectionParameters::DEFAULT_IDLE_TIMEOUT - (DEFAULT_RTT / 2); assert_eq!(res, Output::Callback(idle_timeout)); // Send packets spaced by the PTO timer. And lose them. diff --git a/third_party/rust/neqo-transport/src/connection/tests/resumption.rs b/third_party/rust/neqo-transport/src/connection/tests/resumption.rs @@ -7,7 +7,7 @@ use std::{cell::RefCell, rc::Rc, time::Duration}; use neqo_common::{Datagram, Decoder, Role}; -use neqo_crypto::{AeadTrait as _, AuthenticationStatus}; +use neqo_crypto::AuthenticationStatus; use test_fixture::{ assertions, header_protection::{self, decode_initial_header, initial_aead_and_hp}, diff --git a/third_party/rust/neqo-transport/src/crypto.rs b/third_party/rust/neqo-transport/src/crypto.rs @@ -18,11 +18,11 @@ use enum_map::EnumMap; use neqo_common::{hex, hex_snip_middle, qdebug, qinfo, qtrace, Buffer, Encoder, Role}; pub use neqo_crypto::Epoch; use neqo_crypto::{ - hkdf, hp, random, Aead, AeadTrait as _, Agent, AntiReplay, Cipher, Error as CryptoError, - HandshakeState, PrivateKey, PublicKey, Record, RecordList, ResumptionToken, SymKey, - ZeroRttChecker, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, - TLS_CT_HANDSHAKE, TLS_GRP_EC_SECP256R1, TLS_GRP_EC_SECP384R1, TLS_GRP_EC_SECP521R1, - TLS_GRP_EC_X25519, TLS_GRP_KEM_MLKEM768X25519, TLS_VERSION_1_3, + hkdf, hp, random, Aead, Agent, AntiReplay, Cipher, Error as CryptoError, HandshakeState, + PrivateKey, PublicKey, Record, RecordList, ResumptionToken, SymKey, ZeroRttChecker, + TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_CT_HANDSHAKE, + TLS_GRP_EC_SECP256R1, TLS_GRP_EC_SECP384R1, TLS_GRP_EC_SECP521R1, TLS_GRP_EC_X25519, + TLS_GRP_KEM_MLKEM768X25519, TLS_VERSION_1_3, }; use crate::{ @@ -653,10 +653,7 @@ impl CryptoDxState { ) } - pub fn compute_mask( - &self, - sample: &[u8; hp::Key::SAMPLE_SIZE], - ) -> Res<[u8; hp::Key::SAMPLE_SIZE]> { + pub fn compute_mask(&self, sample: &[u8]) -> Res<[u8; hp::Key::SAMPLE_SIZE]> { let mask = self.hpkey.mask(sample)?; qtrace!("[{self}] HP sample={} mask={}", hex(sample), hex(mask)); Ok(mask) @@ -682,7 +679,7 @@ impl CryptoDxState { // The numbers in `Self::limit` assume a maximum packet size of `LIMIT`. // Adjust them as we encounter larger packets. - let body_len = data.len() - hdr.len() - self.aead.expansion(); + let body_len = data.len() - hdr.len() - Aead::expansion(); debug_assert!(body_len <= u16::MAX.into()); if body_len > self.largest_packet_len { let new_bits = usize::leading_zeros(self.largest_packet_len - 1) @@ -704,8 +701,8 @@ impl CryptoDxState { } #[must_use] - pub fn expansion(&self) -> usize { - self.aead.expansion() + pub const fn expansion() -> usize { + Aead::expansion() } pub fn decrypt<'a>( @@ -745,8 +742,8 @@ impl CryptoDxState { /// Get the amount of extra padding packets protected with this profile need. /// This is the difference between the size of the header protection sample /// and the AEAD expansion. - pub fn extra_padding(&self) -> usize { - hp::Key::SAMPLE_SIZE.saturating_sub(self.expansion()) + pub const fn extra_padding() -> usize { + hp::Key::SAMPLE_SIZE.saturating_sub(Aead::expansion()) } } diff --git a/third_party/rust/neqo-transport/src/ecn.rs b/third_party/rust/neqo-transport/src/ecn.rs @@ -7,7 +7,7 @@ use std::ops::{AddAssign, Deref, DerefMut, Sub}; use enum_map::{Enum, EnumMap}; -use neqo_common::{qdebug, qinfo, Ecn}; +use neqo_common::{qdebug, qinfo, qwarn, Ecn}; use crate::{packet, recovery::sent, Stats}; @@ -302,7 +302,7 @@ impl Info { // > either the ECT(0) or ECT(1) codepoint set, ECN validation fails if the // > corresponding ECN counts are not present in the ACK frame. let Some(ack_ecn) = ack_ecn else { - qinfo!("ECN validation failed, no ECN counts in ACK frame"); + qwarn!("ECN validation failed, no ECN counts in ACK frame"); self.disable_ecn(stats, ValidationError::Bleaching); return; }; @@ -321,12 +321,12 @@ impl Info { let ecn_diff = ack_ecn - self.baseline; let sum_inc = ecn_diff[Ecn::Ect0] + ecn_diff[Ecn::Ce]; if sum_inc < newly_acked_sent_with_ect0 { - qinfo!( + qwarn!( "ECN validation failed, ACK counted {sum_inc} new marks, but {newly_acked_sent_with_ect0} of newly acked packets were sent with ECT(0)" ); self.disable_ecn(stats, ValidationError::Bleaching); } else if ecn_diff[Ecn::Ect1] > 0 { - qinfo!("ECN validation failed, ACK counted ECT(1) marks that were never sent"); + qwarn!("ECN validation failed, ACK counted ECT(1) marks that were never sent"); self.disable_ecn(stats, ValidationError::ReceivedUnsentECT1); } else if self.state != ValidationState::Capable { qinfo!("ECN validation succeeded, path is capable"); diff --git a/third_party/rust/neqo-transport/src/events.rs b/third_party/rust/neqo-transport/src/events.rs @@ -252,7 +252,6 @@ impl EventProvider for ConnectionEvents { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::event::Provider as _; diff --git a/third_party/rust/neqo-transport/src/fc.rs b/third_party/rust/neqo-transport/src/fc.rs @@ -657,7 +657,6 @@ impl IndexMut<StreamType> for LocalStreamLimits { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { #![allow( clippy::allow_attributes, diff --git a/third_party/rust/neqo-transport/src/frame.rs b/third_party/rust/neqo-transport/src/frame.rs @@ -686,7 +686,6 @@ impl<'a> Frame<'a> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::{Decoder, Encoder}; diff --git a/third_party/rust/neqo-transport/src/lib.rs b/third_party/rust/neqo-transport/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] - use neqo_common::qwarn; use neqo_crypto::Error as CryptoError; use thiserror::Error; diff --git a/third_party/rust/neqo-transport/src/pace.rs b/third_party/rust/neqo-transport/src/pace.rs @@ -139,7 +139,6 @@ impl Debug for Pacer { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::time::Duration; diff --git a/third_party/rust/neqo-transport/src/packet/mod.rs b/third_party/rust/neqo-transport/src/packet/mod.rs @@ -15,7 +15,7 @@ use std::{ use enum_map::Enum; use neqo_common::{hex, hex_with_len, qtrace, qwarn, Buffer, Decoder, Encoder}; -use neqo_crypto::{random, AeadTrait as _}; +use neqo_crypto::{random, Aead}; use strum::{EnumIter, FromRepr}; use crate::{ @@ -164,7 +164,7 @@ impl Builder<Vec<u8>> { debug_assert_ne!(token.len(), 0); encoder.encode(token); let tag = retry::use_aead(version, |aead| { - let mut buf = vec![0; aead.expansion()]; + let mut buf = vec![0; Aead::expansion()]; Ok(aead.encrypt(0, encoder.as_ref(), &[], &mut buf)?.to_vec()) })?; encoder.encode(&tag); @@ -416,12 +416,12 @@ impl<B: Buffer> Builder<B> { self.encoder.as_mut()[self.offsets.len + 1] = (len & 0xff) as u8; } - fn pad_for_crypto(&mut self, crypto: &CryptoDxState) { + fn pad_for_crypto(&mut self) { // Make sure that there is enough data in the packet. // The length of the packet number plus the payload length needs to // be at least 4 (MAX_PACKET_NUMBER_LEN) plus any amount by which // the header protection sample exceeds the AEAD expansion. - let crypto_pad = crypto.extra_padding(); + let crypto_pad = CryptoDxState::extra_padding(); self.encoder.pad_to( self.offsets.pn.start + MAX_PACKET_NUMBER_LEN + crypto_pad, 0, @@ -458,9 +458,9 @@ impl<B: Buffer> Builder<B> { return Err(Error::Internal); } - self.pad_for_crypto(crypto); + self.pad_for_crypto(); if self.offsets.len > 0 { - self.write_len(crypto.expansion()); + self.write_len(CryptoDxState::expansion()); } qtrace!( @@ -472,15 +472,15 @@ impl<B: Buffer> Builder<B> { // Add space for crypto expansion. let data_end = self.encoder.len(); - self.pad_to(data_end + crypto.expansion(), 0); + self.pad_to(data_end + CryptoDxState::expansion(), 0); // Calculate the mask. let ciphertext = crypto.encrypt(self.pn, self.header.clone(), self.encoder.as_mut())?; let offset = SAMPLE_OFFSET - self.offsets.pn.len(); - // `decode()` already checked that `decoder.remaining() >= SAMPLE_OFFSET + SAMPLE_SIZE`. - let sample = ciphertext[offset..offset + SAMPLE_SIZE] - .try_into() - .map_err(|_| Error::Internal)?; + if offset + SAMPLE_SIZE > ciphertext.len() { + return Err(Error::Internal); + } + let sample = &ciphertext[offset..offset + SAMPLE_SIZE]; let mask = crypto.compute_mask(sample)?; // Apply the mask. @@ -796,17 +796,17 @@ impl<'a> Public<'a> { debug_assert_ne!(self.packet_type, Type::VersionNegotiation); let sample_offset = self.header_len + SAMPLE_OFFSET; - let sample = self + let mask = self .data .get(sample_offset..(sample_offset + SAMPLE_SIZE)) - .ok_or(Error::NoMoreData)?; - let sample: &[u8; SAMPLE_SIZE] = sample.try_into()?; - qtrace!( - "{:?} unmask hdr={}", - crypto.version(), - hex(&self.data[..sample_offset]) - ); - let mask = crypto.compute_mask(sample)?; + .map_or(Err(Error::NoMoreData), |sample| { + qtrace!( + "{:?} unmask hdr={}", + crypto.version(), + hex(&self.data[..sample_offset]) + ); + crypto.compute_mask(sample) + })?; // Un-mask the leading byte. let bits = if self.packet_type == Type::Short { @@ -954,7 +954,6 @@ pub const PACKET_LIMIT: usize = 2048; #[cfg(all(test, not(feature = "disable-encryption")))] #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use neqo_common::Encoder; use test_fixture::{fixture_init, now}; @@ -1007,7 +1006,7 @@ mod tests { // So burn an encryption: let mut burn = [0; 16]; prot.encrypt(0, 0..0, &mut burn).expect("burn OK"); - assert_eq!(burn.len(), prot.expansion()); + assert_eq!(burn.len(), CryptoDxState::expansion()); let mut builder = Builder::long( Encoder::new(), diff --git a/third_party/rust/neqo-transport/src/packet/retry.rs b/third_party/rust/neqo-transport/src/packet/retry.rs @@ -7,7 +7,7 @@ use std::cell::RefCell; use neqo_common::qerror; -use neqo_crypto::{hkdf, Aead, AeadTrait as _, TLS_AES_128_GCM_SHA256, TLS_VERSION_1_3}; +use neqo_crypto::{hkdf, Aead, TLS_AES_128_GCM_SHA256, TLS_VERSION_1_3}; use crate::{version::Version, Error, Res}; @@ -50,6 +50,6 @@ where /// Determine how large the expansion is for a given key. pub fn expansion(version: Version) -> usize { - use_aead(version, |aead| Ok(aead.expansion())) + use_aead(version, |_| Ok(Aead::expansion())) .unwrap_or_else(|_| panic!("Unable to access Retry AEAD")) } diff --git a/third_party/rust/neqo-transport/src/pmtud.rs b/third_party/rust/neqo-transport/src/pmtud.rs @@ -315,32 +315,21 @@ impl Pmtud { /// Starts the next upward PMTUD probe. pub fn start(&mut self, now: Instant, stats: &mut Stats) { - if self.probe_index == SEARCH_TABLE_LEN - 1 { + if self.probe_index < SEARCH_TABLE_LEN - 1 // Not at the end of the search table + // Next size is <= iface MTU + && self.search_table[self.probe_index + 1] <= self.iface_mtu + { + self.probe_state = Probe::Needed; // We need to send a probe + self.probe_count = 0; // For the first time + self.probe_index += 1; // At this size qdebug!( - "PMTUD reached end of search table, i.e. {}, stopping upwards search", - self.mtu, - ); - self.stop(self.probe_index, now, stats); - return; - } - - if self.search_table[self.probe_index + 1] > self.iface_mtu { - qdebug!( - "PMTUD reached interface MTU limit {}, stopping upwards search at {}", - self.iface_mtu, - self.mtu + "PMTUD started with probe size {}", + self.search_table[self.probe_index], ); + } else { + // If we're at the end of the search table or hit the local interface MTU, we're done. self.stop(self.probe_index, now, stats); - return; } - - self.probe_state = Probe::Needed; // We need to send a probe - self.probe_count = 0; // For the first time - self.probe_index += 1; // At this size - qdebug!( - "PMTUD started with probe size {}", - self.search_table[self.probe_index], - ); } /// Returns the default PLPMTU for the given remote IP address. diff --git a/third_party/rust/neqo-transport/src/qlog.rs b/third_party/rust/neqo-transport/src/qlog.rs @@ -298,7 +298,7 @@ pub fn packets_lost(qlog: &Qlog, pkts: &[sent::Packet], now: Instant) { } #[expect(dead_code, reason = "TODO: Construct all variants.")] -pub enum Metric { +pub enum QlogMetric { MinRtt(Duration), SmoothedRtt(Duration), LatestRtt(Duration), @@ -313,7 +313,7 @@ pub enum Metric { PacingRate(u64), } -pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[Metric], now: Instant) { +pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[QlogMetric], now: Instant) { debug_assert!(!updated_metrics.is_empty()); qlog.add_event_data_with_instant( @@ -331,24 +331,24 @@ pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[Metric], now: Instant) { for metric in updated_metrics { match metric { - Metric::MinRtt(v) => min_rtt = Some(v.as_secs_f32() * 1000.0), - Metric::SmoothedRtt(v) => smoothed_rtt = Some(v.as_secs_f32() * 1000.0), - Metric::LatestRtt(v) => latest_rtt = Some(v.as_secs_f32() * 1000.0), - Metric::RttVariance(v) => rtt_variance = Some(v.as_secs_f32() * 1000.0), - Metric::PtoCount(v) => { + QlogMetric::MinRtt(v) => min_rtt = Some(v.as_secs_f32() * 1000.0), + QlogMetric::SmoothedRtt(v) => smoothed_rtt = Some(v.as_secs_f32() * 1000.0), + QlogMetric::LatestRtt(v) => latest_rtt = Some(v.as_secs_f32() * 1000.0), + QlogMetric::RttVariance(v) => rtt_variance = Some(v.as_secs_f32() * 1000.0), + QlogMetric::PtoCount(v) => { pto_count = Some(u16::try_from(*v).expect("fits in u16")); } - Metric::CongestionWindow(v) => { + QlogMetric::CongestionWindow(v) => { congestion_window = Some(u64::try_from(*v).expect("fits in u64")); } - Metric::BytesInFlight(v) => { + QlogMetric::BytesInFlight(v) => { bytes_in_flight = Some(u64::try_from(*v).expect("fits in u64")); } - Metric::SsThresh(v) => { + QlogMetric::SsThresh(v) => { ssthresh = Some(u64::try_from(*v).expect("fits in u64")); } - Metric::PacketsInFlight(v) => packets_in_flight = Some(*v), - Metric::PacingRate(v) => pacing_rate = Some(*v), + QlogMetric::PacketsInFlight(v) => packets_in_flight = Some(*v), + QlogMetric::PacingRate(v) => pacing_rate = Some(*v), _ => (), } } diff --git a/third_party/rust/neqo-transport/src/quic_datagrams.rs b/third_party/rust/neqo-transport/src/quic_datagrams.rs @@ -17,18 +17,6 @@ use crate::{ pub const MAX_QUIC_DATAGRAM: u64 = 65535; -/// Length of a [`FrameType::Datagram`] or [`FrameType::DatagramWithLen`] in -/// QUIC varint encoding. -pub const DATAGRAM_FRAME_TYPE_VARINT_LEN: usize = 1; -static_assertions::const_assert_eq!( - Encoder::varint_len(FrameType::Datagram as u64), - DATAGRAM_FRAME_TYPE_VARINT_LEN -); -static_assertions::const_assert_eq!( - Encoder::varint_len(FrameType::DatagramWithLen as u64), - DATAGRAM_FRAME_TYPE_VARINT_LEN -); - #[derive(Debug, Clone, Copy)] pub enum DatagramTracking { None, @@ -108,16 +96,12 @@ impl QuicDatagrams { ) { while let Some(dgram) = self.datagrams.pop_front() { let len = dgram.as_ref().len(); - if len + DATAGRAM_FRAME_TYPE_VARINT_LEN <= builder.remaining() { - // The datagram fits into the packet. + if builder.remaining() > len { + // We need 1 more than `len` for the Frame type. let length_len = Encoder::varint_len(u64::try_from(len).expect("usize fits in u64")); // Include a length if there is space for another frame after this one. - if builder.remaining() - >= DATAGRAM_FRAME_TYPE_VARINT_LEN - + length_len - + len - + packet::Builder::MINIMUM_FRAME_SIZE + if builder.remaining() >= 1 + length_len + len + packet::Builder::MINIMUM_FRAME_SIZE { builder.encode_varint(FrameType::DatagramWithLen); builder.encode_vvec(dgram.as_ref()); diff --git a/third_party/rust/neqo-transport/src/recovery/mod.rs b/third_party/rust/neqo-transport/src/recovery/mod.rs @@ -28,7 +28,7 @@ pub use token::{StreamRecoveryToken, Token, Tokens}; use crate::{ ecn, packet, path::{Path, PathRef}, - qlog, + qlog::{self, QlogMetric}, rtt::{RttEstimate, RttSource}, stats::{Stats, StatsCell}, tracking::{PacketNumberSpace, PacketNumberSpaceSet}, @@ -534,7 +534,7 @@ impl Loss { space.on_packet_sent(sent_packet); } else { qinfo!( - "[{self}] ignoring packet {} from dropped space {pn_space}", + "[{self}] ignoring {pn_space}-{} from dropped space", sent_packet.pn() ); } @@ -808,7 +808,7 @@ impl Loss { if let Some(st) = &mut self.pto_state { st.count_pto(&mut self.stats.borrow_mut()); - qlog::metrics_updated(&self.qlog, &[qlog::Metric::PtoCount(st.count())], now); + qlog::metrics_updated(&self.qlog, &[QlogMetric::PtoCount(st.count())], now); } } @@ -946,7 +946,6 @@ impl Display for Loss { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{ cell::RefCell, @@ -1247,9 +1246,9 @@ mod tests { fn reduce_min_rtt() { let mut lr = setup_lr(2); let delta = ms(4); - let reduced_rtt = TEST_RTT.checked_sub(delta).unwrap(); + let reduced_rtt = TEST_RTT - delta; ack(&mut lr, 1, reduced_rtt); - let expected_rtt = TEST_RTT.checked_sub(delta / 8).unwrap(); + let expected_rtt = TEST_RTT - (delta / 8); let expected_rttvar = (TEST_RTTVAR * 3 + delta) / 4; assert_rtts(&lr, reduced_rtt, expected_rtt, expected_rttvar, reduced_rtt); assert_no_sent_times(&lr); diff --git a/third_party/rust/neqo-transport/src/recovery/sent.rs b/third_party/rust/neqo-transport/src/recovery/sent.rs @@ -305,7 +305,6 @@ impl Packets { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{ cell::OnceCell, diff --git a/third_party/rust/neqo-transport/src/recv_stream.rs b/third_party/rust/neqo-transport/src/recv_stream.rs @@ -990,7 +990,6 @@ impl RecvStream { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{ cell::RefCell, diff --git a/third_party/rust/neqo-transport/src/rtt.rs b/third_party/rust/neqo-transport/src/rtt.rs @@ -15,7 +15,9 @@ use neqo_common::{qlog::Qlog, qtrace, Buffer}; use crate::{ ackrate::{AckRate, PeerAckDelay}, - packet, qlog, recovery, + packet, + qlog::{self, QlogMetric}, + recovery, stats::FrameStats, }; @@ -117,7 +119,7 @@ impl RttEstimate { // min_rtt ignores ack delay. self.min_rtt = min(self.min_rtt, rtt_sample); // Adjust for ack delay unless it goes below `min_rtt`. - if rtt_sample >= ack_delay + self.min_rtt { + if rtt_sample - self.min_rtt >= ack_delay { rtt_sample -= ack_delay; } @@ -141,10 +143,10 @@ impl RttEstimate { qlog::metrics_updated( qlog, &[ - qlog::Metric::LatestRtt(self.latest_rtt), - qlog::Metric::MinRtt(self.min_rtt), - qlog::Metric::SmoothedRtt(self.smoothed_rtt), - qlog::Metric::RttVariance(self.rttvar), + QlogMetric::LatestRtt(self.latest_rtt), + QlogMetric::MinRtt(self.min_rtt), + QlogMetric::SmoothedRtt(self.smoothed_rtt), + QlogMetric::RttVariance(self.rttvar), ], now, ); diff --git a/third_party/rust/neqo-transport/src/send_stream.rs b/third_party/rust/neqo-transport/src/send_stream.rs @@ -1774,7 +1774,6 @@ pub struct RecoveryToken { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::{cell::RefCell, collections::VecDeque, num::NonZeroUsize, rc::Rc}; diff --git a/third_party/rust/neqo-transport/src/server.rs b/third_party/rust/neqo-transport/src/server.rs @@ -272,7 +272,7 @@ impl Server { } } - fn create_qlog_trace(&self, odcid: ConnectionIdRef<'_>, now: Instant) -> Qlog { + fn create_qlog_trace(&self, odcid: ConnectionIdRef<'_>) -> Qlog { self.qlog_dir .as_ref() .map_or_else(Qlog::disabled, |qlog_dir| { @@ -282,7 +282,6 @@ impl Server { Some("Neqo server qlog".to_string()), Some("Neqo server qlog".to_string()), format!("server-{odcid}"), - now, ) .unwrap_or_else(|e| { qerror!("failed to create Qlog: {e}"); @@ -296,7 +295,6 @@ impl Server { c: &mut Connection, initial: InitialDetails, orig_dcid: Option<ConnectionId>, - now: Instant, ) { let zcheck = self.zero_rtt_checker.clone(); if c.server_enable_0rtt(&self.anti_replay, zcheck).is_err() { @@ -307,7 +305,7 @@ impl Server { c.set_retry_cids(odcid, initial.src_cid, &initial.dst_cid); } c.set_validation(&self.address_validation); - c.set_qlog(self.create_qlog_trace(orig_dcid.unwrap_or(initial.dst_cid).as_cid_ref(), now)); + c.set_qlog(self.create_qlog_trace(orig_dcid.unwrap_or(initial.dst_cid).as_cid_ref())); if let Some(cfg) = &self.ech_config { if c.server_enable_ech(cfg.config, &cfg.public_name, &cfg.sk, &cfg.pk) .is_err() @@ -342,7 +340,7 @@ impl Server { match sconn { Ok(mut c) => { - self.setup_connection(&mut c, initial, orig_dcid, now); + self.setup_connection(&mut c, initial, orig_dcid); let out = c.process(Some(dgram), now); self.connections.push(Rc::new(RefCell::new(c))); out @@ -351,10 +349,7 @@ impl Server { qwarn!("[{self}] Unable to create connection"); if e == crate::Error::VersionNegotiation { crate::qlog::server_version_information_failed( - &self.create_qlog_trace( - orig_dcid.unwrap_or(initial.dst_cid).as_cid_ref(), - now, - ), + &self.create_qlog_trace(orig_dcid.unwrap_or(initial.dst_cid).as_cid_ref()), self.conn_params.get_versions().all(), initial.version.wire_version(), now, @@ -462,7 +457,7 @@ impl Server { ); crate::qlog::server_version_information_failed( - &self.create_qlog_trace(packet.dcid(), now), + &self.create_qlog_trace(packet.dcid()), self.conn_params.get_versions().all(), packet.wire_version(), now, diff --git a/third_party/rust/neqo-transport/src/sni.rs b/third_party/rust/neqo-transport/src/sni.rs @@ -70,7 +70,6 @@ pub fn find_sni(buf: &[u8]) -> Option<Range<usize>> { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { const BUF_WITH_SNI: &[u8] = &[ 0x01, // msg_type == 1 (ClientHello) diff --git a/third_party/rust/neqo-transport/src/stream_id.rs b/third_party/rust/neqo-transport/src/stream_id.rs @@ -141,7 +141,6 @@ impl Display for StreamId { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod test { use neqo_common::Role; diff --git a/third_party/rust/neqo-transport/src/tparams.rs b/third_party/rust/neqo-transport/src/tparams.rs @@ -882,7 +882,6 @@ where } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; diff --git a/third_party/rust/neqo-transport/src/tracking.rs b/third_party/rust/neqo-transport/src/tracking.rs @@ -619,7 +619,6 @@ impl Default for AckTracker { } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { use std::collections::HashSet; diff --git a/third_party/rust/neqo-transport/tests/connection.rs b/third_party/rust/neqo-transport/tests/connection.rs @@ -7,7 +7,7 @@ mod common; use common::assert_dscp; use neqo_common::{Datagram, Decoder, Encoder, Role}; -use neqo_crypto::AeadTrait as _; +use neqo_crypto::Aead; use neqo_transport::{ CloseReason, ConnectionParameters, Error, State, StreamType, Version, MIN_INITIAL_PACKET_SIZE, }; @@ -176,13 +176,13 @@ fn set_payload(server_packet: Option<&Datagram>, client_dcid: &[u8], payload: &[ - Encoder::varint_len(u64::try_from(pn_len + orig_payload.len()).unwrap()); header.truncate(len_pos); let mut enc = Encoder::new_borrowed_vec(&mut header); - enc.encode_varint(u64::try_from(4 + payload.len() + aead.expansion()).unwrap()); + enc.encode_varint(u64::try_from(4 + payload.len() + Aead::expansion()).unwrap()); enc.encode_uint(4, pn); header[0] = header[0] & 0xfc | 0b0000_0011; // Set the packet number length to 4. // And build a packet containing the given payload. let mut packet = header.clone(); - packet.resize(header.len() + payload.len() + aead.expansion(), 0); + packet.resize(header.len() + payload.len() + Aead::expansion(), 0); aead.encrypt(pn, &header, payload, &mut packet[header.len()..]) .unwrap(); header_protection::apply(&hp, &mut packet, protected_header.len()..header.len()); @@ -277,13 +277,13 @@ fn overflow_crypto() { .encode_vec(1, server_dcid) .encode_vec(1, server_scid) .encode_vvec(&[]) // token - .encode_varint(u64::try_from(2 + payload.len() + aead.expansion()).unwrap()); // length + .encode_varint(u64::try_from(2 + payload.len() + Aead::expansion()).unwrap()); // length let pn_offset = packet.len(); packet.encode_uint(2, pn); let mut packet = Vec::from(packet); let header = packet.clone(); - packet.resize(header.len() + payload.len() + aead.expansion(), 0); + packet.resize(header.len() + payload.len() + Aead::expansion(), 0); aead.encrypt(pn, &header, payload.as_ref(), &mut packet[header.len()..]) .unwrap(); header_protection::apply(&hp, &mut packet, pn_offset..(pn_offset + 2)); diff --git a/third_party/rust/neqo-transport/tests/retry.rs b/third_party/rust/neqo-transport/tests/retry.rs @@ -15,7 +15,7 @@ use std::{ use common::{assert_dscp, connected_server, default_server, generate_ticket}; use neqo_common::{hex_with_len, qdebug, qtrace, Datagram, Encoder, Role}; -use neqo_crypto::{generate_ech_keys, AeadTrait as _, AuthenticationStatus}; +use neqo_crypto::{generate_ech_keys, AuthenticationStatus}; use neqo_transport::{ server::ValidateAddress, CloseReason, ConnectionParameters, Error, State, StreamType, MIN_INITIAL_PACKET_SIZE, diff --git a/third_party/rust/neqo-transport/tests/server.rs b/third_party/rust/neqo-transport/tests/server.rs @@ -11,8 +11,7 @@ use std::{cell::RefCell, net::SocketAddr, rc::Rc, time::Duration}; use common::{connect, connected_server, default_server, find_ticket, generate_ticket, new_server}; use neqo_common::{qtrace, Datagram, Decoder, Encoder, Role}; use neqo_crypto::{ - generate_ech_keys, AeadTrait as _, AllowZeroRtt, AuthenticationStatus, ZeroRttCheckResult, - ZeroRttChecker, + generate_ech_keys, Aead, AllowZeroRtt, AuthenticationStatus, ZeroRttCheckResult, ZeroRttChecker, }; use neqo_transport::{ server::{ConnectionRef, Server, ValidateAddress}, @@ -459,12 +458,12 @@ fn bad_client_initial() { .encode_vec(1, d_cid) .encode_vec(1, s_cid) .encode_vvec(&[]) - .encode_varint(u64::try_from(payload_enc.len() + aead.expansion() + PN_LEN).unwrap()) + .encode_varint(u64::try_from(payload_enc.len() + Aead::expansion() + PN_LEN).unwrap()) .encode_byte(u8::try_from(pn >> 8).unwrap()) .encode_byte(u8::try_from(pn & 0xff).unwrap()); let mut ciphertext = header_enc.as_ref().to_vec(); - ciphertext.resize(header_enc.len() + payload_enc.len() + aead.expansion(), 0); + ciphertext.resize(header_enc.len() + payload_enc.len() + Aead::expansion(), 0); let v = aead .encrypt( pn, @@ -551,11 +550,11 @@ fn bad_client_initial_connection_close() { .encode_vec(1, d_cid) .encode_vec(1, s_cid) .encode_vvec(&[]) - .encode_varint(u64::try_from(payload_enc.len() + aead.expansion() + 1).unwrap()) + .encode_varint(u64::try_from(payload_enc.len() + Aead::expansion() + 1).unwrap()) .encode_byte(u8::try_from(pn).unwrap()); let mut ciphertext = header_enc.as_ref().to_vec(); - ciphertext.resize(header_enc.len() + payload_enc.len() + aead.expansion(), 0); + ciphertext.resize(header_enc.len() + payload_enc.len() + Aead::expansion(), 0); let v = aead .encrypt( pn, diff --git a/third_party/rust/neqo-udp/.cargo-checksum.json b/third_party/rust/neqo-udp/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"c44c53983661e7656b23b78b0eb7457f41e610ee3e456c957c137b75e7e882b9","build.rs":"bf57cd35a78f636c14c442c1926abc2deca3d137e9d207e4f2f960f5b8363b07","src/lib.rs":"18a9dafa4372d99ed26e2d8a2fde5060e587150630d8eedba4f5f6d4d9af916e"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"4686ec5f3ed44a508587b7d2012402ffd86ed5bad3c389a9f6e6b1062a4037e8","build.rs":"bf57cd35a78f636c14c442c1926abc2deca3d137e9d207e4f2f960f5b8363b07","src/lib.rs":"cae1b86b043ed971190f64cf12d18266575dfaba6e20138c762eee30e91c0e32"},"package":null} +\ No newline at end of file diff --git a/third_party/rust/neqo-udp/Cargo.toml b/third_party/rust/neqo-udp/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.81.0" name = "neqo-udp" -version = "0.17.0" +version = "0.16.1" authors = ["The Neqo Authors <necko@mozilla.com>"] build = "build.rs" autolib = false @@ -43,10 +43,7 @@ repository = "https://github.com/mozilla/neqo/" ignored = ["cfg_aliases"] [features] -bench = [ - "neqo-common/bench", - "log/release_max_level_info", -] +bench = ["neqo-common/bench"] fast-apple-datapath = ["quinn-udp/fast-apple-datapath"] [lib] @@ -102,7 +99,6 @@ literal_string_with_formatting_args = "allow" lossy_float_literal = "warn" map_with_unused_argument_over_ranges = "warn" mem_forget = "warn" -missing_asserts_for_indexing = "warn" mixed_read_write_in_expression = "warn" module_name_repetitions = "warn" multiple_crate_versions = "allow" @@ -110,8 +106,6 @@ multiple_inherent_impl = "warn" mutex_atomic = "warn" mutex_integer = "warn" needless_raw_strings = "warn" -non_ascii_literal = "warn" -non_zero_suggestions = "warn" partial_pub_fields = "warn" pathbuf_init_then_push = "warn" precedence_bits = "warn" @@ -164,8 +158,3 @@ unused_import_braces = "warn" unused_lifetimes = "warn" unused_macro_rules = "warn" unused_qualifications = "warn" - -[lints.rust.unexpected_cfgs] -level = "warn" -priority = 0 -check-cfg = ["cfg(coverage,coverage_nightly)"] diff --git a/third_party/rust/neqo-udp/src/lib.rs b/third_party/rust/neqo-udp/src/lib.rs @@ -4,7 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(coverage_nightly, feature(coverage_attribute))] #![expect( clippy::missing_errors_doc, reason = "Functions simply delegate to tokio and quinn-udp." @@ -255,17 +254,9 @@ impl<S: SocketRef> Socket<S> { ) -> Result<DatagramIter<'a>, io::Error> { recv_inner(local_address, &self.state, &self.inner, recv_buf) } - - /// Whether transmitted datagrams might get fragmented by the IP layer - /// - /// Returns `false` on targets which employ e.g. the `IPV6_DONTFRAG` socket option. - pub fn may_fragment(&self) -> bool { - self.state.may_fragment() - } } #[cfg(test)] -#[cfg_attr(coverage_nightly, coverage(off))] mod tests { #![allow( clippy::allow_attributes,