Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Feb 13, 2025
1 parent 76caa99 commit ff518d1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 30 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ qlog = { version = "0.13", default-features = false }
quinn-udp = { version = "0.5.6", default-features = false, features = ["direct-log", "fast-apple-datapath"] }
regex = { version = "1.9", default-features = false, features = ["unicode-perl"] }
static_assertions = { version = "1.1", default-features = false }
strum = { version = "0.26", default-features = false }
strum_macros = { version = "0.26", default-features = false }
url = { version = "2.5.3", default-features = false, features = ["std"] }

Expand Down
3 changes: 0 additions & 3 deletions neqo-crypto/src/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ experimental_api!(SSL_SecretCallback(
#[cfg_attr(windows, repr(i32))] // Windows has to be different, of coourse.
#[cfg_attr(not(windows), repr(u32))]
pub enum SecretDirection {
#[allow(trivial_numeric_casts, clippy::unnecessary_cast)]
// These cast are neccessary on Windows, where
Read = SSLSecretDirection::ssl_secret_read,
// These cast are neccessary on Windows, wher
Write = SSLSecretDirection::ssl_secret_write,
}

Expand Down
3 changes: 2 additions & 1 deletion neqo-transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ mtu = { version = "0.2.3", default-features = false } # neqo is only user curren
qlog = { workspace = true }
smallvec = { version = "1.13", default-features = false }
static_assertions = { workspace = true }
strum_macros = { workspace = true}
strum = { workspace = true }
strum_macros = { workspace = true }

[dev-dependencies]
criterion = { version = "0.5", default-features = false }
Expand Down
15 changes: 8 additions & 7 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use neqo_crypto::{
Server, ZeroRttChecker,
};
use smallvec::SmallVec;
use strum::IntoEnumIterator as _;

use crate::{
addr_valid::{AddressValidation, NewTokenState},
Expand Down Expand Up @@ -2399,7 +2400,7 @@ impl Connection {
let mut encoder = Encoder::with_capacity(profile.limit());
for space in PacketNumberSpace::iter() {
// Ensure we have tx crypto state for this epoch, or skip it.
let Some((epoch, tx)) = self.crypto.states.select_tx_mut(self.version, *space) else {
let Some((epoch, tx)) = self.crypto.states.select_tx_mut(self.version, space) else {
continue;
};

Expand All @@ -2416,7 +2417,7 @@ impl Connection {
let pn = Self::add_packet_number(
&mut builder,
tx,
self.loss_recovery.largest_acknowledged_pn(*space),
self.loss_recovery.largest_acknowledged_pn(space),
);
// The builder will set the limit to 0 if there isn't enough space for the header.
if builder.is_full() {
Expand Down Expand Up @@ -2445,10 +2446,10 @@ impl Connection {
let payload_start = builder.len();
let (mut tokens, mut ack_eliciting, mut padded) = (Vec::new(), false, false);
if let Some(close) = closing_frame {
self.write_closing_frames(close, &mut builder, *space, now, path, &mut tokens);
self.write_closing_frames(close, &mut builder, space, now, path, &mut tokens);
} else {
(tokens, ack_eliciting, padded) =
self.write_frames(path, *space, &profile, &mut builder, header_start != 0, now);
self.write_frames(path, space, &profile, &mut builder, header_start != 0, now);
}
if builder.packet_empty() {
// Nothing to include in this packet.
Expand Down Expand Up @@ -2503,7 +2504,7 @@ impl Connection {
self.loss_recovery.on_packet_sent(path, sent, now);
}

if *space == PacketNumberSpace::Handshake
if space == PacketNumberSpace::Handshake
&& self.role == Role::Server
&& self.state == State::Confirmed
{
Expand All @@ -2518,8 +2519,8 @@ impl Connection {
// do not support, because they may not save packets they can't
// decrypt yet.
if self.role == Role::Client
&& *space == PacketNumberSpace::Initial
&& !self.crypto.streams.is_empty(*space)
&& space == PacketNumberSpace::Initial
&& !self.crypto.streams.is_empty(space)
{
break;
}
Expand Down
11 changes: 6 additions & 5 deletions neqo-transport/src/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use enum_map::{enum_map, EnumMap};
use neqo_common::{qdebug, qinfo, qlog::NeqoQlog, qtrace, qwarn};
pub use sent::SentPacket;
use sent::SentPackets;
use strum::IntoEnumIterator as _;
pub use token::{RecoveryToken, StreamRecoveryToken};

use crate::{
Expand Down Expand Up @@ -825,17 +826,17 @@ impl LossRecovery {
// The spaces in which we will allow probing.
let mut allow_probes = PacketNumberSpaceSet::default();
for pn_space in PacketNumberSpace::iter() {
if let Some(t) = self.pto_time(rtt, *pn_space) {
allow_probes[*pn_space] = true;
if let Some(t) = self.pto_time(rtt, pn_space) {
allow_probes[pn_space] = true;
if t <= now {
qdebug!("[{self}] PTO timer fired for {pn_space}");
if let Some(space) = self.spaces.get_mut(*pn_space) {
if let Some(space) = self.spaces.get_mut(pn_space) {
lost.extend(
space
.pto_packets(PtoState::pto_packet_count(*pn_space))
.pto_packets(PtoState::pto_packet_count(pn_space))
.cloned(),
);
pto_space = pto_space.or(Some(*pn_space));
pto_space = pto_space.or(Some(pn_space));
}
}
}
Expand Down
19 changes: 5 additions & 14 deletions neqo-transport/src/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::{
use enum_map::{enum_map, Enum, EnumMap};
use neqo_common::{qdebug, qinfo, qtrace, qwarn, IpTosEcn};
use neqo_crypto::Epoch;
use strum::IntoEnumIterator as _;
use strum_macros::EnumIter;

use crate::{
ecn,
Expand All @@ -26,24 +28,13 @@ use crate::{
Error, Res,
};

#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Ord, Eq, Enum)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Ord, Eq, Enum, EnumIter)]
pub enum PacketNumberSpace {
Initial,
Handshake,
ApplicationData,
}

impl PacketNumberSpace {
pub fn iter() -> impl Iterator<Item = &'static Self> {
const SPACES: &[PacketNumberSpace] = &[
PacketNumberSpace::Initial,
PacketNumberSpace::Handshake,
PacketNumberSpace::ApplicationData,
];
SPACES.iter()
}
}

impl From<Epoch> for PacketNumberSpace {
fn from(epoch: Epoch) -> Self {
match epoch {
Expand Down Expand Up @@ -122,12 +113,12 @@ impl std::fmt::Debug for PacketNumberSpaceSet {
let mut first = true;
f.write_str("(")?;
for sp in PacketNumberSpace::iter() {
if self[*sp] {
if self[sp] {
if !first {
f.write_str("+")?;
first = false;
}
std::fmt::Display::fmt(sp, f)?;
std::fmt::Display::fmt(&sp, f)?;
}
}
f.write_str(")")
Expand Down

0 comments on commit ff518d1

Please sign in to comment.