Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2024 08:18:21 GMT
From:      Richard Scheffenegger <rscheff@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 04719681ba76 - stable/13 - tcp: prevent spurious empty segments and fix uncommon panic
Message-ID:  <202401150818.40F8ILU4084869@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=04719681ba76a0756492b42313ea744503b78358

commit 04719681ba76a0756492b42313ea744503b78358
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2024-01-08 08:25:39 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2024-01-15 05:22:17 +0000

    tcp: prevent spurious empty segments and fix uncommon panic
    
    Only try sending more data on pure ACKs when there is
    more data available in the send buffer.
    
    In the case of a retransmitted SYN not being sent due to
    an internal error, the snd_una/snd_nxt accounting could
    be off, leading to a panic. Pulling snd_nxt up to snd_una
    prevents this from happening.
    
    Reported by:           fengdreamer@126.com
    Reviewed by:           cc, tuexen, #transport
    MFC after:             1 week
    Sponsored by:          NetApp, Inc.
    Differential Revision: https://reviews.freebsd.org/D43343
    
    (cherry picked from commit f4574e2dc5a4719379496338257526aba484751b)
---
 sys/netinet/tcp_input.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 262e95d08071..af6afbd271bb 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1943,7 +1943,13 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
 					tcp_timer_activate(tp, TT_REXMT,
 						      tp->t_rxtcur);
 				sowwakeup(so);
-				if (sbavail(&so->so_snd))
+				/*
+				 * Only call tcp_output when there
+				 * is new data available to be sent
+				 * or we need to send an ACK.
+				 */
+				if (SEQ_GT(tp->snd_una + sbavail(&so->so_snd),
+				    tp->snd_max) || tp->t_flags & TF_ACKNOW)
 					(void) tp->t_fb->tfb_tcp_output(tp);
 				goto check_delack;
 			}
@@ -2112,6 +2118,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
 			tp->rcv_adv += min(tp->rcv_wnd,
 			    TCP_MAXWIN << tp->rcv_scale);
 			tp->snd_una++;		/* SYN is acked */
+			if (SEQ_LT(tp->snd_nxt, tp->snd_una))
+				tp->snd_nxt = tp->snd_una;
 			/*
 			 * If not all the data that was sent in the TFO SYN
 			 * has been acked, resend the remainder right away.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401150818.40F8ILU4084869>