From nobody Sat Aug 9 12:11:37 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 4bzfrn5XD8z648Sl; Sat, 09 Aug 2025 12:11:37 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bzfrn3x4Rz3hCQ; Sat, 09 Aug 2025 12:11:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754741497; 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=ygPu0LVOldcq20DKKuy2NiqVqKkU4V9ETJq6MCtXq+Q=; b=DEjHSRf7mMOQDYo1gaaBgqwl6rb/tZPHSHZaovdzQT5bwvnSSlzaWQFNYnnhCxxWzoqsce 6KVqFsxNWPdhBBig1cXZSsF5ZbbUdVvri0RtBxCT8w8sYY9IBvQmHDhSNb49aX49gP+qHF 5GR+3mYvYyEOlgMHLO6qXRB/cH553NJ4U1rNKrNKvE2F26jOQFjniSbCxvIxF/RZIiX/Rl SsUpBhVgVZeQ968KCb/OBJOebsnj51raxJ0oNJw3nF9nPxsp7gdJcu6hTWOuzVgvm1e03h Y0u/SO9e+c7EN7pNW5CcnCMaL+mZfZwbisBBKvZPiY/wv/gZZkl4W68Yp6VVpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754741497; 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=ygPu0LVOldcq20DKKuy2NiqVqKkU4V9ETJq6MCtXq+Q=; b=PVfNEHSwbbh6jbGsCGPEFYP1YudzchSdicZGoQR7PNLqfXAnNp46I8P2pneeTq3gkk6Iwf 39H57rB2V+gYWHNjtchdygozfF2afj+QDyHbnopTdaFFpVuePogRlpuj298rDS4Oqr5lMp voblT7vDVoywdVDCO1o9HlELQaVXpCxdICXuccpnJqrgGu0uuH518vWvSb8+sjOIvZfxJ8 mJiNPOhL89iuvZkEZUI0QWuKV5Eh90kE9tHmyJqO12+fEv0OkdctGBW02pDXPnhDfHMeBZ 5OdsxV18D+kknXyoB/9dazPLPxtRLTAGsCNrZ+84fgLRfXih6eMgpq/oVtGfrQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754741497; a=rsa-sha256; cv=none; b=TKnZqyGPEpVJpeUL/f+v9Mq58Tbu8u9iOQpc9xrB3ahtLzjL4kC+CYPl9PlYlS8wrYJzuP lw1z9F6wQ/yWps+9bEUhiaI1qiNH9/Ho+D4LDzlmFskNG51tGGm7YDSAuugJADio7n1wQw LFLCLG4j+TjlIz6HI+7QzhERm1yuxKIPsfaXKz03ubJrCoNRD7n+SR/7UQly8NTX2NX+ZK 7kAdbuCNIP83goF509alGC9BSvcmcmmQ6NWCXq719tCD6HHFhv735nZz4aJBcoi71hyGqI x8ZfJdxn0vi7Ed8VYlrJoGQLadFaAxiO/OqsHt25CR3e5VMGuNhg98sGbtmz5g== 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 4bzfrn3JqWz4fF; Sat, 09 Aug 2025 12:11:37 +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 579CBbZ9074424; Sat, 9 Aug 2025 12:11:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 579CBbhf074421; Sat, 9 Aug 2025 12:11:37 GMT (envelope-from git) Date: Sat, 9 Aug 2025 12:11:37 GMT Message-Id: <202508091211.579CBbhf074421@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 2eb786d96e97 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 2eb786d96e97a953d0256d1d622c4853964be2dc Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=2eb786d96e97a953d0256d1d622c4853964be2dc commit 2eb786d96e97a953d0256d1d622c4853964be2dc Author: Michael Tuexen AuthorDate: 2025-08-07 20:23:54 +0000 Commit: Michael Tuexen CommitDate: 2025-08-07 20:23:54 +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 MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D51815 --- 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 fa0a1661e37d..d392cbe09950 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1134,7 +1134,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; @@ -1568,7 +1568,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; } @@ -2346,7 +2346,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 ce4e9f30020c..f2960ab9c636 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -7863,7 +7863,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); } @@ -9405,7 +9405,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 d6bbfeb886d9..2dfcad84ad99 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -12038,7 +12038,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); } } @@ -13518,7 +13518,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)