From nobody Mon Sep 08 22:02: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 4cLLXs4R53z679mn; Mon, 08 Sep 2025 22:02: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cLLXs3Zfrz3G3g; Mon, 08 Sep 2025 22:02:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757368957; 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=OZJRZuitaRFIwF5lrWCFxTzJCuiyvc0IPfnBHzA1b8w=; b=ObrzTQQtIGdqWUcWqhN9FMTyBUX1hBOd3LFuZSphNc7KP4FQz5Tc8qgQE0cU3auE1O5iOP y+kB6/1Vg7yvgvSbWq8uDzRAgFO6G5B+c8uEkBsjJ49fj43aP5v0dUPoHSvcr9SGOBQR73 Atg9YXhQd7DgCDOZpg8INVkUHOkeYe5Xphcakb/gpJNNn1y2wEpgmOgXisfKJuP9LhwrWf +fPDLTwlx9LLBKevEnE8/vKCts36l/5l/1isI2hyGs9ISCl91mtIlxuO3401tCA+jeWAG3 wJarbHim+PIQ4dhAX6dSUEeA8Oiorp3swKYH96wLYrIIcruRUDPUjGaR/VbMtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757368957; 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=OZJRZuitaRFIwF5lrWCFxTzJCuiyvc0IPfnBHzA1b8w=; b=Yk4H8vC1RGfA5VoseS1pMQhzJXBp3qHSgZyRgc89XD+jbWSH2dkFGu+ufNfC9uzD5j8I6z izmadByPwCzL76l/BhV0JfTQDZhvhUaen0IsKH5cXTlQdYB5RLehy3u9MYYXeWttzm9Nby SiMLmbkXlcYN2uLEOTale3RiCAHI1+81FCwDYg9RxXD2zl3rMbIFXFcrOv2mtp5R5PLUbX GRk46D/igtI62gRRsR1nhiQHZ/uv4bxpEo2qr6hZfFtNC/JmVcjWqNcuTX/Kr+fh6v0hmu RXYua2tibRr0yPyisczPb7GO+DHj3dEkTvIBw1HKttot0Pc9NLG4pFF6nMjlXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757368957; a=rsa-sha256; cv=none; b=cenQ3VdSKY5TbMSgR7psPDzrHxV0Sj6ZTJsHdrOkaW5U0TKUAZp6LAWf1kyBP5/xZnajJ5 71D8atGap9iCGxH0qeMsbkNdTL5QTRQW8yo8713TTRSL33kMNt6K6wuwZFJrV3TFs9xAy6 migU3rPNITNVs+PjvWLLOUG4Ww7pE0w38VeSQ5t03hzowHEp/Azd7mNux/aav9Hd3T9umc VU56A2HPkrieBLOwx7xTCJou6pPVAx8a1xbKOQf1BAMRyaBbpi68LBHtgoVdj5jx7h5MbC iMyh0IDoyJqVMqFwbZaDfuGujbHhM5VU32xsF9by/9LvNvcO8Yuw87J4oUXpSw== 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 4cLLXs2rVBz1N7S; Mon, 08 Sep 2025 22:02: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 588M2b95028861; Mon, 8 Sep 2025 22:02:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 588M2bY0028858; Mon, 8 Sep 2025 22:02:37 GMT (envelope-from git) Date: Mon, 8 Sep 2025 22:02:37 GMT Message-Id: <202509082202.588M2bY0028858@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: 5d65c9eeb805 - stable/14 - tcp: micro-optimize SYN-cookie expansion 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: 5d65c9eeb8057ac796cf9b51ab3fa3d30b06e91c Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=5d65c9eeb8057ac796cf9b51ab3fa3d30b06e91c commit 5d65c9eeb8057ac796cf9b51ab3fa3d30b06e91c Author: Michael Tuexen AuthorDate: 2025-09-01 22:18:35 +0000 Commit: Michael Tuexen CommitDate: 2025-09-08 21:57:11 +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) Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52296 (cherry picked from commit 341d1aabc13e47911d2eb38e857b90f7d356134e) --- 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 5a12aa3ed21a..29dbaaec929a 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1672,7 +1672,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 @@ -2268,7 +2268,7 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, uint32_t hash; uint8_t *secbits; tcp_seq ack, seq; - int wnd, wscale = 0; + int wnd; union syncookie cookie; /* @@ -2319,12 +2319,14 @@ syncookie_lookup(struct in_conninfo *inc, 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;