From nobody Tue Sep 09 18:04:47 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 4cLsCz4Bhcz67FXZ; Tue, 09 Sep 2025 18:04:47 +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 4cLsCz3NSMz3ftw; Tue, 09 Sep 2025 18:04:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757441087; 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=f3yJazICviDs8phhOyIxK71g4CXoW/5gFxroLY2MDNY=; b=i8PZFIZhBdlQae2WPKSa5N4bmbT5NtiZ57oMsndRxFLTo9copd36YFfh/iM6ng+jGHURAo rcEaRb9tGB4wmxTOWIlIlCyLbVq977YbTBGEWtXxJNeit2v9fRjS09VVSo+I4y91PjZIW8 Mw2fjizPq+/2UxFd0AWuykTQl9bY5L3sYj6zJlJkqYgL/gpeW6fZ7SlmRmFu3zdmnG15ZM Xt/vcnotN3uluTA3aSjLE9+y5X0ei8AnipU7Z9Y9Vf/HYIV21PlkhbMTJxNT76aSZKgOfq ZZ/qKYjkKugMemCCmlHLSZG9M8xBN6LveqA9PbVjO7Oyra2oNUoLaDdltPudKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757441087; 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=f3yJazICviDs8phhOyIxK71g4CXoW/5gFxroLY2MDNY=; b=Qb55E3oysIJUYFPNVANarkaoiltzT0VfJFAh25XeXX/dvYDjgwmYN9bLJ4E7R0XWKc1cN1 2wuQraempof94q1/DyINd/1Nh+hrhg5g92Ih9TTf8rupJvib4KLHzT42pjqNZpZ3T5BPc1 5rw6wklh4uDrBadFbSiIRxL42BTQbGpiKSucaudv0owYXf+b6pucZAVk+JPGZI4F0ejGlW fg75FN06JnZ5I2rNKpsMyXZB2h7sNMu35iHsXO4Bgi5gtCkdUImD4C4hdwBOcbHXtiWiAY rnAFBD0VZdjwXSsBXCdzfWpUm4U8crCFRYFGKErsPv8aqhFf3oF9fg52+xc5rg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757441087; a=rsa-sha256; cv=none; b=gEhHWvwCG0tgjtX4mZhzVRwtSuhKvD4mSCnufQYlzthbqWQpZtX69x/zTzfpIlgfBTj486 thd9N+GGDx+6DhnsijfEMNyE6vvZlRZGk/rf55kpmTbv8uytjgcn4FIPx77WRqrMqrbbl9 PSwGnURL/Hepev3SLFQlRql4rdUo0S8Yuha6tFyiZp5fEkoxBJwyBivCqAxbcKtJbKBOM0 EEiwVz4PuGwUtOgrJSxj1SmEwyRuHCJl+PUax6mLurkSQA8QB2LOYg6fTzWVq4ct3wj/3E TxfnNtnRqEHWX1kRS+MK2em/ohq9Ro7tqNzfh5pthxo8rLiu+dWlzjwz9kXoGA== 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 4cLsCz2vdzzmqv; Tue, 09 Sep 2025 18:04:47 +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 589I4llk084706; Tue, 9 Sep 2025 18:04:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 589I4lnV084703; Tue, 9 Sep 2025 18:04:47 GMT (envelope-from git) Date: Tue, 9 Sep 2025 18:04:47 GMT Message-Id: <202509091804.589I4lnV084703@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: d6849a3b13f2 - stable/14 - tcp: rename syncookie_lookup() into syncookie_expand() and make it bool 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: d6849a3b13f2f704aefd48fcfc6fc2d9c2834903 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d6849a3b13f2f704aefd48fcfc6fc2d9c2834903 commit d6849a3b13f2f704aefd48fcfc6fc2d9c2834903 Author: Gleb Smirnoff AuthorDate: 2025-06-17 15:50:01 +0000 Commit: Michael Tuexen CommitDate: 2025-09-09 18:02:14 +0000 tcp: rename syncookie_lookup() into syncookie_expand() and make it bool This function always returns the same pointer it was passed. With new name and return type the code is easier to understand. Mark the hash bucket argument as pointer to const, since function doesn't modify it, just uses value as integer. No functional changes. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D50895 (cherry picked from commit 6538742c1aaca3ce522ccea95007dfa9686c78dd) --- sys/netinet/tcp_syncache.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 29dbaaec929a..89d3f95601c9 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -139,10 +139,10 @@ static void syncache_timer(void *); static uint32_t syncookie_mac(struct in_conninfo *, tcp_seq, uint8_t, uint8_t *, uintptr_t); static tcp_seq syncookie_generate(struct syncache_head *, struct syncache *); -static struct syncache - *syncookie_lookup(struct in_conninfo *, struct syncache_head *, - struct syncache *, struct tcphdr *, struct tcpopt *, - struct socket *, uint16_t); +static bool syncookie_expand(struct in_conninfo *, + const struct syncache_head *, struct syncache *, + struct tcphdr *, struct tcpopt *, struct socket *, + uint16_t); static void syncache_pause(struct in_conninfo *); static void syncache_unpause(void *); static void syncookie_reseed(void *); @@ -1122,7 +1122,8 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, goto failed; } bzero(&scs, sizeof(scs)); - sc = syncookie_lookup(inc, sch, &scs, th, to, *lsop, port); + if (syncookie_expand(inc, sch, &scs, th, to, *lsop, port)) + sc = &scs; if (locked) SCH_UNLOCK(sch); if (sc == NULL) { @@ -2260,8 +2261,8 @@ syncookie_generate(struct syncache_head *sch, struct syncache *sc) return (iss); } -static struct syncache * -syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, +static bool +syncookie_expand(struct in_conninfo *inc, const struct syncache_head *sch, struct syncache *sc, struct tcphdr *th, struct tcpopt *to, struct socket *lso, uint16_t port) { @@ -2291,7 +2292,7 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, /* The recomputed hash matches the ACK if this was a genuine cookie. */ if ((ack & ~0xff) != (hash & ~0xff)) - return (NULL); + return (false); /* Fill in the syncache values. */ sc->sc_flags = 0; @@ -2354,7 +2355,7 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, sc->sc_port = port; TCPSTAT_INC(tcps_sc_recvcookie); - return (sc); + return (true); } #ifdef INVARIANTS @@ -2363,11 +2364,12 @@ syncookie_cmp(struct in_conninfo *inc, struct syncache_head *sch, struct syncache *sc, struct tcphdr *th, struct tcpopt *to, struct socket *lso, uint16_t port) { - struct syncache scs, *scx; + struct syncache scs, *scx = NULL; char *s; bzero(&scs, sizeof(scs)); - scx = syncookie_lookup(inc, sch, &scs, th, to, lso, port); + if (syncookie_expand(inc, sch, &scs, th, to, lso, port)) + scx = &scs; if ((s = tcp_log_addrs(inc, th, NULL, NULL)) == NULL) return (0);