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

fix: process packets from different sources before handshake confirmed #2463

Merged
merged 2 commits into from
Feb 1, 2025
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
10 changes: 10 additions & 0 deletions quic/s2n-quic-core/events/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ struct DatagramDropped<'a> {
reason: DatagramDropReason,
}

#[event("transport:handshake_remote_address_change_observed")]
/// The remote address was changed before the handshake was complete
struct HandshakeRemoteAddressChangeObserved<'a> {
local_addr: SocketAddress<'a>,
/// The newly observed remote address
remote_addr: SocketAddress<'a>,
/// The remote address established from the initial packet
initial_remote_addr: SocketAddress<'a>,
}

#[event("connectivity:connection_id_updated")]
//= https://tools.ietf.org/id/draft-marx-qlog-event-definitions-quic-h3-02#5.1.4
/// ConnectionId updated
Expand Down
136 changes: 136 additions & 0 deletions quic/s2n-quic-core/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,29 @@ pub mod api {
}
#[derive(Clone, Debug)]
#[non_exhaustive]
#[doc = " The remote address was changed before the handshake was complete"]
pub struct HandshakeRemoteAddressChangeObserved<'a> {
pub local_addr: SocketAddress<'a>,
#[doc = " The newly observed remote address"]
pub remote_addr: SocketAddress<'a>,
#[doc = " The remote address established from the initial packet"]
pub initial_remote_addr: SocketAddress<'a>,
}
#[cfg(any(test, feature = "testing"))]
impl<'a> crate::event::snapshot::Fmt for HandshakeRemoteAddressChangeObserved<'a> {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("HandshakeRemoteAddressChangeObserved");
fmt.field("local_addr", &self.local_addr);
fmt.field("remote_addr", &self.remote_addr);
fmt.field("initial_remote_addr", &self.initial_remote_addr);
fmt.finish()
}
}
impl<'a> Event for HandshakeRemoteAddressChangeObserved<'a> {
const NAME: &'static str = "transport:handshake_remote_address_change_observed";
}
#[derive(Clone, Debug)]
#[non_exhaustive]
#[doc = " ConnectionId updated"]
pub struct ConnectionIdUpdated<'a> {
pub path_id: u64,
Expand Down Expand Up @@ -3921,6 +3944,21 @@ pub mod tracing {
tracing :: event ! (target : "datagram_dropped" , parent : id , tracing :: Level :: DEBUG , { local_addr = tracing :: field :: debug (local_addr) , remote_addr = tracing :: field :: debug (remote_addr) , destination_cid = tracing :: field :: debug (destination_cid) , source_cid = tracing :: field :: debug (source_cid) , len = tracing :: field :: debug (len) , reason = tracing :: field :: debug (reason) });
}
#[inline]
fn on_handshake_remote_address_change_observed(
&mut self,
context: &mut Self::ConnectionContext,
_meta: &api::ConnectionMeta,
event: &api::HandshakeRemoteAddressChangeObserved,
) {
let id = context.id();
let api::HandshakeRemoteAddressChangeObserved {
local_addr,
remote_addr,
initial_remote_addr,
} = event;
tracing :: event ! (target : "handshake_remote_address_change_observed" , parent : id , tracing :: Level :: DEBUG , { local_addr = tracing :: field :: debug (local_addr) , remote_addr = tracing :: field :: debug (remote_addr) , initial_remote_addr = tracing :: field :: debug (initial_remote_addr) });
}
#[inline]
fn on_connection_id_updated(
&mut self,
context: &mut Self::ConnectionContext,
Expand Down Expand Up @@ -5978,6 +6016,32 @@ pub mod builder {
}
}
#[derive(Clone, Debug)]
#[doc = " The remote address was changed before the handshake was complete"]
pub struct HandshakeRemoteAddressChangeObserved<'a> {
pub local_addr: SocketAddress<'a>,
#[doc = " The newly observed remote address"]
pub remote_addr: SocketAddress<'a>,
#[doc = " The remote address established from the initial packet"]
pub initial_remote_addr: SocketAddress<'a>,
}
impl<'a> IntoEvent<api::HandshakeRemoteAddressChangeObserved<'a>>
for HandshakeRemoteAddressChangeObserved<'a>
{
#[inline]
fn into_event(self) -> api::HandshakeRemoteAddressChangeObserved<'a> {
let HandshakeRemoteAddressChangeObserved {
local_addr,
remote_addr,
initial_remote_addr,
} = self;
api::HandshakeRemoteAddressChangeObserved {
local_addr: local_addr.into_event(),
remote_addr: remote_addr.into_event(),
initial_remote_addr: initial_remote_addr.into_event(),
}
}
}
#[derive(Clone, Debug)]
#[doc = " ConnectionId updated"]
pub struct ConnectionIdUpdated<'a> {
pub path_id: u64,
Expand Down Expand Up @@ -7073,6 +7137,18 @@ mod traits {
let _ = meta;
let _ = event;
}
#[doc = "Called when the `HandshakeRemoteAddressChangeObserved` event is triggered"]
#[inline]
fn on_handshake_remote_address_change_observed(
&mut self,
context: &mut Self::ConnectionContext,
meta: &api::ConnectionMeta,
event: &api::HandshakeRemoteAddressChangeObserved,
) {
let _ = context;
let _ = meta;
let _ = event;
}
#[doc = "Called when the `ConnectionIdUpdated` event is triggered"]
#[inline]
fn on_connection_id_updated(
Expand Down Expand Up @@ -7783,6 +7859,16 @@ mod traits {
(self.1).on_datagram_dropped(&mut context.1, meta, event);
}
#[inline]
fn on_handshake_remote_address_change_observed(
&mut self,
context: &mut Self::ConnectionContext,
meta: &api::ConnectionMeta,
event: &api::HandshakeRemoteAddressChangeObserved,
) {
(self.0).on_handshake_remote_address_change_observed(&mut context.0, meta, event);
(self.1).on_handshake_remote_address_change_observed(&mut context.1, meta, event);
}
#[inline]
fn on_connection_id_updated(
&mut self,
context: &mut Self::ConnectionContext,
Expand Down Expand Up @@ -8348,6 +8434,11 @@ mod traits {
fn on_datagram_received(&mut self, event: builder::DatagramReceived);
#[doc = "Publishes a `DatagramDropped` event to the publisher's subscriber"]
fn on_datagram_dropped(&mut self, event: builder::DatagramDropped);
#[doc = "Publishes a `HandshakeRemoteAddressChangeObserved` event to the publisher's subscriber"]
fn on_handshake_remote_address_change_observed(
&mut self,
event: builder::HandshakeRemoteAddressChangeObserved,
);
#[doc = "Publishes a `ConnectionIdUpdated` event to the publisher's subscriber"]
fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated);
#[doc = "Publishes a `EcnStateChanged` event to the publisher's subscriber"]
Expand Down Expand Up @@ -8665,6 +8756,21 @@ mod traits {
self.subscriber.on_event(&self.meta, &event);
}
#[inline]
fn on_handshake_remote_address_change_observed(
&mut self,
event: builder::HandshakeRemoteAddressChangeObserved,
) {
let event = event.into_event();
self.subscriber.on_handshake_remote_address_change_observed(
self.context,
&self.meta,
&event,
);
self.subscriber
.on_connection_event(self.context, &self.meta, &event);
self.subscriber.on_event(&self.meta, &event);
}
#[inline]
fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated) {
let event = event.into_event();
self.subscriber
Expand Down Expand Up @@ -9106,6 +9212,7 @@ pub mod testing {
pub datagram_sent: u64,
pub datagram_received: u64,
pub datagram_dropped: u64,
pub handshake_remote_address_change_observed: u64,
pub connection_id_updated: u64,
pub ecn_state_changed: u64,
pub connection_migration_denied: u64,
Expand Down Expand Up @@ -9196,6 +9303,7 @@ pub mod testing {
datagram_sent: 0,
datagram_received: 0,
datagram_dropped: 0,
handshake_remote_address_change_observed: 0,
connection_id_updated: 0,
ecn_state_changed: 0,
connection_migration_denied: 0,
Expand Down Expand Up @@ -9605,6 +9713,20 @@ pub mod testing {
self.output.push(out);
}
}
fn on_handshake_remote_address_change_observed(
&mut self,
_context: &mut Self::ConnectionContext,
meta: &api::ConnectionMeta,
event: &api::HandshakeRemoteAddressChangeObserved,
) {
self.handshake_remote_address_change_observed += 1;
if self.location.is_some() {
let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
let event = crate::event::snapshot::Fmt::to_snapshot(event);
let out = format!("{meta:?} {event:?}");
self.output.push(out);
}
}
fn on_connection_id_updated(
&mut self,
_context: &mut Self::ConnectionContext,
Expand Down Expand Up @@ -10037,6 +10159,7 @@ pub mod testing {
pub datagram_sent: u64,
pub datagram_received: u64,
pub datagram_dropped: u64,
pub handshake_remote_address_change_observed: u64,
pub connection_id_updated: u64,
pub ecn_state_changed: u64,
pub connection_migration_denied: u64,
Expand Down Expand Up @@ -10117,6 +10240,7 @@ pub mod testing {
datagram_sent: 0,
datagram_received: 0,
datagram_dropped: 0,
handshake_remote_address_change_observed: 0,
connection_id_updated: 0,
ecn_state_changed: 0,
connection_migration_denied: 0,
Expand Down Expand Up @@ -10511,6 +10635,18 @@ pub mod testing {
self.output.push(out);
}
}
fn on_handshake_remote_address_change_observed(
&mut self,
event: builder::HandshakeRemoteAddressChangeObserved,
) {
self.handshake_remote_address_change_observed += 1;
let event = event.into_event();
if self.location.is_some() {
let event = crate::event::snapshot::Fmt::to_snapshot(&event);
let out = format!("{event:?}");
self.output.push(out);
}
}
fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated) {
self.connection_id_updated += 1;
let event = event.into_event();
Expand Down
20 changes: 20 additions & 0 deletions quic/s2n-quic-core/src/event/generated/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct Context<R: Recorder> {
datagram_sent: u64,
datagram_received: u64,
datagram_dropped: u64,
handshake_remote_address_change_observed: u64,
connection_id_updated: u64,
ecn_state_changed: u64,
connection_migration_denied: u64,
Expand Down Expand Up @@ -109,6 +110,7 @@ where
datagram_sent: 0,
datagram_received: 0,
datagram_dropped: 0,
handshake_remote_address_change_observed: 0,
connection_id_updated: 0,
ecn_state_changed: 0,
connection_migration_denied: 0,
Expand Down Expand Up @@ -417,6 +419,20 @@ where
.on_datagram_dropped(&mut context.recorder, meta, event);
}
#[inline]
fn on_handshake_remote_address_change_observed(
&mut self,
context: &mut Self::ConnectionContext,
meta: &api::ConnectionMeta,
event: &api::HandshakeRemoteAddressChangeObserved,
) {
context.handshake_remote_address_change_observed += 1;
self.subscriber.on_handshake_remote_address_change_observed(
&mut context.recorder,
meta,
event,
);
}
#[inline]
fn on_connection_id_updated(
&mut self,
context: &mut Self::ConnectionContext,
Expand Down Expand Up @@ -675,6 +691,10 @@ impl<R: Recorder> Drop for Context<R> {
.increment_counter("datagram_received", self.datagram_received as _);
self.recorder
.increment_counter("datagram_dropped", self.datagram_dropped as _);
self.recorder.increment_counter(
"handshake_remote_address_change_observed",
self.handshake_remote_address_change_observed as _,
);
self.recorder
.increment_counter("connection_id_updated", self.connection_id_updated as _);
self.recorder
Expand Down
Loading
Loading