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=Xfcmhz+q; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 66BA25A0272 for ; Wed, 03 Jun 2026 04:37:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1780454258; bh=vTpaaLBjdb3huBIS7tH6e7PaN+7oZv5Ee3Gv8s6NBA0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xfcmhz+qF7zwsWHIdnighEVUptNOZvmkVdhM4ENjy8fA206mpL8ycYDIe39fPpCBi jsNRYkly4URudJjL/gccevcyck3ahrn2aPOECpagjmmgZUHo2HMEsvJ6XzW7QAS2mb mKLIi/mdEdw3COW+SM5DyYEaRcm03aqNYrUEO9NhFfkdU39MUidgLixQwkiWaxWioR NgElgT441GjTPwn2n/wX+kNj0Aq4mMC2ojDgQjORNGzu7+RK6rcptWQ959dLGB1yTd Gy0hOrBJjGsLoWcZ51Lcd2ebzwBoQ1LQI3b+Q6KH+bXW4B8zHzR9LkH0f1U+3SBXZO 9uYr5LqKM6qDQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gVX0y61JGz4wxG; Wed, 03 Jun 2026 12:37:38 +1000 (AEST) Date: Wed, 3 Jun 2026 12:37:29 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH] passt, tcp: Inline CALL_PROTO_HANDLER() and merge tcp_timer() Message-ID: References: <20260602131708.2726632-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Yqus6M+c77JIsMf1" Content-Disposition: inline In-Reply-To: <20260602131708.2726632-1-lvivier@redhat.com> Message-ID-Hash: 7NBIZIT2BG764ADJU7PSN4CFXWCZGZKL X-Message-ID-Hash: 7NBIZIT2BG764ADJU7PSN4CFXWCZGZKL 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: passt-dev@passt.top 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: --Yqus6M+c77JIsMf1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 02, 2026 at 03:17:08PM +0200, Laurent Vivier wrote: > Since 260075bde769 ("tcp, udp, fwd: Run all port scanning from a > single timer"), CALL_PROTO_HANDLER() has only one user (tcp), so > inline it at the call site and remove the macro. >=20 > Merge tcp_timer() into tcp_defer_handler(), moving the timer interval > check there, matching the pattern used by flow_defer_handler() and > fwd_scan_ports_timer(). >=20 > The weak declaration and null check for tcp_defer_handler are also > dropped as the function is always defined. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > passt.c | 23 ++--------------------- > tcp.c | 22 ++++++++++------------ > tcp.h | 3 +-- > 3 files changed, 13 insertions(+), 35 deletions(-) >=20 > diff --git a/passt.c b/passt.c > index b6fc12d4ed81..b3f806b9a15e 100644 > --- a/passt.c > +++ b/passt.c > @@ -101,27 +101,8 @@ struct passt_stats { > */ > static void post_handler(struct ctx *c, const struct timespec *now) > { > -#define CALL_PROTO_HANDLER(lc, uc) \ > - do { \ > - extern void \ > - lc ## _defer_handler (struct ctx *c) \ > - __attribute__ ((weak)); \ > - \ > - if (!c->no_ ## lc) { \ > - if (lc ## _defer_handler) \ > - lc ## _defer_handler(c); \ > - \ > - if (timespec_diff_ms((now), &c->lc.timer_run) \ > - >=3D uc ## _TIMER_INTERVAL) { \ > - lc ## _timer(c, now); \ > - c->lc.timer_run =3D *now; \ > - } \ > - } \ > - } while (0) > - > - /* NOLINTNEXTLINE(bugprone-branch-clone): intervals can be the same */ > - CALL_PROTO_HANDLER(tcp, TCP); > -#undef CALL_PROTO_HANDLER > + if (!c->no_tcp) > + tcp_defer_handler(c, now); > =20 > flow_defer_handler(c, now); > fwd_scan_ports_timer(c, now); > diff --git a/tcp.c b/tcp.c > index 0fb8da05cb65..c400075440c9 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -895,16 +895,6 @@ bool tcp_flow_defer(const struct tcp_tap_conn *conn) > return true; > } > =20 > -/** > - * tcp_defer_handler() - Handler for TCP deferred tasks > - * @c: Execution context > - */ > -/* cppcheck-suppress [constParameterPointer, unmatchedSuppression] */ > -void tcp_defer_handler(struct ctx *c) > -{ > - tcp_payload_flush(c); > -} > - > /** > * tcp_fill_header() - Fill the TCP header fields for a given TCP segmen= t. > * > @@ -3005,12 +2995,20 @@ static void tcp_inactivity(struct ctx *c, const s= truct timespec *now) > } > =20 > /** > - * tcp_timer() - Periodic tasks: port detection, closed connections, poo= l refill > + * tcp_defer_handler() - Handler for TCP deferred tasks > * @c: Execution context > * @now: Current timestamp > */ > -void tcp_timer(struct ctx *c, const struct timespec *now) > +/* cppcheck-suppress [constParameterPointer, unmatchedSuppression] */ > +void tcp_defer_handler(struct ctx *c, const struct timespec *now) > { > + tcp_payload_flush(c); > + > + if (timespec_diff_ms(now, &c->tcp.timer_run) < TCP_TIMER_INTERVAL) > + return; > + > + c->tcp.timer_run =3D *now; > + > tcp_sock_refill_init(c); > if (c->mode =3D=3D MODE_PASTA) > tcp_splice_refill(c); > diff --git a/tcp.h b/tcp.h > index 8a0eb930b54b..3262a807e5d4 100644 > --- a/tcp.h > +++ b/tcp.h > @@ -29,8 +29,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, s= a_family_t af, > int tcp_listen(const struct ctx *c, uint8_t pif, unsigned rule, > const union inany_addr *addr, const char *ifname, in_port_t port= ); > int tcp_init(struct ctx *c); > -void tcp_timer(struct ctx *c, const struct timespec *now); > -void tcp_defer_handler(struct ctx *c); > +void tcp_defer_handler(struct ctx *c, const struct timespec *now); > =20 > void tcp_update_l2_buf(const unsigned char *eth_d); > =20 > --=20 > 2.54.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --Yqus6M+c77JIsMf1 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmofk1oACgkQzQJF27ox 2GdHwQ/8C4Kd1ERKcnMoDE7W4Sdaiz8eYSh/fZ6CQiZQ0jqYAaLSDbvPvwJLpHSM rAjXYfJWZBBlgC2NOlJcVo6CaXqGDld+iE2Khu29xUL+sbP2CzD05TVLwcG1s2y+ BdKR4+ahWpTKkOZaoSBMI6ZgeYaESW0oRDM4hHQgtT6KGwQmKf64SHEX0eD7Wr96 zbY7/8GGNarGrY9/E9VyhxWtFHt1D/qNBAdsvE1UJXQDw6ia7n90do4CiEJuT4ac 7o9BizSb3+pA311Sx8iLTcBfWSa2JIa367bHA4zDi5LnVDbZDzz1vykfTKaifMK4 6MCq5Pymv1yRnIMgWc9tINclq8lBPNSQeeIlcgGbursBcKGrLreGYXvW+85VYMWv W/CJp0qYhQRiIm6Mfj5897/Sp1UoLlDIreSB34J43qBub0CMpFZgUbGRuednkX1E /5AYt6wWErbliawbVPurFkTE75o6NWsiknM4jA1lv/FcKC0H3cVKax/PKyL2zooQ Xobe14pe5GHJuJTx3fmAUk724ZP48dJ5xbWJChD1BWmFyIaig5FA63aFpc63kSs1 pJkX06y1z6f2toEjzz/Y3qaHO/r7jqVciqo45UAGEpSFFtgILfQVZ/u7KD4nH9Ea Hj3Snlt4Bn3pu5eetmM5stKkatnPrjJjjfAtUqyxnucb7DMriRo= =r/+y -----END PGP SIGNATURE----- --Yqus6M+c77JIsMf1--