Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process()
@ 2026-09-22  1:06 Eric Dumazet
  2026-09-23  1:22 ` Xuanqiang Luo
  2026-09-23  2:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-09-22  1:06 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
	eric.dumazet, Eric Dumazet

Since commit 3d501dd326fb ("tcp: do not accept ACK of bytes we never
sent"), tcp_ack() bounds the acceptable old ACK window by
min(tp->max_window, tp->bytes_acked).

When sk->sk_state == TCP_SYN_RECV, tp->bytes_acked is always 0, so
any segment with before(ack, prior_snd_una) immediately returns
-SKB_DROP_REASON_TCP_TOO_OLD_ACK and never reaches the old_ack label
(which returns 0).

Therefore, tcp_ack() can only return 0 in closing states (where old
ACKs are accepted), and can never return 0 in TCP_SYN_RECV.

Simplify the tcp_ack() return value check in tcp_rcv_state_process()
to only check for negative return values and remove the unreachable
!reason branch.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_input.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 92bc60716f33d81e9ce90d9de2e5d989ba71c8a3..892ff256e235272a8483a11949cc98b319dd7cc9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -7233,19 +7233,14 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 				  FLAG_UPDATE_TS_RECENT |
 				  FLAG_NO_CHALLENGE_ACK);
 
-	if ((int)reason <= 0) {
-		if (sk->sk_state == TCP_SYN_RECV) {
+	/* accept old ack (reason == 0) during closing */
+	if ((int)reason < 0) {
+		reason = -reason;
+		if (sk->sk_state == TCP_SYN_RECV)
 			/* send one RST */
-			if (!reason)
-				return SKB_DROP_REASON_TCP_OLD_ACK;
-			return -reason;
-		}
-		/* accept old ack during closing */
-		if ((int)reason < 0) {
-			tcp_send_challenge_ack(sk, false);
-			reason = -reason;
-			goto discard;
-		}
+			return reason;
+		tcp_send_challenge_ack(sk, false);
+		goto discard;
 	}
 	SKB_DR_SET(reason, NOT_SPECIFIED);
 	switch (sk->sk_state) {
-- 
2.55.0.1082.g2b9226bbc0-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process()
  2026-09-22  1:06 [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process() Eric Dumazet
@ 2026-09-23  1:22 ` Xuanqiang Luo
  2026-09-23  2:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Xuanqiang Luo @ 2026-09-23  1:22 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Simon Horman, Neal Cardwell, Kuniyuki Iwashima, netdev,
	eric.dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni

On 2026/9/22 at 09:06 Eric Dumazet wrote:
> Since commit 3d501dd326fb ("tcp: do not accept ACK of bytes we never
> sent"), tcp_ack() bounds the acceptable old ACK window by
> min(tp->max_window, tp->bytes_acked).
> 
> When sk->sk_state == TCP_SYN_RECV, tp->bytes_acked is always 0, so
> any segment with before(ack, prior_snd_una) immediately returns
> -SKB_DROP_REASON_TCP_TOO_OLD_ACK and never reaches the old_ack label
> (which returns 0).
> 
> Therefore, tcp_ack() can only return 0 in closing states (where old
> ACKs are accepted), and can never return 0 in TCP_SYN_RECV.
> 
> Simplify the tcp_ack() return value check in tcp_rcv_state_process()
> to only check for negative return values and remove the unreachable
> !reason branch.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

Thanks,
Xuanqiang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process()
  2026-09-22  1:06 [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process() Eric Dumazet
  2026-09-23  1:22 ` Xuanqiang Luo
@ 2026-09-23  2:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-23  2:10 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, horms, ncardwell, kuniyu, netdev,
	eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Sep 2026 01:06:27 +0000 you wrote:
> Since commit 3d501dd326fb ("tcp: do not accept ACK of bytes we never
> sent"), tcp_ack() bounds the acceptable old ACK window by
> min(tp->max_window, tp->bytes_acked).
> 
> When sk->sk_state == TCP_SYN_RECV, tp->bytes_acked is always 0, so
> any segment with before(ack, prior_snd_una) immediately returns
> -SKB_DROP_REASON_TCP_TOO_OLD_ACK and never reaches the old_ack label
> (which returns 0).
> 
> [...]

Here is the summary with links:
  - [net-next] tcp: remove dead code in tcp_rcv_state_process()
    https://git.kernel.org/netdev/net-next/c/944ae66642b7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-23  2:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22  1:06 [PATCH net-next] tcp: remove dead code in tcp_rcv_state_process() Eric Dumazet
2026-09-23  1:22 ` Xuanqiang Luo
2026-09-23  2:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox