From nobody Mon Jan 08 18:39:57 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T82t52tDvz56P59; Mon, 8 Jan 2024 18:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T82t52G1Qz49Kc; Mon, 8 Jan 2024 18:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704739197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MU5MgoSskyuyJNiJma12eJkWewmkX0eVUf8jTStsXKE=; b=S+APjGaYGSgPWnY9yxlbgT4OBpTQqe/VcPUywxFSobyXC5JzCJomVrtvptjAsv1X83kv+1 9a/HpNfSQtV20WEgci4pYmIjLKQ7vzbcX117d0zzlje4unbc5BjsDtGaSWbOL5o14xg5e4 6CLuO9+wtyRx5T8uussjzn3sQe7prcfiW5IzLs3TDMkbWqvjFkSWiCPUqyenwWTDKF4KBM XTiC2BF9qOuRIkg6Ahvb5ZNzboZcUo5O+30AJfr64PyCVOlNZ2WHdIGztbHUYueo5sx8yL jO2p6xda41zVr36RwZ6ytrE7v26mA2gio4YlkkGyw6HpheDtE976wyATVYWiQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704739197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MU5MgoSskyuyJNiJma12eJkWewmkX0eVUf8jTStsXKE=; b=Gf1v8ICiw4jZpmLWHVklvSKwBWFh6HttR+kwuou5+wtn+98GEKmWiIctV3QY/6qvfKd5gp 9VK/U2rY8zrU01sXqVgECHdOYUIGjB4/KwqUTFJjC+vBfzjYm4TtXxFbRU/O3s/U2eX7E6 3z4JXVz2VrCif0UUXB47gN3x/FcbIvy1ZgJa9h8u4T1XT7jVNcWbzRbWtjiLfD7HdWTwAg GVpRXQu+ljgp8ymsnBUZ2wNyqU0J+LdFW6jcGkLXSBdhqkhcOjGKmimzbrE52LAQ6WrlfL 4H9RqKVY3Da21zwRcU6B2/SY1XPThiKs6BOV1nanb/dkWWiEXnuEfr4sh+TLCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704739197; a=rsa-sha256; cv=none; b=o//9V69JW4gWJKaui+5rzMciVUyjTqxsV9Dhv4fAeAzS7KWXD0gR9kMKUPeU0/z5UzVkkw bbK6O9SZFjSEeKKr+QpfCha2Yer2+ibYNzWAgpKpGp7nlcYiLDbzibnFad3gqR+7ElwMLV TO/Iv9En9wtIJaKXByRaZBLyVnBgUENjbjJqs6oW4F/Qm1hw2fSQ8qOAwf6LDb73SYJN35 zN3mExVKCUV6pKNBF1IJOLh7WIDK6cD1suuLgJErLt4GeH9t8wdcKcgKlriFBQi9l8IaCH bSGBrE9KkVYZ7PXSvJixDYZOwwg2nYxlPrE2BuLVhNI2QpaXwQuTKUdTLsZp+A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T82t518y4zJPb; Mon, 8 Jan 2024 18:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 408Idvfb023941; Mon, 8 Jan 2024 18:39:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 408Idvbr023938; Mon, 8 Jan 2024 18:39:57 GMT (envelope-from git) Date: Mon, 8 Jan 2024 18:39:57 GMT Message-Id: <202401081839.408Idvbr023938@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: f4574e2dc5a4 - main - tcp: prevent spurious empty segments and fix uncommon panic List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f4574e2dc5a4719379496338257526aba484751b Auto-Submitted: auto-generated The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=f4574e2dc5a4719379496338257526aba484751b commit f4574e2dc5a4719379496338257526aba484751b Author: Richard Scheffenegger AuthorDate: 2024-01-08 08:25:39 +0000 Commit: Richard Scheffenegger CommitDate: 2024-01-08 09:52:49 +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 --- 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 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.