Skip to content

Commit

Permalink
Remove feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sterlingdeng committed Sep 24, 2024
1 parent 3fd8f2e commit 3af9df4
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 127 deletions.
1 change: 0 additions & 1 deletion quinn-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ring = ["dep:ring"]
platform-verifier = ["dep:rustls-platform-verifier"]
# Configure `tracing` to log events via `log` if no `tracing` subscriber exists.
log = ["tracing/log"]
acktimestamps = []

[dependencies]
arbitrary = { workspace = true, optional = true }
Expand Down
16 changes: 3 additions & 13 deletions quinn-proto/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pub struct TransportConfig {
pub(crate) mtu_discovery_config: Option<MtuDiscoveryConfig>,
pub(crate) ack_frequency_config: Option<AckFrequencyConfig>,

#[cfg(feature = "acktimestamps")]
pub(crate) ack_timestamp_config: Option<AckTimestampsConfig>,

pub(crate) persistent_congestion_threshold: u32,
Expand Down Expand Up @@ -230,7 +229,6 @@ impl TransportConfig {
/// Defaults to `None`, which disables receiving acknowledgement timestamps from the sender.
/// If `Some`, TransportParameters are sent to the peer to enable acknowledgement timestamps
/// if supported.
#[cfg(feature = "acktimestamps")]
pub fn ack_timestamp_config(&mut self, value: Option<AckTimestampsConfig>) -> &mut Self {
self.ack_timestamp_config = value;
self
Expand Down Expand Up @@ -374,7 +372,6 @@ impl Default for TransportConfig {

enable_segmentation_offload: true,

#[cfg(feature = "acktimestamps")]
ack_timestamp_config: None,
}
}
Expand Down Expand Up @@ -406,7 +403,6 @@ impl fmt::Debug for TransportConfig {
deterministic_packet_numbers: _,
congestion_controller_factory: _,
enable_segmentation_offload,
#[cfg(feature = "acktimestamps")]
ack_timestamp_config,
} = self;
let mut s = fmt.debug_struct("TransportConfig");
Expand Down Expand Up @@ -434,25 +430,20 @@ impl fmt::Debug for TransportConfig {
.field("datagram_receive_buffer_size", datagram_receive_buffer_size)
.field("datagram_send_buffer_size", datagram_send_buffer_size)
.field("congestion_controller_factory", &"[ opaque ]")
.field("enable_segmentation_offload", enable_segmentation_offload);

#[cfg(feature = "acktimestamps")]
s.field("ack_timestamp_config", ack_timestamp_config);

s.finish()
.field("enable_segmentation_offload", enable_segmentation_offload)
.field("ack_timestamp_config", ack_timestamp_config)
.finish()
}
}

/// Parameters for controlling the peer's acknowledgements with receiver timestamps.
#[cfg(feature = "acktimestamps")]
#[derive(Clone, Debug)]
pub struct AckTimestampsConfig {
pub(crate) max_timestamps_per_ack: VarInt,
pub(crate) exponent: VarInt,
pub(crate) basis: std::time::Instant,
}

#[cfg(feature = "acktimestamps")]
impl AckTimestampsConfig {
/// Sets the maximum number of timestamp entries per ACK frame.
pub fn max_timestamps_per_ack(&mut self, value: VarInt) -> &mut Self {
Expand All @@ -475,7 +466,6 @@ impl AckTimestampsConfig {
}
}

#[cfg(feature = "acktimestamps")]
impl Default for AckTimestampsConfig {
fn default() -> Self {
Self {
Expand Down
1 change: 0 additions & 1 deletion quinn-proto/src/congestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub trait Controller: Send + Sync {
}

#[allow(unused_variables)]
#[cfg(feature = "acktimestamps")]
/// Packet deliveries were confirmed with timestamps information.
fn on_ack_packet(
&mut self,
Expand Down
64 changes: 10 additions & 54 deletions quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ use crate::{
VarInt, MAX_STREAM_COUNT, MIN_INITIAL_SIZE, TIMER_GRANULARITY,
};

#[cfg(feature = "acktimestamps")]
use crate::config::AckTimestampsConfig;

#[cfg(feature = "acktimestamps")]
use crate::ack_timestamp_frame::AckTimestampFrame;

mod ack_frequency;
Expand Down Expand Up @@ -70,9 +68,7 @@ use paths::{PathData, PathResponses};

mod send_buffer;

#[cfg(feature = "acktimestamps")]
mod receiver_timestamps;
#[cfg(feature = "acktimestamps")]
pub(crate) use receiver_timestamps::{PacketTimestamp, ReceiverTimestamps};

pub(crate) mod spaces;
Expand Down Expand Up @@ -240,7 +236,6 @@ pub struct Connection {
//
// Ack Receive Timestamps
//
#[cfg(feature = "acktimestamps")]
peer_ack_timestamp_cfg: Option<AckTimestampsConfig>,

streams: StreamsState,
Expand Down Expand Up @@ -353,7 +348,6 @@ impl Connection {
&TransportParameters::default(),
)),

#[cfg(feature = "acktimestamps")]
peer_ack_timestamp_cfg: None,

pto_count: 0,
Expand All @@ -380,10 +374,7 @@ impl Connection {
if side.is_client() {
// Kick off the connection
this.write_crypto();
this.init_0rtt(
#[cfg(feature = "acktimestamps")]
now,
);
this.init_0rtt(now);
}
this
}
Expand Down Expand Up @@ -839,7 +830,6 @@ impl Connection {
&mut self.spaces[space_id],
buf,
&mut self.stats,
#[cfg(feature = "acktimestamps")]
None,
);
}
Expand Down Expand Up @@ -1358,7 +1348,6 @@ impl Connection {
}
}

#[cfg(feature = "acktimestamps")]
fn on_ack_with_timestamp_received(
&mut self,
now: Instant,
Expand Down Expand Up @@ -1658,7 +1647,6 @@ impl Connection {
&self.path.rtt,
);

#[cfg(feature = "acktimestamps")]
self.path.congestion.on_ack_packet(
pn,
now,
Expand Down Expand Up @@ -2082,7 +2070,7 @@ impl Connection {
Ok(())
}

fn init_0rtt(&mut self, #[cfg(feature = "acktimestamps")] now: Instant) {
fn init_0rtt(&mut self, now: Instant) {
let (header, packet) = match self.crypto.early_crypto() {
Some(x) => x,
None => return,
Expand All @@ -2104,11 +2092,7 @@ impl Connection {
max_ack_delay: TransportParameters::default().max_ack_delay,
..params
};
self.set_peer_params(
params,
#[cfg(feature = "acktimestamps")]
now,
);
self.set_peer_params(params, now);
}
Err(e) => {
error!("session ticket has malformed transport parameters: {}", e);
Expand Down Expand Up @@ -2629,11 +2613,7 @@ impl Connection {
self.endpoint_events
.push_back(EndpointEventInner::ResetToken(self.path.remote, token));
}
self.handle_peer_params(
params,
#[cfg(feature = "acktimestamps")]
now,
)?;
self.handle_peer_params(params, now)?;
self.issue_first_cids(now);
} else {
// Server-only
Expand Down Expand Up @@ -2680,16 +2660,9 @@ impl Connection {
frame: None,
reason: "transport parameters missing".into(),
})?;
self.handle_peer_params(
params,
#[cfg(feature = "acktimestamps")]
now,
)?;
self.handle_peer_params(params, now)?;
self.issue_first_cids(now);
self.init_0rtt(
#[cfg(feature = "acktimestamps")]
now,
);
self.init_0rtt(now);
}
Ok(())
}
Expand Down Expand Up @@ -2759,7 +2732,6 @@ impl Connection {
return Ok(());
}

#[cfg(feature = "acktimestamps")]
Frame::AckTimestamps(ack) => {
self.on_ack_with_timestamp_received(now, packet.header.space(), ack)?;
}
Expand Down Expand Up @@ -2857,7 +2829,6 @@ impl Connection {
self.on_ack_received(now, SpaceId::Data, ack)?;
}

#[cfg(feature = "acktimestamps")]
Frame::AckTimestamps(ack) => {
self.on_ack_with_timestamp_received(now, SpaceId::Data, ack)?;
}
Expand Down Expand Up @@ -3247,7 +3218,6 @@ impl Connection {
space,
buf,
&mut self.stats,
#[cfg(feature = "acktimestamps")]
self.peer_ack_timestamp_cfg
.as_ref()
.map_or(None, |v| Some(v.clone())),
Expand Down Expand Up @@ -3435,7 +3405,7 @@ impl Connection {
space: &mut PacketSpace,
buf: &mut Vec<u8>,
stats: &mut ConnectionStats,
#[cfg(feature = "acktimestamps")] timestamp_config: Option<AckTimestampsConfig>,
timestamp_config: Option<AckTimestampsConfig>,
) {
debug_assert!(!space.pending_acks.ranges().is_empty());

Expand All @@ -3460,7 +3430,6 @@ impl Connection {
delay_micros
);

#[cfg(feature = "acktimestamps")]
if timestamp_config.is_some() {
let timestamp_config = timestamp_config.unwrap();
AckTimestampFrame::encode(
Expand All @@ -3476,10 +3445,6 @@ impl Connection {
frame::Ack::encode(delay as _, space.pending_acks.ranges(), ecn, buf);
}

if !cfg!(feature = "acktimestamps") {
frame::Ack::encode(delay as _, space.pending_acks.ranges(), ecn, buf);
}

stats.frame_tx.acks += 1;
}

Expand All @@ -3499,7 +3464,7 @@ impl Connection {
fn handle_peer_params(
&mut self,
params: TransportParameters,
#[cfg(feature = "acktimestamps")] now: Instant,
now: Instant,
) -> Result<(), TransportError> {
if Some(self.orig_rem_cid) != params.initial_src_cid
|| (self.side.is_client()
Expand All @@ -3511,20 +3476,12 @@ impl Connection {
));
}

self.set_peer_params(
params,
#[cfg(feature = "acktimestamps")]
now,
);
self.set_peer_params(params, now);

Ok(())
}

fn set_peer_params(
&mut self,
params: TransportParameters,
#[cfg(feature = "acktimestamps")] now: Instant,
) {
fn set_peer_params(&mut self, params: TransportParameters, now: Instant) {
self.streams.set_params(&params);
self.idle_timeout = match (self.config.max_idle_timeout, params.max_idle_timeout) {
(None, VarInt(0)) => None,
Expand All @@ -3546,7 +3503,6 @@ impl Connection {
u16::try_from(self.peer_params.max_udp_payload_size.into_inner()).unwrap_or(u16::MAX),
);

#[cfg(feature = "acktimestamps")]
{
self.peer_ack_timestamp_cfg = if let (Some(max_timestamps_per_ack), Some(exponent)) = (
params.max_recv_timestamps_per_ack,
Expand Down
1 change: 0 additions & 1 deletion quinn-proto/src/connection/packet_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ impl PacketBuilder {
retransmits: sent.retransmits,
stream_frames: sent.stream_frames,

#[cfg(feature = "acktimestamps")]
time_received: None,
};

Expand Down
9 changes: 0 additions & 9 deletions quinn-proto/src/connection/spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{
shared::IssuedCid, Dir, StreamId, TransportError, VarInt,
};

#[cfg(feature = "acktimestamps")]
use crate::connection::receiver_timestamps::ReceiverTimestamps;

pub(super) struct PacketSpace {
Expand Down Expand Up @@ -282,7 +281,6 @@ pub(super) struct SentPacket {
/// The time the packet was sent.
pub(super) time_sent: Instant,

#[cfg(feature = "acktimestamps")]
/// The time the packet was received by the receiver. The time Instant on this field is
/// relative to a basis negotiated by the two connections. Time arithmetic done using the
/// time_received field is only useful when compared to other time_received.
Expand Down Expand Up @@ -597,7 +595,6 @@ pub(super) struct PendingAcks {
/// The largest acknowledged packet number sent in an ACK frame
largest_acked: Option<u64>,

#[cfg(feature = "acktimestamps")]
receiver_timestamps: Option<ReceiverTimestamps>,
}

Expand All @@ -615,12 +612,10 @@ impl PendingAcks {
largest_ack_eliciting_packet: None,
largest_acked: None,

#[cfg(feature = "acktimestamps")]
receiver_timestamps: None,
}
}

#[cfg(feature = "acktimestamps")]
pub(super) fn set_receiver_timestamp(&mut self, max_timestamps: usize) {
self.receiver_timestamps = Some(ReceiverTimestamps::new(max_timestamps));
}
Expand Down Expand Up @@ -664,7 +659,6 @@ impl PendingAcks {
ack_eliciting: bool,
dedup: &Dedup,
) -> bool {
#[cfg(feature = "acktimestamps")]
if let Some(ts) = self.receiver_timestamps_as_mut() {
ts.add(packet_number, now);
}
Expand Down Expand Up @@ -774,7 +768,6 @@ impl PendingAcks {
pub(super) fn subtract_below(&mut self, max: u64) {
self.ranges.remove(0..(max + 1));

#[cfg(feature = "acktimestamps")]
self.receiver_timestamps.as_mut().map(|v| {
v.subtract_below(max);
});
Expand All @@ -785,12 +778,10 @@ impl PendingAcks {
&self.ranges
}

#[cfg(feature = "acktimestamps")]
pub(super) fn receiver_timestamps_as_mut(&mut self) -> Option<&mut ReceiverTimestamps> {
self.receiver_timestamps.as_mut()
}

#[cfg(feature = "acktimestamps")]
pub(super) fn receiver_timestamps_as_ref(&self) -> Option<&ReceiverTimestamps> {
self.receiver_timestamps.as_ref()
}
Expand Down
1 change: 0 additions & 1 deletion quinn-proto/src/connection/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ impl FrameStats {
Frame::Padding => {}
Frame::Ping => self.ping += 1,
Frame::Ack(_) => self.acks += 1,
#[cfg(feature = "acktimestamps")]
Frame::AckTimestamps(_) => self.acks += 1,
Frame::ResetStream(_) => self.reset_stream += 1,
Frame::StopSending(_) => self.stop_sending += 1,
Expand Down
Loading

0 comments on commit 3af9df4

Please sign in to comment.