Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(qlog): log version_information on client #1505

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,12 @@ impl Connection {
.get_versions_mut()
.set_initial(self.conn_params.get_versions().initial());
mem::swap(self, &mut c);
qlog::client_version_information_negotiated(
&mut self.qlog,
self.conn_params.get_versions().all(),
supported,
version,
);
Ok(())
} else {
qinfo!([self], "Version negotiation: failed with {:?}", supported);
Expand Down Expand Up @@ -2302,6 +2308,7 @@ impl Connection {
qinfo!([self], "client_start");
debug_assert_eq!(self.role, Role::Client);
qlog::client_connection_started(&mut self.qlog, &self.paths.primary());
qlog::client_version_information_initiated(&mut self.qlog, self.conn_params.get_versions());

self.handshake(now, self.version, PacketNumberSpace::Initial, None)?;
self.set_state(State::WaitInitial);
Expand Down
39 changes: 38 additions & 1 deletion neqo-transport/src/qlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use qlog::events::{
connectivity::{ConnectionStarted, ConnectionState, ConnectionStateUpdated},
quic::{
AckedRanges, ErrorSpace, MetricsUpdated, PacketDropped, PacketHeader, PacketLost,
PacketReceived, PacketSent, QuicFrame, StreamType,
PacketReceived, PacketSent, QuicFrame, StreamType, VersionInformation,
},
Event, EventData, RawInfo,
};
Expand All @@ -33,6 +33,7 @@ use crate::{
stream_id::StreamType as NeqoStreamType,
tparams::{self, TransportParametersHandler},
tracking::SentPacket,
version::{Version, VersionConfig, WireVersion},
};

pub fn connection_tparams_set(qlog: &mut NeqoQlog, tph: &TransportParametersHandler) {
Expand Down Expand Up @@ -127,6 +128,42 @@ pub fn connection_state_updated(qlog: &mut NeqoQlog, new: &State) {
})
}

pub fn client_version_information_initiated(qlog: &mut NeqoQlog, version_config: &VersionConfig) {
qlog.add_event_data(|| {
Some(EventData::VersionInformation(VersionInformation {
client_versions: Some(
version_config
.all()
.iter()
.map(|v| format!("{:02x}", v.wire_version()))
.collect(),
),
server_versions: None,
chosen_version: Some(format!("{:02x}", version_config.initial().wire_version())),
}))
});
}

pub fn client_version_information_negotiated(
qlog: &mut NeqoQlog,
client: &[Version],
server: &[WireVersion],
chosen: Version,
) {
qlog.add_event_data(|| {
Some(EventData::VersionInformation(VersionInformation {
client_versions: Some(
client
.iter()
.map(|v| format!("{:02x}", v.wire_version()))
.collect(),
),
server_versions: Some(server.iter().map(|v| format!("{v:02x}")).collect()),
chosen_version: Some(format!("{:02x}", chosen.wire_version())),
}))
});
}

pub fn packet_sent(
qlog: &mut NeqoQlog,
pt: PacketType,
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/tests/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn overflow_crypto() {
decode_initial_header(client_initial.as_ref().unwrap(), Role::Client);
let client_dcid = client_dcid.to_owned();

let server_packet = server.process(client_initial, now()).dgram();
let server_packet = server.process(client_initial.as_ref(), now()).dgram();
let (server_initial, _) = split_datagram(server_packet.as_ref().unwrap());

// Now decrypt the server packet to get AEAD and HP instances.
Expand Down Expand Up @@ -184,7 +184,7 @@ fn overflow_crypto() {
server_initial.destination(),
packet,
);
client.process_input(dgram, now());
client.process_input(&dgram, now());
if let State::Closing { error, .. } = client.state() {
assert!(
matches!(
Expand Down
Loading