Skip to content

Commit 89c3aa2

Browse files
committed
tcp: Put pause_synack behind a feature flag
1 parent 99a7a36 commit 89c3aa2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ defmt = ["dep:defmt", "heapless/defmt-03"]
7272
"socket-raw" = ["socket"]
7373
"socket-udp" = ["socket"]
7474
"socket-tcp" = ["socket"]
75+
"socket-tcp-pause-synack" = ["socket-tcp"]
7576
"socket-icmp" = ["socket"]
7677
"socket-dhcpv4" = ["socket", "medium-ethernet", "proto-dhcpv4"]
7778
"socket-dns" = ["socket", "proto-dns"]

src/socket/tcp.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,6 @@ pub struct Socket<'a> {
527527
/// Used for rate-limiting: No more challenge ACKs will be sent until this instant.
528528
challenge_ack_timer: Instant,
529529

530-
/// If this is set, we will not send a SYN|ACK until this is unset.
531-
synack_paused: bool,
532-
533530
/// Nagle's Algorithm enabled.
534531
nagle: bool,
535532

@@ -546,6 +543,10 @@ pub struct Socket<'a> {
546543
rx_waker: WakerRegistration,
547544
#[cfg(feature = "async")]
548545
tx_waker: WakerRegistration,
546+
547+
/// If this is set, we will not send a SYN|ACK until this is unset.
548+
#[cfg(feature = "socket-tcp-pause-synack")]
549+
synack_paused: bool,
549550
}
550551

551552
const DEFAULT_MSS: usize = 536;
@@ -604,12 +605,14 @@ impl<'a> Socket<'a> {
604605
tsval_generator: None,
605606
last_remote_tsval: 0,
606607
congestion_controller: congestion::AnyController::new(),
607-
synack_paused: false,
608608

609609
#[cfg(feature = "async")]
610610
rx_waker: WakerRegistration::new(),
611611
#[cfg(feature = "async")]
612612
tx_waker: WakerRegistration::new(),
613+
614+
#[cfg(feature = "socket-tcp-pause-synack")]
615+
synack_paused: false,
613616
}
614617
}
615618

@@ -733,6 +736,7 @@ impl<'a> Socket<'a> {
733736
/// When this flag is set, the socket will get stuck in `SynReceived` state without sending
734737
/// any SYN|ACK packets back, until this flag is unset. This is useful for certain niche TCP
735738
/// proxy usecases.
739+
#[cfg(feature = "socket-tcp-pause-synack")]
736740
pub fn pause_synack(&mut self, pause: bool) {
737741
self.synack_paused = pause;
738742
}
@@ -2385,6 +2389,7 @@ impl<'a> Socket<'a> {
23852389
.on_retransmit(cx.now());
23862390
}
23872391

2392+
#[cfg(feature = "socket-tcp-pause-synack")]
23882393
if matches!(self.state, State::SynReceived) && self.synack_paused {
23892394
return Ok(());
23902395
}

0 commit comments

Comments
 (0)