From nobody Tue Jun 17 15:50:42 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 4bMBD252tYz5yTjP; Tue, 17 Jun 2025 15:50:42 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bMBD24Tytz3pP6; Tue, 17 Jun 2025 15:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750175442; 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=zS54zQMnEIY88q/bG2xAef5YAO5Bk1pux6UwrI4pRlU=; b=NV705OZQzgkR8ilhcDmHIsHyh9wRck7RKsFLBf0Kcvd0mUEaWvu+UPMEHihMWFkqD1DSmy Bcw2jRdCLvE8mWe4RpqS9pmdVPnWhG6nu4/mxCgwntGmERC6IHFs4Ra9MaOfm1LwODm32K 8qDasLhNM9kZfKxcuKcCGkxstqCKMjXm4oHZN6l1DGYkWJ7BT2n1PE53+zGJe4mXGcRhWD fgD7duisE3XW54EiGL9gNYyBBKaT7iAG+sVOY2+BtjuGWAgeVXH7+idlACxlqktbuHSL4f XE9fJuxG6yBZJLzbLXHYio4jBEWVqD5nkwLNWbTcQ0YVdCsqAcTPq1fixcmppg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750175442; 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=zS54zQMnEIY88q/bG2xAef5YAO5Bk1pux6UwrI4pRlU=; b=j+/ULCvpxg1dcKusMO/cZmEGbDXDihZMkZRPbpW3hK8Hc6FlMubwvSoyM9y0jcLKdqa9WH TXdZaOjOhVP7KDZtwakAtK5sA5+o66PGeLZaC2vXEI3B3uQTDFtpfeu5s7zxwMqcgz1cT7 ATp/vMjZYxcBLNmlJVmZyov0O5INpQubT3GL5qMTu75QI7amiqicBRZQIrkkgMG7j3W2TK qVmfnb9651Ys+hSu2RR25TTDtjIdeFecnTY4mtBP1FPzGRdv38V2uPhVwua7ouzNClKCAp pbbchWC+wy/uCUqb7FAmw8DuBL26FE2V1xqBd8d5NR5A85aI2MhbBiqHXuKlIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750175442; a=rsa-sha256; cv=none; b=s0+5o6QNdzdT19B8xgy8DwR6tc3aS/ZxhEM9V2WvL0DiK0XBMdelA4eE9VnpXi7vMGklp7 I/e6uOOj28X/G6RDLdXDGbAmobDuLF5OvENl3bq360OKgyWSntKrE/8l1wSQ36RIOb3SWo J1xAgqdLPXk3scxZwtL1iGSIBET5JIUGgCZUoqbIA18k0clv+jWzwCYpIPQJl8U/RrKCAN jFtX20BLpudH8ZAdSWT19WT6mKwWC48Ecw1bYinx/bSXLeSzo7I9eqXABMRlMvM+RGhyKc KsIGEVQbx62ED4s0uqpTY/9Uc5+9axLF8wZ2fPbdgatoxX2yIJwhzd8qGK5k7Q== 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 4bMBD23xhvzqTH; Tue, 17 Jun 2025 15:50:42 +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 55HFogR4029453; Tue, 17 Jun 2025 15:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55HFogd3029450; Tue, 17 Jun 2025 15:50:42 GMT (envelope-from git) Date: Tue, 17 Jun 2025 15:50:42 GMT Message-Id: <202506171550.55HFogd3029450@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 6538742c1aac - main - tcp: rename syncookie_lookup() into syncookie_expand() and make it bool 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6538742c1aaca3ce522ccea95007dfa9686c78dd Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=6538742c1aaca3ce522ccea95007dfa9686c78dd commit 6538742c1aaca3ce522ccea95007dfa9686c78dd Author: Gleb Smirnoff AuthorDate: 2025-06-17 15:50:01 +0000 Commit: Gleb Smirnoff CommitDate: 2025-06-17 15:50:01 +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 --- 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 606d808676e1..bcbc028cfbdc 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -131,10 +131,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 *); @@ -1112,7 +1112,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) { @@ -2251,8 +2252,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) { @@ -2282,7 +2283,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; @@ -2343,7 +2344,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 @@ -2352,11 +2353,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);