Skip to content

Commit

Permalink
Merge branch 'main' into fix-1943471
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Jan 31, 2025
2 parents c905197 + 1090de3 commit 3956b7d
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 171 deletions.
4 changes: 2 additions & 2 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,13 @@ impl Http3Connection {
match conn.stream_fairness(stream_id, true) {
Ok(()) | Err(neqo_transport::Error::InvalidStreamId) => (),
Err(e) => return Err(Error::from(e)),
};
}
qinfo!("[{self}] A new WebTransport stream {stream_id} for session {session_id}");
}
NewStreamType::Unknown => {
conn.stream_stop_sending(stream_id, Error::HttpStreamCreation.code())?;
}
};
}

match stream_type {
NewStreamType::Control | NewStreamType::Decoder | NewStreamType::Encoder => {
Expand Down
14 changes: 7 additions & 7 deletions neqo-http3/src/connection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ mod tests {
assert_eq!(err, CloseReason::Application(expected.code()));
}
_ => panic!("Wrong state {:?}", client.state()),
};
}
}

/// Create a http3 client with default configuration.
Expand Down Expand Up @@ -3679,7 +3679,7 @@ mod tests {
panic!("We should not receive a DataGeadable event!");
}
_ => {}
};
}
}

// ok NOW send fin
Expand All @@ -3703,7 +3703,7 @@ mod tests {
assert!(fin);
}
_ => {}
};
}
}

// Stream should now be closed and gone
Expand Down Expand Up @@ -3755,7 +3755,7 @@ mod tests {
assert_eq!(Ok((0, true)), client.read_data(now(), stream_id, &mut buf));
}
_ => {}
};
}
}

// Stream should now be closed and gone
Expand Down Expand Up @@ -3804,7 +3804,7 @@ mod tests {
panic!("We should not receive a DataGeadable event!");
}
_ => {}
};
}
}

// ok NOW send fin
Expand All @@ -3828,7 +3828,7 @@ mod tests {
assert!(fin);
}
_ => {}
};
}
}

// Stream should now be closed and gone
Expand Down Expand Up @@ -3875,7 +3875,7 @@ mod tests {
assert!(!fin);
}
_ => {}
};
}
}

// ok NOW send fin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,5 @@ fn wrong_setting_value() {
assert_eq!(err, CloseReason::Application(Error::HttpSettings.code()));
}
_ => panic!("Wrong state {:?}", client.state()),
};
}
}
2 changes: 1 addition & 1 deletion neqo-http3/src/frames/tests/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn test_reading_frame<T: FrameDecoder<T> + PartialEq + Debug>(
assert!(fin);
assert!(f.is_none());
}
};
}
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion neqo-http3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl Error {
_ => {
debug_assert!(false, "Unexpected error");
}
};
}
Self::TransportStreamDoesNotExist
}

Expand Down
4 changes: 2 additions & 2 deletions neqo-http3/src/recv_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl RecvMessage {
break self.set_state_to_close_pending(post_readable_event);
}
}
};
}
}
RecvMessageState::DecodingHeaders { header_block, fin } => {
if self
Expand Down Expand Up @@ -338,7 +338,7 @@ impl RecvMessage {
// WebTransportSession
break Ok(());
}
};
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion neqo-http3/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl HSettings {
// other supported settings here
(Some(_), Some(_)) => {} // ignore unknown setting, it is fine.
_ => return Err(Error::NotEnoughData),
};
}
}
Ok(())
}
Expand Down
52 changes: 0 additions & 52 deletions neqo-transport/src/connection/dump.rs

This file was deleted.

64 changes: 34 additions & 30 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::{
cell::RefCell,
cmp::{max, min},
fmt::{self, Debug},
fmt::{self, Debug, Write as _},
iter, mem,
net::{IpAddr, SocketAddr},
num::NonZeroUsize,
Expand Down Expand Up @@ -44,7 +44,7 @@ use crate::{
CloseError, Frame, FrameType, FRAME_TYPE_CONNECTION_CLOSE_APPLICATION,
FRAME_TYPE_CONNECTION_CLOSE_TRANSPORT,
},
packet::{DecryptedPacket, PacketBuilder, PacketNumber, PacketType, PublicPacket},
packet::{self, DecryptedPacket, PacketBuilder, PacketNumber, PacketType, PublicPacket},
path::{Path, PathRef, Paths},
qlog,
quic_datagrams::{DatagramTracking, QuicDatagrams},
Expand All @@ -61,15 +61,13 @@ use crate::{
AppError, CloseReason, Error, Res, StreamId,
};

mod dump;
mod idle;
pub mod params;
mod saved;
mod state;
#[cfg(test)]
pub mod test_internal;

use dump::dump_packet;
use idle::IdleTimeout;
pub use params::ConnectionParameters;
use params::PreferredAddressConfig;
Expand Down Expand Up @@ -1605,15 +1603,9 @@ impl Connection {
Ok(payload) => {
// OK, we have a valid packet.
self.idle_timeout.on_packet_received(now);
dump_packet(
self,
path,
"-> RX",
payload.packet_type(),
payload.pn(),
&payload[..],
d.tos(),
d.len(),
self.log_packet(
packet::MetaData::new_in(path, d.tos(), packet.len(), &payload),
now,
);

#[cfg(feature = "build-fuzzing-corpus")]
Expand All @@ -1626,7 +1618,6 @@ impl Connection {
neqo_common::write_item_to_fuzzing_corpus(target, &payload[..]);
}

qlog::packet_received(&self.qlog, &packet, &payload, now);
let space = PacketNumberSpace::from(payload.packet_type());
if let Some(space) = self.acks.get_mut(space) {
if space.is_duplicate(payload.pn()) {
Expand Down Expand Up @@ -2450,22 +2441,14 @@ impl Connection {
continue;
}

dump_packet(
self,
path,
"TX ->",
pt,
pn,
&builder.as_ref()[payload_start..],
path.borrow().tos(),
builder.len() + aead_expansion,
);
qlog::packet_sent(
&self.qlog,
pt,
pn,
builder.len() - header_start + aead_expansion,
&builder.as_ref()[payload_start..],
self.log_packet(
packet::MetaData::new_out(
path,
pt,
pn,
builder.len() + aead_expansion,
&builder.as_ref()[payload_start..],
),
now,
);

Expand Down Expand Up @@ -3564,6 +3547,27 @@ impl Connection {
pub fn plpmtu(&self) -> usize {
self.paths.primary().unwrap().borrow().plpmtu()
}

fn log_packet(&self, meta: packet::MetaData, now: Instant) {
if !log::log_enabled!(log::Level::Debug) {
return;
}

let mut s = String::new();
let mut d = Decoder::from(meta.payload());
while d.remaining() > 0 {
let Ok(f) = Frame::decode(&mut d) else {
s.push_str(" [broken]...");
break;
};
let x = f.dump();
if !x.is_empty() {
_ = write!(&mut s, "\n {} {}", meta.direction(), &x);
}
}
qdebug!("[{self}] {meta}{s}");
qlog::packet_io(&self.qlog, meta, now);
}
}

impl EventProvider for Connection {
Expand Down
Loading

0 comments on commit 3956b7d

Please sign in to comment.