Skip to content

Commit

Permalink
feat(s2n-quic-dc): return from ConfirmComplete when no dc version neg…
Browse files Browse the repository at this point in the history
…otiated (#2278)
  • Loading branch information
WesleyRosenblum authored Jul 19, 2024
1 parent 518c0a9 commit f568f26
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 51 deletions.
8 changes: 8 additions & 0 deletions quic/s2n-quic-core/src/connection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ impl PartialEq for Error {
a.eq(b)
}
(Error::EndpointClosing { .. }, Error::EndpointClosing { .. }) => true,
(
Error::InvalidConfiguration {
reason: a_reason, ..
},
Error::InvalidConfiguration {
reason: b_reason, ..
},
) => a_reason.eq(b_reason),
(Error::Unspecified { .. }, Error::Unspecified { .. }) => true,
_ => false,
}
Expand Down
4 changes: 4 additions & 0 deletions quic/s2n-quic-core/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ pub mod api {
#[non_exhaustive]
VersionNegotiated { version: u32 },
#[non_exhaustive]
NoVersionNegotiated {},
#[non_exhaustive]
PathSecretsReady {},
#[non_exhaustive]
Complete {},
Expand Down Expand Up @@ -3560,6 +3562,7 @@ pub mod builder {
#[derive(Clone, Debug)]
pub enum DcState {
VersionNegotiated { version: u32 },
NoVersionNegotiated,
PathSecretsReady,
Complete,
}
Expand All @@ -3571,6 +3574,7 @@ pub mod builder {
Self::VersionNegotiated { version } => VersionNegotiated {
version: version.into_event(),
},
Self::NoVersionNegotiated => NoVersionNegotiated {},
Self::PathSecretsReady => PathSecretsReady {},
Self::Complete => Complete {},
}
Expand Down
1 change: 1 addition & 0 deletions quic/s2n-quic-events/events/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ enum BbrState {

enum DcState {
VersionNegotiated { version: u32 },
NoVersionNegotiated,
PathSecretsReady,
Complete,
}
10 changes: 9 additions & 1 deletion quic/s2n-quic-transport/src/space/session_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ use s2n_quic_core::{
dc,
dc::Endpoint as _,
event,
event::IntoEvent,
event::{
builder::{DcState, DcStateChanged},
IntoEvent,
},
packet::number::PacketNumberSpace,
time::Timestamp,
transport::{
Expand Down Expand Up @@ -459,6 +462,11 @@ impl<'a, Config: endpoint::Config, Pub: event::ConnectionPublisher>
let dc_path = self.dc.new_path(&conn_info);
crate::dc::Manager::new(dc_path, dc_version, self.publisher)
} else {
if Config::DcEndpoint::ENABLED {
self.publisher.on_dc_state_changed(DcStateChanged {
state: DcState::NoVersionNegotiated,
});
}
crate::dc::Manager::disabled()
};

Expand Down
16 changes: 11 additions & 5 deletions quic/s2n-quic/src/provider/dc/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,17 @@ impl Subscriber for ConfirmComplete {
) {
ensure!(matches!(context.state, State::Waiting(_)));

if let DcState::Complete { .. } = event.state {
// notify the application that the dc handshake has completed
context.update(State::Ready);
} else {
context.update(State::Waiting(Some(event.state.clone())));
match event.state {
DcState::NoVersionNegotiated { .. } => context.update(State::Failed(
Error::invalid_configuration("peer does not support specified dc versions"),
)),
DcState::Complete { .. } => {
// notify the application that the dc handshake has completed
context.update(State::Ready);
}
_ => {
context.update(State::Waiting(Some(event.state.clone())));
}
}
}
}
Loading

0 comments on commit f568f26

Please sign in to comment.