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=Z9qGcFIz; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id AFE695A027B 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=gYdYlJHUgr4aLNi1LQDz0D1hbB2OO7N2o2BNTVv3gxE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z9qGcFIz4QmFRiBN5rw4DvA4tZpDPICgz1V8S67RUcUTFcDwCIh9enfzS+rEZai7f 0WoLLEFi3Rh1KxheQYk8w3+psouBZVmjd4dkRhO9Ynr7folzHNo/GpzWS78hFzsGMI xpuzoB2E6O5lWsQANGxPfGR03earp4B+qM6LYik2nubyLYaEKKboc4300F4SlE2Nfw cmOgNUAHtmAtqHsc2iRYCZUK2xHRQjwX1/oE4jnP1QbTsyPILXoRQqu1qDO+3fIJJd 8BQn96It1uk4QQ1NB3I0a+HN8ck9aRN9RpewewD9UJzCCn3mf6dms5SALi3w8wGkvS PmfmXumVBffEw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bxgXM0clqz4xcZ; Wed, 6 Aug 2025 16:35:31 +1000 (AEST) Date: Wed, 6 Aug 2025 16:21:52 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v8 20/30] tap: Convert tap6_handler() to iov_tail Message-ID: References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-21-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="W1uEaB5mX30FE1aE" Content-Disposition: inline In-Reply-To: <20250805154628.301343-21-lvivier@redhat.com> Message-ID-Hash: 4APERIDBMVGWEXYCDOZONWQ3LO44WKOQ X-Message-ID-Hash: 4APERIDBMVGWEXYCDOZONWQ3LO44WKOQ 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: --W1uEaB5mX30FE1aE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2025 at 05:46:18PM +0200, Laurent Vivier wrote: > Use packet_data() and extract headers using IOV_REMOVE_HEADER() > and IOV_PEEK_HEADER() rather than packet_get(). >=20 > Remove packet_get() as it is not used anymore. [snip] > @@ -896,21 +896,28 @@ resume: > for (seq_count =3D 0, seq =3D NULL; i < in->count; i++) { > size_t l4len, plen, check; > struct in6_addr *saddr, *daddr; > + struct ipv6hdr ip6h_storage; > + struct ethhdr eh_storage; > + struct udphdr uh_storage; > const struct ethhdr *eh; > const struct udphdr *uh; > struct iov_tail data; > struct ipv6hdr *ip6h; > uint8_t proto; > - char *l4h; > =20 > - eh =3D packet_get(in, i, 0, sizeof(*eh), NULL); > + if (!packet_data(in, i, &data)) > + return -1; > + > + eh =3D IOV_REMOVE_HEADER(&data, eh_storage); > if (!eh) > continue; > =20 > - ip6h =3D packet_get(in, i, sizeof(*eh), sizeof(*ip6h), &check); > + ip6h =3D IOV_PEEK_HEADER(&data, ip6h_storage); > if (!ip6h) > continue; You peek the IPv6 header here, but I haven't spotted where you remove / drop it before... > + check =3D iov_tail_size(&data) - sizeof(*ip6h); > + > saddr =3D &ip6h->saddr; > daddr =3D &ip6h->daddr; > =20 > @@ -918,10 +925,8 @@ resume: > if (plen !=3D check) > continue; > =20 > - data =3D IOV_TAIL_FROM_BUF(ip6h, sizeof(*ip6h) + check, 0); > if (!ipv6_l4hdr(&data, &proto, &l4len)) > continue; > - l4h =3D (char *)data.iov[0].iov_base + data.off; > =20 > if (IN6_IS_ADDR_LOOPBACK(saddr) || IN6_IS_ADDR_LOOPBACK(daddr)) { > char sstr[INET6_ADDRSTRLEN], dstr[INET6_ADDRSTRLEN]; > @@ -946,6 +951,8 @@ resume: > } > =20 > if (proto =3D=3D IPPROTO_ICMPV6) { > + struct icmp6hdr l4h_storage; > + const struct icmp6hdr *l4h; > PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); > =20 > if (c->no_icmp) > @@ -954,9 +961,9 @@ resume: > if (l4len < sizeof(struct icmp6hdr)) > continue; > =20 > - data =3D IOV_TAIL_FROM_BUF(l4h, l4len, 0); > packet_add(pkt, &data); > =20 > + l4h =3D IOV_PEEK_HEADER(&data, l4h_storage); =2E.. peeking the next header here. > if (ndp(c, (struct icmp6hdr *)l4h, saddr, pkt)) > continue; > =20 > @@ -969,12 +976,13 @@ resume: > =20 > if (l4len < sizeof(*uh)) > continue; > - uh =3D (struct udphdr *)l4h; > + uh =3D IOV_PEEK_HEADER(&data, uh_storage); And here. > + if (!uh) > + continue; > =20 > if (proto =3D=3D IPPROTO_UDP) { > PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); > =20 > - data =3D IOV_TAIL_FROM_BUF(l4h, l4len, 0); > packet_add(pkt, &data); > =20 > if (dhcpv6(c, pkt, saddr, daddr)) > @@ -1031,7 +1039,6 @@ resume: > #undef L4_SET > =20 > append: > - data =3D IOV_TAIL_FROM_BUF(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 --W1uEaB5mX30FE1aE Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiS9HkACgkQzQJF27ox 2GdcjBAAm7YTGjt4L3UTmYaMdcP28/z74O5EICUNISq599Dj7WeX5iqC2Yv3sIak P6vo/yu9YrXDfHWrpFCvBxlDtLaga/9DBqEH/d4Ms23vjDgTxGGCTX8NfJp2NVyh +HgPzepWdlREVLi3YS56GdHazsKZcQGujILp7iL0rpYlx8hqPqCV3SLDwMTWo597 GsNJ4VSQf+gGe2izbr85Z0atVhHzf5JBDQXqKJ4MeMYdpbCTirTorT8GF7/JYCBn fyqorTvZmM0GbqITKvFeE/0R7YtY5D6flXkASkWhUnFqRG8eghMDhlaNG9Z9+j6v SxlHRfHyoDxy9BJIK7wZSX3VFNmKLiT4CHec+xJClo/N1kMnIhpih9hsb8cl37KA izL4Rg7rsbLk1uNvLYrnZkkMxmSe3Rukwu4MZzbDH9J9TR0NY9v6y8J/Yxh0GO8/ 2rNly8tyeQQH8tDRao51KWA3MEstoNOIaiouNZ0p6OKphv7djrtiGKZ6DxJF+uHW 4jzuxolK6EnzEDciVPRCT3zWkb+T5seK6XGdBvY6t4aNtrhBAmhXsaQHauQTRuwa DmsJaigBgFjLw8dPwdBCDIGiG4+xIhH/C2yJ2fnaFtTKX2VUuj2j+NKCGoCZCTP5 L+RxUUsH6puCLkHEeEGEhEWZ6oJDezXQW1DhwJSObjW96f+cd2A= =6nId -----END PGP SIGNATURE----- --W1uEaB5mX30FE1aE--