diff options
author | Richard Scheffenegger <rscheff@FreeBSD.org> | 2024-01-08 08:25:39 +0000 |
---|---|---|
committer | Richard Scheffenegger <rscheff@FreeBSD.org> | 2024-01-08 09:52:49 +0000 |
commit | f4574e2dc5a4719379496338257526aba484751b (patch) | |
tree | ef581ff6661a7ece5a1e714d1e81713e918d9aa1 | |
parent | a4a838a31ac24e19c8ee68d45cf5234615d0b958 (diff) | |
download | src-f4574e2dc5a4719379496338257526aba484751b.tar.gz src-f4574e2dc5a4719379496338257526aba484751b.zip |
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
-rw-r--r-- | sys/netinet/tcp_input.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 4a6100fc969b..0014c11d9daa 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1866,7 +1866,13 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, tcp_timer_activate(tp, TT_REXMT, TP_RXTCUR(tp)); 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) tcp_output(tp); goto check_delack; } @@ -2033,6 +2039,8 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, 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. |