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=202602 header.b=TwPRVCh1; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D14BA5A061A for ; Mon, 02 Mar 2026 05:31:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1772425897; bh=S9Rq3ZqbvNT/uHL7ObE1e6f3Ozwt+GQnWGeaj2/3u+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwPRVCh1MQAfExxqzkXO3xCQ/7kfFMcVDIlSv9Ao3lzOT8U2FHTyvAzMK91e/u6YU RKfBMShKZt4Dekucls0DzBcr8Cqnz1iqRl6gDWxwz0E4NR/Fh86Qr3R6ejIN83CVTB GDw7Gtzs1oxwefiVJ76DPH/xnlkhth2RyeDQ/mhDzLImQ0FkKSF/QMvy3F4m2Di+h1 9I3YaElU9zug2o5dppJxTKBwVCnIu5WciVBTZgnXjvr1oYgfvhK1vDER1jG70TCDM6 lsTlAhnTw3TnDzis1LWM0Azm5prjB77uAT2rOywOSKfFUcRyE1KiQggu/b2ds/Z2C2 TT+EUmsHO4ScA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fPQxP06CXz4w9y; Mon, 02 Mar 2026 15:31:37 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 1/3] tcp: Use flow_foreach_of_type() in tcp_{keepalive,inactivity} Date: Mon, 2 Mar 2026 15:31:33 +1100 Message-ID: <20260302043135.800803-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260302043135.800803-1-david@gibson.dropbear.id.au> References: <20260302043135.800803-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XDTJHL2ZZV32VGR5JLJHI5XFL5JQQTVC X-Message-ID-Hash: XDTJHL2ZZV32VGR5JLJHI5XFL5JQQTVC 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: These functions step through all TCP flows. I forgot there was already a flow_foreach_of_type() macro which makes this easier. Use it. Signed-off-by: David Gibson --- tcp.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tcp.c b/tcp.c index 88ad886d..16470703 100644 --- a/tcp.c +++ b/tcp.c @@ -2907,12 +2907,9 @@ static void tcp_keepalive(struct ctx *c, const struct timespec *now) c->tcp.keepalive_run = now->tv_sec; - flow_foreach(flow) { + flow_foreach_of_type(flow, FLOW_TCP) { struct tcp_tap_conn *conn = &flow->tcp; - if (flow->f.type != FLOW_TCP) - continue; - if (conn->tap_inactive) { flow_dbg(conn, "No tap activity for least %us, send keepalive", KEEPALIVE_INTERVAL); @@ -2938,12 +2935,9 @@ static void tcp_inactivity(struct ctx *c, const struct timespec *now) debug("TCP inactivity scan"); c->tcp.inactivity_run = now->tv_sec; - flow_foreach(flow) { + flow_foreach_of_type(flow, FLOW_TCP) { struct tcp_tap_conn *conn = &flow->tcp; - if (flow->f.type != FLOW_TCP) - continue; - if (conn->inactive) { /* No activity in this interval, reset */ flow_dbg(conn, "Inactive for at least %us, resetting", -- 2.53.0