From nobody Tue Sep 30 20:08:49 2025 X-Original-To: dev-commits-src-main@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 4cbpzQ0DTGz69D43; Tue, 30 Sep 2025 20:08:50 +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 4cbpzP6dd4z3kN6; Tue, 30 Sep 2025 20:08:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759262930; 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=1LhaL9s8I/DNuJ4+JMVpwubb6P8Y1GPkQVX8yZyaeYs=; b=c+qn+SEGI/5nJu0iKdqeFRLqJ5+9W6o2cZDZuixCTE8/3GCyPjB3DtiyUbsm7MaDq8Qmqd kQ8fPwRymvwuZI/a3ETq+ytOnAT9j0QH91mQKNOmy5M5ZPHOIBy04u9WzbyUdQOeKGyX5u wNCGwqeTU716Rnna+76mhU6RV/t6t35s8D9sG3CveQvU+j0Q+rjNu6asEWu3zGCgAOXQ/Y Shdpf1bGllctTvEcz2y8aSKyB7IlqKRR9hNpbLHt7aWpwod9eFaaEQXQfKP8dg09upSnpV 26XL1786t1RkT33OS+MpSTEx0ifQnXTQEVMm9JNg7vfUjhtrqsozmCme4EZcpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759262930; 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=1LhaL9s8I/DNuJ4+JMVpwubb6P8Y1GPkQVX8yZyaeYs=; b=PBc1GdPVbPWFWq7o+8zEz7piHA2jPXYzdYhJP7iy4OnneorqWV17rwg9ATmqrN1GiyuTlg oyHEFqxUVAnPuCITbjraGbYAuCnSRJAOLAL7bqIRG/nHvYbQA0Tcoum7DjC5ml3YuEdiBY IkcOfKGBwciNUJuQAvb/D1/ok6mV+Z7R66F5h0BsNUKa7wZgBDu/2C6ETDmDSKwvTQ6ruS MCU2rzeqLq6wXLghFjZ/YsKNsELJI8uw7TOMpOj/gI7ofsVelliSLu80Evgk8KFWFmrkjT 7qzkV7vEsqAPtfaacQPLmSQkPcIKOWhoNuyiX9SmQWJX8In2/CZeb5D23EHt/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759262930; a=rsa-sha256; cv=none; b=DowgbYEphuXkQvLePnPfzIuNbM4B0wKhfMtCTqZD2Z9qkeSmCaQcdphLJSPL65fKLdUtMI q0ZKWW+HF1/pf/MbfD1IX4/NqtDGDmDunqIS5lZshKZcHuzGapf5Nauh7xKdLJynaR9GuR M221Ho4KT2xvG7V8qgQC90EXGWZhzOcqmMXzvz0HD1rD7/a2U+TOkMlohzMfr5QYCbUyhn xoiFSQFWccpJxDfzi442pULWH93DqkNkaw1NxJkaGADFZdBEjQcxCcni+qXVPjfoFH/3sc f+qF51jfHoBz9R/d/VPzja1y0LvC42r7gq0pBhQr80UUp2e6OE/x4yn5b2YDOA== 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 4cbpzP6C6HzrpQ; Tue, 30 Sep 2025 20:08:49 +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 58UK8nFC078897; Tue, 30 Sep 2025 20:08:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58UK8nBT078894; Tue, 30 Sep 2025 20:08:49 GMT (envelope-from git) Date: Tue, 30 Sep 2025 20:08:49 GMT Message-Id: <202509302008.58UK8nBT078894@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: c2900b6e8255 - main - tcp: apply rate limits to challenge ACKs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: c2900b6e8255ba4f54dbd897cf42427db577ed3d Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c2900b6e8255ba4f54dbd897cf42427db577ed3d commit c2900b6e8255ba4f54dbd897cf42427db577ed3d Author: Michael Tuexen AuthorDate: 2025-09-30 20:06:33 +0000 Commit: Michael Tuexen CommitDate: 2025-09-30 20:06:33 +0000 tcp: apply rate limits to challenge ACKs When sending challenge ACKs from the SYN-cache, apply the same rate limiting as in other states. Reviewed by: cc, rrs MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52754 --- sys/netinet/tcp_syncache.c | 28 ++++++++++++++++++++++++---- sys/netinet/tcp_syncache.h | 2 ++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 1ee6c6e31f33..72e9dccea9a5 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -122,6 +122,7 @@ static void syncache_drop(struct syncache *, struct syncache_head *); static void syncache_free(struct syncache *); static void syncache_insert(struct syncache *, struct syncache_head *); static int syncache_respond(struct syncache *, const struct mbuf *, int); +static int syncache_send_challenge_ack(struct syncache *, struct mbuf *); static struct socket *syncache_socket(struct syncache *, struct socket *, struct mbuf *m); static void syncache_timeout(struct syncache *sc, struct syncache_head *sch, @@ -694,10 +695,7 @@ syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th, struct mbuf *m, "sending challenge ACK\n", s, __func__, th->th_seq, sc->sc_irs + 1, sc->sc_wnd); - if (syncache_respond(sc, m, TH_ACK) == 0) { - TCPSTAT_INC(tcps_sndacks); - TCPSTAT_INC(tcps_sndtotal); - } else { + if (syncache_send_challenge_ack(sc, m) != 0) { syncache_drop(sc, sch); TCPSTAT_INC(tcps_sc_dropped); } @@ -963,6 +961,10 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) if (sc->sc_rxmits > 1) tp->snd_cwnd = 1; + /* Copy over the challenge ACK state. */ + tp->t_challenge_ack_end = sc->sc_challenge_ack_end; + tp->t_challenge_ack_cnt = sc->sc_challenge_ack_cnt; + #ifdef TCP_OFFLOAD /* * Allow a TOE driver to install its hooks. Note that we hold the @@ -2053,6 +2055,24 @@ syncache_respond(struct syncache *sc, const struct mbuf *m0, int flags) return (error); } +static int +syncache_send_challenge_ack(struct syncache *sc, struct mbuf *m) +{ + int error; + + if (tcp_challenge_ack_check(&sc->sc_challenge_ack_end, + &sc->sc_challenge_ack_cnt)) { + error = syncache_respond(sc, m, TH_ACK); + if (error == 0) { + TCPSTAT_INC(tcps_sndacks); + TCPSTAT_INC(tcps_sndtotal); + } + } else { + error = 0; + } + return (error); +} + /* * The purpose of syncookies is to handle spoofed SYN flooding DoS attacks * that exceed the capacity of the syncache by avoiding the storage of any diff --git a/sys/netinet/tcp_syncache.h b/sys/netinet/tcp_syncache.h index a336571f12c9..37f6ff3d6ca9 100644 --- a/sys/netinet/tcp_syncache.h +++ b/sys/netinet/tcp_syncache.h @@ -67,6 +67,8 @@ struct syncache { u_int8_t sc_requested_s_scale:4, sc_requested_r_scale:4; u_int16_t sc_flags; + u_int32_t sc_challenge_ack_cnt; /* chall. ACKs sent in epoch */ + sbintime_t sc_challenge_ack_end; /* End of chall. ack epoch */ #if defined(TCP_OFFLOAD) struct toedev *sc_tod; /* entry added by this TOE */ void *sc_todctx; /* TOE driver context */