From nobody Fri Sep 5 18:57:31 2025 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 4cJQZh0lBmz66Dmk; Fri, 05 Sep 2025 18:57:32 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cJQZg6yl3z3LPR; Fri, 05 Sep 2025 18:57:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757098652; 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=cPwwM1Bjqp9Y/wxj0j0tfG73TBmOtvzHJxk6WzeqXzw=; b=X6Ask9YbBRQv1OdPxQIYo/+SGc2unEfIjtX8Et3GNeZbtiUSEn/9fLYMtKN9R5frleze8P 13gjSkAdL1pu/PSXUzR89UNz1lLeS0DIy9u67Ch8yNj42Hcq1DmhSZiQ07WHSBMgOA0g+G OaW/c5azuoq3sXDzqe1NjD4+rI8h9+231xcHP3+enw4M/mnfj/mu5iO5d91h4rVPatB+Y5 mrs1NgnOoZFJjGIyQLk5CSgtUGsfbhrO0D/m/pYZ7imVQAWQSpN0qMsj9nGmyaW1cBrLva vEMzt2s0Wt2NO5ScgtBgmceZX3ZeggYjDaKAAgtBAzvgM60H0XgpBfYvdpZfPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757098652; 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=cPwwM1Bjqp9Y/wxj0j0tfG73TBmOtvzHJxk6WzeqXzw=; b=BrR1nKMZXKyIktBs1v4FIPrLdz3kpmEmuLZsisy+wXfh/oVeFAaas11y5Gn6dU75NMZpYA GVnrk2f8aT7BmEpjhH8D2GUQuswJ/5+bQ0a6eJumb92RtfDO86ukw+E9liPrqZNPj/YjHi hDuxxyFDxWeVNtBP7VwxZ/ifyWk2ORPBoiHMy/ixu3zjoqlJDY4wZtEP2diWSNbD3oqhGW nhPNjX41qAQjY16zfovBwKSMzWr4DMQxyUN2/0cLmFXImoNvytgcsGPDvy4YemrHponpVE cHjQGFdReKenaPOOFvsPlJkzOjngq464YHBl+oWnOd3WgWwTYB4bJ/2yQ5BIEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757098652; a=rsa-sha256; cv=none; b=txt9FaCYh2bAc77b3pdVBpoKBZDWgDIQNnHKCr7KEbv1p9KX7/MAIb79kekRkhEX5RV8tx 84tWGBkFPwg/C26WXx3uMNd9jWmbr+w+3fezMQ2wcq0wxYiWd14q1eXi4ChrxPTiVHSWNh mWC3M9Sy1YKgvVxrOUeRgKAenUlBNlbqeMBax3uKjBdXCWv5cCveZhaB1jnV3OaKMoTwym u+UaOg8Lf1LYi3ooYUNdeJb55svbSrNjkI7Y+fDD8WYjJ8e4UQLzEnWgx98qB5nKw1tWOZ vbQ+uEv8GsvX3NaRj1X4bMBCwKRm1Joi5x6mJrLy38eP5kmof2HW4wAkrWPVmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cJQZg6MMxz11Jp; Fri, 05 Sep 2025 18:57:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 585IvVgA018042; Fri, 5 Sep 2025 18:57:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 585IvVeV018038; Fri, 5 Sep 2025 18:57:31 GMT (envelope-from git) Date: Fri, 5 Sep 2025 18:57:31 GMT Message-Id: <202509051857.585IvVeV018038@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: e7331da314b5 - stable/14 - tcp: rate limit the sending of all RST segments 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e7331da314b57c39cf5c3fb5f20a2963b2485ce6 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=e7331da314b57c39cf5c3fb5f20a2963b2485ce6 commit e7331da314b57c39cf5c3fb5f20a2963b2485ce6 Author: Michael Tuexen AuthorDate: 2025-08-07 20:23:54 +0000 Commit: Michael Tuexen CommitDate: 2025-09-05 18:57:10 +0000 tcp: rate limit the sending of all RST segments Also rate limit the sending of RST segments in the following cases: * when receiving data on a closed socket. * when a socket can not be created at the end of the handshake and the sysctl-variable net.inet.tcp.syncache.rst_on_sock_fail is 1. * when an ACK segment is received in SYN SENT state and it does not acknowledge the SYN segment. After this change, there is no need anymore to provide a rstreason to tcp_dropwithreset(), since it is always BANDLIM_TCP_RST. This will be a follow-up commit, since it will change the code in a couple of places, but will not change the functionality. Reviewed by: rrs, Nick Banks, Peter Lei Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D51815 (cherry picked from commit 2eb786d96e97a953d0256d1d622c4853964be2dc) --- sys/netinet/tcp_input.c | 6 +++--- sys/netinet/tcp_stacks/bbr.c | 4 ++-- sys/netinet/tcp_stacks/rack.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 18b489f2e605..93d2e94bcff0 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1151,7 +1151,7 @@ tfo_socket_result: V_tcp_sc_rst_sock_fail ? "sending RST" : "try again"); if (V_tcp_sc_rst_sock_fail) { - rstreason = BANDLIM_UNLIMITED; + rstreason = BANDLIM_TCP_RST; goto dropwithreset; } else goto dropunlock; @@ -1598,7 +1598,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, */ if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && (SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { - rstreason = BANDLIM_UNLIMITED; + rstreason = BANDLIM_TCP_RST; tcp_log_end_status(tp, TCP_EI_STATUS_RST_IN_FRONT); goto dropwithreset; } @@ -2359,7 +2359,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); tp = tcp_close(tp); TCPSTAT_INC(tcps_rcvafterclose); - rstreason = BANDLIM_UNLIMITED; + rstreason = BANDLIM_TCP_RST; goto dropwithreset; } diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 65230bbd953f..c1053e90d6da 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -7852,7 +7852,7 @@ nothing_left: /* tcp_close will kill the inp pre-log the Reset */ tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); tp = tcp_close(tp); - ctf_do_dropwithreset(m, tp, th, BANDLIM_UNLIMITED, tlen); + ctf_do_dropwithreset(m, tp, th, BANDLIM_TCP_RST, tlen); BBR_STAT_INC(bbr_dropped_af_data); return (1); } @@ -9394,7 +9394,7 @@ close_now: tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); tp = tcp_close(tp); KMOD_TCPSTAT_INC(tcps_rcvafterclose); - ctf_do_dropwithreset(m, tp, th, BANDLIM_UNLIMITED, (*tlen)); + ctf_do_dropwithreset(m, tp, th, BANDLIM_TCP_RST, (*tlen)); return (1); } if (sbavail(&so->so_snd) == 0) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 10fc55bb2088..9a4ec0546b95 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -12428,7 +12428,7 @@ rack_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so, /* tcp_close will kill the inp pre-log the Reset */ tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); tp = tcp_close(tp); - ctf_do_dropwithreset(m, tp, th, BANDLIM_UNLIMITED, tlen); + ctf_do_dropwithreset(m, tp, th, BANDLIM_TCP_RST, tlen); return (1); } } @@ -13899,7 +13899,7 @@ rack_check_data_after_close(struct mbuf *m, tcp_log_end_status(tp, TCP_EI_STATUS_SERVER_RST); tp = tcp_close(tp); KMOD_TCPSTAT_INC(tcps_rcvafterclose); - ctf_do_dropwithreset(m, tp, th, BANDLIM_UNLIMITED, (*tlen)); + ctf_do_dropwithreset(m, tp, th, BANDLIM_TCP_RST, (*tlen)); return (1); } if (sbavail(&so->so_snd) == 0)