diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 73c5b4189866..3fd0e215324d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -107,7 +107,8 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE; #define FLAG_TS_PROGRESS 0x40000 /* Positive timestamp delta */ #define FLAG_ACKED (FLAG_DATA_ACKED|FLAG_SYN_ACKED) -#define FLAG_NOT_DUP (FLAG_DATA|FLAG_WIN_UPDATE|FLAG_ACKED) +#define FLAG_NOT_DUP (FLAG_DATA|FLAG_WIN_UPDATE|FLAG_ACKED| \ + FLAG_SND_UNA_ADVANCED) #define FLAG_CA_ALERT (FLAG_DATA_SACKED|FLAG_ECE|FLAG_DSACKING_ACK) #define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED) @@ -3986,11 +3987,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 nwin <<= tp->rx_opt.snd_wscale; if (tcp_may_update_window(tp, ack, ack_seq, nwin)) { - flag |= FLAG_WIN_UPDATE; tcp_update_wl(tp, ack_seq); if (tp->snd_wnd != nwin) { tp->snd_wnd = nwin; + flag |= FLAG_WIN_UPDATE; /* Note, it is the only place, where * fast path is recovered for sending TCP. @@ -4381,7 +4382,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) */ tcp_update_wl(tp, ack_seq); tcp_snd_una_update(tp, ack); - flag |= FLAG_WIN_UPDATE; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPHPACKS); } else { diff --git a/tools/testing/selftests/net/packetdrill/tcp_bidir_fast_retransmit_nosack.pkt b/tools/testing/selftests/net/packetdrill/tcp_bidir_fast_retransmit_nosack.pkt new file mode 100644 index 000000000000..5c66b7171d22 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_bidir_fast_retransmit_nosack.pkt @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Verify that non-SACK connections properly detect duplicate acks when mixed +// with other data segments from peer. + +`./defaults.sh` + + 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4 + +0...0 connect(4, ..., ...) = 0 + + // Three-way handshake, SACK not supported by peer + +0 > S 0:0(0) + +0 < S. 0:0(0) ack 1 win 65535 + +0 > . 1:1(0) ack 1 + + // Send 1000 bytes, peer acks everything + +0 send(4, ..., 1000, 0) = 1000 + +0 > P. 1:1001(1000) ack 1 + +0 < . 1:1(0) ack 1001 win 65535 + + // Send 4000 more bytes + +0 send(4, ..., 4000, 0) = 4000 + +0 > P. 1001:5001(4000) ack 1 + + // Receive first dup-ack (considering segment 1001-2001 was lost) + +0 < . 1:1(0) ack 1001 win 65535 + + // Receive unrelated data segment from peer and ack it + +0 < P. 1:11(10) ack 1001 win 65535 + +0 > . 5001:5001(0) ack 11 + + // Receive second dup-ack + +0 < . 11:11(0) ack 1001 win 65535 + + // Receive another data segment from peer and ack it + +0 < P. 11:21(10) ack 1001 win 65535 + +0 > . 5001:5001(0) ack 21 + + // Receive third dup-ack, which should trigger fast retransmit (without + // waiting for RTO) + +0 < . 21:21(0) ack 1001 win 65535 + +0 > . 1001:2001(1000) ack 21