From nobody Mon Sep 1 22:24:23 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 4cG3MC4sDNz65Q7g; Mon, 01 Sep 2025 22:24:23 +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 4cG3MC3yx6z41H8; Mon, 01 Sep 2025 22:24:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756765463; 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=/tJ0DnLFqmVR7nKDh0rMnYcFXjZZ8iTSKb0d67tkspA=; b=emjBndyE6Hgwyq8eH5yViBqrSwVBGZPI/fLOYpbMdb5crynbMpqgQ7TruIj6vW/q2TQpbr Kkzv58dLbrB3Ft5DXopNWGun9Tvxh1KjieN/vBRqyYzAt3wMmEiD79AlzaXB9qrhkxX8hK /6lDwyCGxa1U/8H39hq0K108H6/oHyWOvQlCG5+SqK6lTtEBt/YZVzNG1r8fZ383mUdJkV caKcckAT0iug8pAsUrzbPxA2x1ngBuvmlLsLCvnDHXUXr8jXMYE9RuqrsMrLiVlc8rRqdu MDHK+7MMByLrmi3lfylJe9YZz57jj9eQGvrYXzzmVTJ52ANH5UTYEOS0XWgOIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756765463; 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=/tJ0DnLFqmVR7nKDh0rMnYcFXjZZ8iTSKb0d67tkspA=; b=Ibdn9OAhDRAFEj8EJAAjzGXZsmRVz26il/PTnDIG2mL/l+ixpZ7inYxRmxfPslcoOHLf4s jlXsqGx6Cyc34c0dfmexMcxrxILj2oMYF9taKqBxxwNbuMt5vBxTEKSjqjphwUaZXI4a1P igSPHApCZgcwXXWAttM13iAEy9357Ao5BdJjZUEmjwtsHkIut9tpRaJm80D/3qS3vILFdw JeEYzaQwBcUDaxUQSEtM50tJU+DzeKtBT2Zhf13H2fBZ2bg2R3PWrve3UzMtZqDx0PO8Q5 QMrCnDtEYpm897HQaJf51hFy0eeEOnydLny7YH68/z44x+Nc+HBvybcPXks2dg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756765463; a=rsa-sha256; cv=none; b=COy3xqgFlNxTEzxJa02X8WNP4CBwOxDK/2use0WkPJNdqo4QNUMUn0MF5vgYVLPz0Ucv7H B9qj/Q5K8Ln2wAyg9MTwttwWM4UxsXDpzjZHI/3+70dqVILhxeeEnMu1qShhizEqNJnGXG /0vPClWPOZbt1MQI320y1mQKj2yZ9erlHspH23hqSYqtCDBWeNGVE6cxyfMUVy8uV5vD4E DPSpYlDvT/zsZjTLGHPnw3T8+nIg6166neuP6N2Kc/4arYuJQVH7Pp/6u2KJhMYZ58u311 3s+myVxKOOVIfULiAPGyupHV/fYmTbpW025x3EAt7eNq4uJyFQnkz4E/3SCXWg== 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 4cG3MC3YSDz34J; Mon, 01 Sep 2025 22:24:23 +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 581MONul052107; Mon, 1 Sep 2025 22:24:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 581MON2f052104; Mon, 1 Sep 2025 22:24:23 GMT (envelope-from git) Date: Mon, 1 Sep 2025 22:24:23 GMT Message-Id: <202509012224.581MON2f052104@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: 341d1aabc13e - main - tcp: micro-optimize SYN-cookie expansion 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: 341d1aabc13e47911d2eb38e857b90f7d356134e Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=341d1aabc13e47911d2eb38e857b90f7d356134e commit 341d1aabc13e47911d2eb38e857b90f7d356134e Author: Michael Tuexen AuthorDate: 2025-09-01 22:18:35 +0000 Commit: Michael Tuexen CommitDate: 2025-09-01 22:18:35 +0000 tcp: micro-optimize SYN-cookie expansion Only compute wscale when it is actually used. While there, change the type of wscale to u_int as suggested by glebius. No functional change intended. Reviewed by: glebius, rscheff (older version) MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52296 --- sys/netinet/tcp_syncache.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index bec1a0bd14c4..1ee6c6e31f33 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1675,7 +1675,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, sc->sc_tsoff = tcp_new_ts_offset(inc); } if ((to->to_flags & TOF_SCALE) && (V_tcp_do_rfc1323 != 3)) { - int wscale = 0; + u_int wscale = 0; /* * Pick the smallest possible scaling factor that @@ -2271,7 +2271,7 @@ syncookie_expand(struct in_conninfo *inc, const struct syncache_head *sch, uint32_t hash; uint8_t *secbits; tcp_seq ack, seq; - int wnd, wscale = 0; + int wnd; union syncookie cookie; /* @@ -2322,12 +2322,14 @@ syncookie_expand(struct in_conninfo *inc, const struct syncache_head *sch, sc->sc_peer_mss = tcp_sc_msstab[cookie.flags.mss_idx]; - /* We can simply recompute receive window scale we sent earlier. */ - while (wscale < TCP_MAX_WINSHIFT && (TCP_MAXWIN << wscale) < sb_max) - wscale++; - /* Only use wscale if it was enabled in the orignal SYN. */ if (cookie.flags.wscale_idx > 0) { + u_int wscale = 0; + + /* Recompute the receive window scale that was sent earlier. */ + while (wscale < TCP_MAX_WINSHIFT && + (TCP_MAXWIN << wscale) < sb_max) + wscale++; sc->sc_requested_r_scale = wscale; sc->sc_requested_s_scale = tcp_sc_wstab[cookie.flags.wscale_idx]; sc->sc_flags |= SCF_WINSCALE;