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=202510 header.b=BHtc6zuy; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 912A25A0619 for ; Fri, 05 Dec 2025 05:14:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764908069; bh=nNjspVLy6Olla5LDmFpzMj0znQFGlvD2UkYzhXWIU+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BHtc6zuypxpZOiWDEHXxjv7XnC8iOkMYdrWTeSB7s96TCe5ARwf4mFJhpPB5zXgcn OpshX9n73oI1d6pdmRxFS1pDCB8L5ZiJIsHR+XB2qEbu4Fzxub4w6lhaX3XRLLF7pc 5RoEutHGbRvKsTFQ6nr7gzM77bP1PSF6dtmR+Quqx3OWX+XVlnQi5Z+yC9HVcs+cij pLM5RxdiSLS1Zzj4htYPyURRNRDQWdR7rXCJb3K8Fo8aAviEgufR2K1sGqaUEwNX2e iIaTQrN19nIRdlrLdWLC0lKjN3zFYah6+h1RiqTvpwtxDPXf68OGts+QZZV+vFLipw YnjLq6jaYclkw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dMygn67HMz4wHF; Fri, 05 Dec 2025 15:14:29 +1100 (AEDT) Date: Fri, 5 Dec 2025 15:14:23 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v3 1/6] tap: Remove pool parameter from tap4_handler() and tap6_handler() Message-ID: References: <20251203185435.582096-1-lvivier@redhat.com> <20251203185435.582096-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hHVguPWNK306ylqf" Content-Disposition: inline In-Reply-To: <20251203185435.582096-2-lvivier@redhat.com> Message-ID-Hash: OKGNDX6D5E5QD4TWCS6AJ6G45OKTNPQM X-Message-ID-Hash: OKGNDX6D5E5QD4TWCS6AJ6G45OKTNPQM 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: --hHVguPWNK306ylqf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 03, 2025 at 07:54:29PM +0100, Laurent Vivier wrote: > These handlers only ever operate on their respective global pools > (pool_tap4 and pool_tap6). The pool parameter was always passed the > same value, making it unnecessary indirection. >=20 > Access the global pools directly instead, simplifying the function > signatures. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tap.c | 46 +++++++++++++++++++++------------------------- > 1 file changed, 21 insertions(+), 25 deletions(-) >=20 > diff --git a/tap.c b/tap.c > index 44b06448757a..2cda8c9772b8 100644 > --- a/tap.c > +++ b/tap.c > @@ -696,23 +696,21 @@ static bool tap4_is_fragment(const struct iphdr *ip= h, > /** > * tap4_handler() - IPv4 and ARP packet handler for tap file descriptor > * @c: Execution context > - * @in: Ingress packet pool, packets with Ethernet headers > * @now: Current timestamp > * > * Return: count of packets consumed by handlers > */ > -static int tap4_handler(struct ctx *c, const struct pool *in, > - const struct timespec *now) > +static int tap4_handler(struct ctx *c, const struct timespec *now) > { > unsigned int i, j, seq_count; > struct tap4_l4_t *seq; > =20 > - if (!c->ifi4 || !in->count) > - return in->count; > + if (!c->ifi4 || !pool_tap4->count) > + return pool_tap4->count; > =20 > i =3D 0; > resume: > - for (seq_count =3D 0, seq =3D NULL; i < in->count; i++) { > + for (seq_count =3D 0, seq =3D NULL; i < pool_tap4->count; i++) { > size_t l3len, hlen, l4len; > struct ethhdr eh_storage; > struct iphdr iph_storage; > @@ -722,7 +720,7 @@ resume: > struct iov_tail data; > struct iphdr *iph; > =20 > - if (!packet_get(in, i, &data)) > + if (!packet_get(pool_tap4, i, &data)) > continue; > =20 > eh =3D IOV_PEEK_HEADER(&data, eh_storage); > @@ -789,7 +787,7 @@ resume: > if (iph->protocol =3D=3D IPPROTO_UDP) { > struct iov_tail eh_data; > =20 > - packet_get(in, i, &eh_data); > + packet_get(pool_tap4, i, &eh_data); > if (dhcp(c, &eh_data)) > continue; > } > @@ -820,7 +818,7 @@ resume: > goto append; > =20 > if (seq_count =3D=3D TAP_SEQS) > - break; /* Resume after flushing if i < in->count */ > + break; /* Resume after flushing if i < pool_tap4->count */ > =20 > for (seq =3D tap4_l4 + seq_count - 1; seq >=3D tap4_l4; seq--) { > if (L4_MATCH(iph, uh, seq)) { > @@ -866,32 +864,30 @@ append: > } > } > =20 > - if (i < in->count) > + if (i < pool_tap4->count) > goto resume; > =20 > - return in->count; > + return pool_tap4->count; > } > =20 > /** > * tap6_handler() - IPv6 packet handler for tap file descriptor > * @c: Execution context > - * @in: Ingress packet pool, packets with Ethernet headers > * @now: Current timestamp > * > * Return: count of packets consumed by handlers > */ > -static int tap6_handler(struct ctx *c, const struct pool *in, > - const struct timespec *now) > +static int tap6_handler(struct ctx *c, const struct timespec *now) > { > unsigned int i, j, seq_count =3D 0; > struct tap6_l4_t *seq; > =20 > - if (!c->ifi6 || !in->count) > - return in->count; > + if (!c->ifi6 || !pool_tap6->count) > + return pool_tap6->count; > =20 > i =3D 0; > resume: > - for (seq_count =3D 0, seq =3D NULL; i < in->count; i++) { > + for (seq_count =3D 0, seq =3D NULL; i < pool_tap6->count; i++) { > size_t l4len, plen, check; > struct in6_addr *saddr, *daddr; > struct ipv6hdr ip6h_storage; > @@ -903,7 +899,7 @@ resume: > struct ipv6hdr *ip6h; > uint8_t proto; > =20 > - if (!packet_get(in, i, &data)) > + if (!packet_get(pool_tap6, i, &data)) > return -1; > =20 > eh =3D IOV_REMOVE_HEADER(&data, eh_storage); > @@ -1011,7 +1007,7 @@ resume: > goto append; > =20 > if (seq_count =3D=3D TAP_SEQS) > - break; /* Resume after flushing if i < in->count */ > + break; /* Resume after flushing if i < pool_tap6->count */ > =20 > for (seq =3D tap6_l4 + seq_count - 1; seq >=3D tap6_l4; seq--) { > if (L4_MATCH(ip6h, proto, uh, seq)) { > @@ -1058,10 +1054,10 @@ append: > } > } > =20 > - if (i < in->count) > + if (i < pool_tap6->count) > goto resume; > =20 > - return in->count; > + return pool_tap6->count; > } > =20 > /** > @@ -1080,8 +1076,8 @@ void tap_flush_pools(void) > */ > void tap_handler(struct ctx *c, const struct timespec *now) > { > - tap4_handler(c, pool_tap4, now); > - tap6_handler(c, pool_tap6, now); > + tap4_handler(c, now); > + tap6_handler(c, now); > } > =20 > /** > @@ -1115,14 +1111,14 @@ void tap_add_packet(struct ctx *c, struct iov_tai= l *data, > case ETH_P_ARP: > case ETH_P_IP: > if (!pool_can_fit(pool_tap4, data)) { > - tap4_handler(c, pool_tap4, now); > + tap4_handler(c, now); > pool_flush(pool_tap4); > } > packet_add(pool_tap4, data); > break; > case ETH_P_IPV6: > if (!pool_can_fit(pool_tap6, data)) { > - tap6_handler(c, pool_tap6, now); > + tap6_handler(c, now); > pool_flush(pool_tap6); > } > packet_add(pool_tap6, data); > --=20 > 2.51.1 >=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 --hHVguPWNK306ylqf Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkyXB4ACgkQzQJF27ox 2Gfv2w/+I7+zC41Pt2t+NLNqRFHJQ8Tvx5xGaTzUASQirxuKT8YBPSkwXDs95qTW /2OG/trodsgkmxh/f3Awuh6PK4/wkEcPUwCNmL9ZPZeYOUgfXw9sq4aROGpBCDcS O6s1o+fNfd1y3VHHqyfWirg9fPZwpGAzjqO0J18pnrVYyLZhQo5vU8X+SsOlJ11V Lm4+pa2zyGkUWh+sUwi6CVf9ifjQVIb3TvOdiRdBFc8rvgHXkgr2nHSLgMEYe03T 9RSQsfNwRhPs4ZTTN83gx2gkHTg1QKsH73SycJpJZP8C+UsV6QBKErZBg07uzfVA LhuwOipvKsnww2KCR/yC0FsHW11Pv4mQ93nll7tKBR36GG9nUuZjiMPxn2mk/H1m Ik6GG30/I9VZ1GEvHGi6IEHHw5QSyzdnzQ53bcJFi/87FoGJH2N7GV/ghrqt6FMu hcDaBIoTanFq2VrqjZhg5fdUi0ECCUIFzoQSkj1QMUkOCZV+d6yaoGcsFILriAko IcmkE0P6BZ4ZHR9cp+vSSL61RF3Uj0vlvELTTZJH49YQ3vj+ZWFx2faDplUjP8+q S5bGxag/fTPMU+jHtoWPOIzzOHZu8e7UIEhRHC2Z75BX87jMzd00o12Yxbv71wR1 daxh0wfTgeaYThOaYJ1DXhF+0CuKPJsKAOhvDDiDWpq4OdbWAOQ= =eZ1p -----END PGP SIGNATURE----- --hHVguPWNK306ylqf--