From 805eed84473ababca496054d7ebb9ba65e931992 Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:31:27 -0400 Subject: [PATCH 1/2] fix: internal sACK flag not updated for client socket --- src/socket/tcp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index f944875ad..988bce905 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -1806,6 +1806,7 @@ impl<'a> Socket<'a> { self.remote_seq_no = repr.seq_number + 1; self.remote_last_seq = self.local_seq_no + 1; self.remote_last_ack = Some(repr.seq_number); + self.remote_has_sack = repr.sack_permitted; self.remote_win_scale = repr.window_scale; // Remote doesn't support window scaling, don't do it. if self.remote_win_scale.is_none() { From ffcb62e11923a7b51460ff6a0b3ced6c4d7fe14e Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:50:38 -0400 Subject: [PATCH 2/2] test(tcp): add coverage for remote_has_sack in SYN-SENT state --- src/socket/tcp.rs | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index 988bce905..46f1b36f9 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -3725,6 +3725,63 @@ mod test { assert_eq!(s.state, State::Closed); } + #[test] + fn test_syn_sent_sack_option() { + let mut s = socket_syn_sent(); + recv!( + s, + [TcpRepr { + control: TcpControl::Syn, + seq_number: LOCAL_SEQ, + ack_number: None, + max_seg_size: Some(BASE_MSS), + window_scale: Some(0), + sack_permitted: true, + ..RECV_TEMPL + }] + ); + send!( + s, + TcpRepr { + control: TcpControl::Syn, + seq_number: REMOTE_SEQ, + ack_number: Some(LOCAL_SEQ + 1), + max_seg_size: Some(BASE_MSS - 80), + window_scale: Some(0), + sack_permitted: true, + ..SEND_TEMPL + } + ); + assert!(s.remote_has_sack); + + let mut s = socket_syn_sent(); + recv!( + s, + [TcpRepr { + control: TcpControl::Syn, + seq_number: LOCAL_SEQ, + ack_number: None, + max_seg_size: Some(BASE_MSS), + window_scale: Some(0), + sack_permitted: true, + ..RECV_TEMPL + }] + ); + send!( + s, + TcpRepr { + control: TcpControl::Syn, + seq_number: REMOTE_SEQ, + ack_number: Some(LOCAL_SEQ + 1), + max_seg_size: Some(BASE_MSS - 80), + window_scale: Some(0), + sack_permitted: false, + ..SEND_TEMPL + } + ); + assert!(!s.remote_has_sack); + } + #[test] fn test_syn_sent_win_scale_buffers() { for (buffer_size, shift_amt) in &[