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=202508 header.b=CS5t3c4c; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EB9B65A027C for ; Wed, 06 Aug 2025 08:35:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1754462131; bh=tapp7jXFmNg6e2Fe5IYWyW2uwpyVBV5dHPzU082Fgh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CS5t3c4cHEh+CqGwze5U93sUkhPbAqe+6OHx8yZbAOEorVCSY5JpjnHnpzjfwzq7p vVogHz6LWSqBSJUWH1mSDOxeQ3ogBybnMgl1CZi4CyJvruDQ58gzVaEcWSD34bNi7V FIaG3meNIsdakcVHabhx5A7Oo/aFSIiQ2EsRQnZcZFRgP1OIODyD0B3hlr0clf9X9I 6fxPNIrHmArPhgjvLwBtYR2Ex/WqPB5okqBSqRwPLOGEYbvZAOJid1rZJqXJWnxsuv 8CQGwF3kRqmshANsd864N/BLh8IWXRqw12F5Yx32u2WojsuvxMMiZebDRLjba6tr0p 7g1BkBY8z7dNA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bxgXM0QhKz4wbd; Wed, 6 Aug 2025 16:35:31 +1000 (AEST) Date: Wed, 6 Aug 2025 15:17:46 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v8 19/30] tap: Convert tap4_handler() to iov_tail Message-ID: References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-20-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="REJFVU+1+Oa4VS6y" Content-Disposition: inline In-Reply-To: <20250805154628.301343-20-lvivier@redhat.com> Message-ID-Hash: H7N5YUV6WRF3E3FYTJLBZ5HGDMWAH5CI X-Message-ID-Hash: H7N5YUV6WRF3E3FYTJLBZ5HGDMWAH5CI 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: --REJFVU+1+Oa4VS6y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2025 at 05:46:17PM +0200, Laurent Vivier wrote: > Use packet_data() and extract headers using IOV_PEEK_HEADER() > rather than packet_get(). >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tap.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) >=20 > diff --git a/tap.c b/tap.c > index d7852fad6069..4fbcad3b385f 100644 > --- a/tap.c > +++ b/tap.c > @@ -706,28 +706,34 @@ static int tap4_handler(struct ctx *c, const struct= pool *in, > i =3D 0; > resume: > for (seq_count =3D 0, seq =3D NULL; i < in->count; i++) { > - size_t l2len, l3len, hlen, l4len; > + size_t l3len, hlen, l4len; > + struct ethhdr eh_storage; > + struct iphdr iph_storage; > + struct udphdr uh_storage; > const struct ethhdr *eh; > const struct udphdr *uh; > struct iov_tail data; > struct iphdr *iph; > - const char *l4h; > =20 > - packet_get(in, i, 0, 0, &l2len); > + if (!packet_data(in, i, &data)) > + continue; > =20 > - eh =3D packet_get(in, i, 0, sizeof(*eh), &l3len); > + eh =3D IOV_PEEK_HEADER(&data, eh_storage); > if (!eh) > continue; > if (ntohs(eh->h_proto) =3D=3D ETH_P_ARP) { > PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); > =20 > - data =3D IOV_TAIL_FROM_BUF((void *)eh, l2len, 0); > packet_add(pkt, &data); > arp(c, pkt); > continue; > } > =20 > - iph =3D packet_get(in, i, sizeof(*eh), sizeof(*iph), NULL); > + if (!iov_tail_drop(&data, sizeof(*eh))) > + continue; > + l3len =3D iov_tail_size(&data); > + > + iph =3D IOV_PEEK_HEADER(&data, iph_storage); > if (!iph) > continue; > =20 > @@ -755,8 +761,9 @@ resume: > if (iph->saddr && c->ip4.addr_seen.s_addr !=3D iph->saddr) > c->ip4.addr_seen.s_addr =3D iph->saddr; > =20 > - l4h =3D packet_get(in, i, sizeof(*eh) + hlen, l4len, NULL); > - if (!l4h) > + if (!iov_tail_drop(&data, hlen)) > + continue; > + if (iov_tail_size(&data) !=3D l4len) > continue; > =20 > if (iph->protocol =3D=3D IPPROTO_ICMP) { > @@ -767,7 +774,6 @@ resume: > =20 > tap_packet_debug(iph, NULL, NULL, 0, NULL, 1); > =20 > - data =3D IOV_TAIL_FROM_BUF((void *)l4h, l4len, 0); > packet_add(pkt, &data); > icmp_tap_handler(c, PIF_TAP, AF_INET, > &iph->saddr, &iph->daddr, > @@ -775,15 +781,17 @@ resume: > continue; > } > =20 > - uh =3D packet_get(in, i, sizeof(*eh) + hlen, sizeof(*uh), NULL); > + uh =3D IOV_PEEK_HEADER(&data, uh_storage); > if (!uh) > continue; > =20 > if (iph->protocol =3D=3D IPPROTO_UDP) { > + struct iov_tail eh_data; > + > PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); > =20 > - data =3D IOV_TAIL_FROM_BUF((void *)eh, l2len, 0); > - packet_add(pkt, &data); > + packet_data(in, i, &eh_data); > + packet_add(pkt, &eh_data); > if (dhcp(c, pkt)) > continue; > } > @@ -834,7 +842,6 @@ resume: > #undef L4_SET > =20 > append: > - data =3D IOV_TAIL_FROM_BUF((void *)l4h, l4len, 0); > packet_add((struct pool *)&seq->p, &data); > } > =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 --REJFVU+1+Oa4VS6y Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiS5WgACgkQzQJF27ox 2GfDgg//ZtfJbNmuwWLdVqfHNykkpY+uUPYnyJY/EV6X1vxnj6IfiB7VWBJxWWeX ioFYSX/I/XHqWZxaCLdPWyJVNUp9XCZ//zOLt0qIkm90qkgWk833uneFpklM6I6Y o2vjxSVzXCHV2JVX4hyHgCQdi0pP3XszBDv1yNV/SMTleAxa1thYJzVyykGaA8Qq kdgMyGf3myyzf/3PAVeSgoAXW2YBq0uwSr8G+7F6oy70ivynt0t6fFrj4lzNzTR6 JfewZp/GCPfEdHeMYX0iQBogXzOfDwF+yQaY8hfMsIjY49jAUVxtMdJpD7H7wQt9 L1j58qsNbrayBemnae/n8Ud24afX27LBzNfIEtasGT6AyF7j42MKmfPNJmGLO1Ot 1/JvWouaMUblkWuc5gghcJF26Ao7SL2OFFWA33oICYTUIORkCujv3eE76uk4Bsb5 H8xnfkMDs/MLNGJuEdKtW3kfrEqP720FO+vJsNjyGDj4TeYd0LYgAWT/UMilw7lR IQgJsNGowmrL2rh+FQnTLLCYgAgXFjLWkxXyBeK2ojp3dWut2aNgvaQlgCUe3zGc j/OUwqooDpv41TsQmknCDq0BbjgI/OtM8iZxl+elwiNnz0KJxgjqyx4GcyOT14Me AjPkUJ3IwUWqTMsmbMmtgunG4+umMsD/W5xVRQ8uuujO3QV+Y9Q= =Ak5w -----END PGP SIGNATURE----- --REJFVU+1+Oa4VS6y--