From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202408 header.b=MILBnJyE; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5502B5A0276 for ; Fri, 13 Sep 2024 06:32:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1726201936; bh=l9gKlcgxIjQVF30fSBPMMWwEXZNLLKu8iPru4E7g3Q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MILBnJyEAh1GYSUrFK3IjVj2E8UGUr7vf15ODqIrG1OVNk2I5F/RrTWyPNx92HBOM 1shfDjyBeqx67ISIARzxZ+Tys1OvoXzvFnNhIIDO6ov6e5qaDejI7N8vEjj48MbDor OSqZ2u/z8H33VW8qpo3GX7t/CoYU2h6ZE6TnNv0yJSjGXJ1jakAcQApGnOFtUM5NWW xMFH30xAD3SfkdlIg0pwEFK5ZdIHqAzVdrJpoRDnB9b4HdH5yGN+P3QrLWMQvbBBkV GJyEiqGEzdG+X1uG/6WS7kn50IUDIdh0nSis3W4T9igedhI3ipM0LykSePAevAPMTi voCyGyn4e/uiQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4X4hH45Zsbz4xQM; Fri, 13 Sep 2024 14:32:16 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 03/10] tcp: Simplify ifdef logic in tcp_update_seqack_wnd() Date: Fri, 13 Sep 2024 14:32:07 +1000 Message-ID: <20240913043214.1753014-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240913043214.1753014-1-david@gibson.dropbear.id.au> References: <20240913043214.1753014-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: J7A2DMJBXRQ3BQQXPXXKA4QKZRMIQ43I X-Message-ID-Hash: J7A2DMJBXRQ3BQQXPXXKA4QKZRMIQ43I X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This function has a block conditional on !snd_wnd_cap shortly before an #ifdef HAS_SND_WND. But snd_wnd_cap implies HAS_SND_WND (if !HAS_SND_WND, snd_wnd_cap is statically false). Therefore, simplify this down to a single conditional with an else branch. While we're there, fix some improperly indented closing braces. Signed-off-by: David Gibson --- tcp.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tcp.c b/tcp.c index cba3f3bd..6733e7e3 100644 --- a/tcp.c +++ b/tcp.c @@ -1061,27 +1061,25 @@ int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn, conn->wnd_to_tap = MIN(new_wnd_to_tap >> conn->ws_to_tap, USHRT_MAX); goto out; - } - - if (!tinfo) { - if (prev_wnd_to_tap > WINDOW_DEFAULT) { - goto out; -} - tinfo = &tinfo_new; - if (getsockopt(s, SOL_TCP, TCP_INFO, tinfo, &sl)) { - goto out; -} - } - -#ifdef HAS_SND_WND - if ((conn->flags & LOCAL) || tcp_rtt_dst_low(conn)) { - new_wnd_to_tap = tinfo->tcpi_snd_wnd; } else { - tcp_get_sndbuf(conn); - new_wnd_to_tap = MIN((int)tinfo->tcpi_snd_wnd, - SNDBUF_GET(conn)); + if (!tinfo) { + if (prev_wnd_to_tap > WINDOW_DEFAULT) { + goto out; + } + tinfo = &tinfo_new; + if (getsockopt(s, SOL_TCP, TCP_INFO, tinfo, &sl)) { + goto out; + } + } + + if ((conn->flags & LOCAL) || tcp_rtt_dst_low(conn)) { + new_wnd_to_tap = tinfo->tcpi_snd_wnd; + } else { + tcp_get_sndbuf(conn); + new_wnd_to_tap = MIN((int)tinfo->tcpi_snd_wnd, + SNDBUF_GET(conn)); + } } -#endif new_wnd_to_tap = MIN(new_wnd_to_tap, MAX_WINDOW); if (!(conn->events & ESTABLISHED)) -- 2.46.0