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=wD8wkZrM; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 79CA55A028B for ; Wed, 06 Aug 2025 08:35:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1754462131; bh=iLfuV6yEdzR99LZAMQc6dkZ49FIt2Wu9e2nnBnr1vBw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wD8wkZrMoMa5d6n4UCb7vxhYt/MtVzTfnHi3RDWiZ/eE5pEva1u7z7Qzi5UgBUziQ +Mgo1Y9xYON+97Jswk4efKeRmqB2nyQsyx9+CBOiOG6WLMjc8BEfQGUBTt8yEktF5Z vWiiBkjyshvom+vCxOu5SRSJUTx0Gd6OzI1DGzjMTIDZFGWqM87W7mNu4nnjUkkGkX aAlAdnf7vNSiDD0ob3N742rsB3+9hPiw4TTiJDGc/4JLBv6NXTAY523IXgxjESZu8c cSXDwtMUA5+B4dnvGSjZ22cGRc0hbwK3ML7z85dpIZihoicmFzY0MBoKnysPhXSebT Oe7tR/Jzlcfqw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bxgXM19BZz4xcb; Wed, 6 Aug 2025 16:35:31 +1000 (AEST) Date: Wed, 6 Aug 2025 16:26:33 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v8 23/30] dhcp: use iov_tail rather than pool Message-ID: References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-24-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+baFmIX1O3MsI5P7" Content-Disposition: inline In-Reply-To: <20250805154628.301343-24-lvivier@redhat.com> Message-ID-Hash: JNY4Z6WSLVF52P6XZFLGICVLPDVZXXEJ X-Message-ID-Hash: JNY4Z6WSLVF52P6XZFLGICVLPDVZXXEJ 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: --+baFmIX1O3MsI5P7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2025 at 05:46:21PM +0200, Laurent Vivier wrote: > This patch refactors the dhcp() function to accept `struct iov_tail *data` > directly as its packet input, replacing the previous `const struct pool *= p` > parameter. Consequently, dhcp() no longer fetches packet data internally > using packet_data(). >=20 > This change simplifies callers, such as tap4_handler(), which now pass > the iov_tail representing the L2 frame directly to dhcp(). This removes > the need for intermediate packet pool handling for DHCP processing. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > dhcp.c | 32 ++++++++++++++------------------ > dhcp.h | 2 +- > tap.c | 5 +---- > 3 files changed, 16 insertions(+), 23 deletions(-) >=20 > diff --git a/dhcp.c b/dhcp.c > index 47317f334945..cad1d037cee1 100644 > --- a/dhcp.c > +++ b/dhcp.c > @@ -296,11 +296,11 @@ static void opt_set_dns_search(const struct ctx *c,= size_t max_len) > /** > * dhcp() - Check if this is a DHCP message, reply as needed > * @c: Execution context > - * @p: Packet pool, single packet with Ethernet buffer > + * @data: Single packet with Ethernet buffer > * > * Return: 0 if it's not a DHCP message, 1 if handled, -1 on failure > */ > -int dhcp(const struct ctx *c, const struct pool *p) > +int dhcp(const struct ctx *c, struct iov_tail *data) > { > char macstr[ETH_ADDRSTRLEN]; > size_t mlen, dlen, opt_len; > @@ -311,24 +311,20 @@ int dhcp(const struct ctx *c, const struct pool *p) > const struct ethhdr *eh; > const struct iphdr *iph; > const struct udphdr *uh; > - struct iov_tail data; > struct msg const *m; > struct msg reply; > unsigned int i; > struct msg m_storage; > =20 > - if (!packet_get(p, 0, &data)) > - return -1; > - > - eh =3D IOV_REMOVE_HEADER(&data, eh_storage); > - iph =3D IOV_PEEK_HEADER(&data, iph_storage); > + eh =3D IOV_REMOVE_HEADER(data, eh_storage); > + iph =3D IOV_PEEK_HEADER(data, iph_storage); > if (!eh || !iph) > return -1; > =20 > - if (!iov_tail_drop(&data, iph->ihl * 4UL)) > + if (!iov_tail_drop(data, iph->ihl * 4UL)) > return -1; > =20 > - uh =3D IOV_REMOVE_HEADER(&data, uh_storage); > + uh =3D IOV_REMOVE_HEADER(data, uh_storage); > if (!uh) > return -1; > =20 > @@ -338,8 +334,8 @@ int dhcp(const struct ctx *c, const struct pool *p) > if (c->no_dhcp) > return 1; > =20 > - mlen =3D iov_tail_size(&data); > - m =3D (struct msg const *)iov_remove_header_(&data, &m_storage, > + mlen =3D iov_tail_size(data); > + m =3D (struct msg const *)iov_remove_header_(data, &m_storage, > offsetof(struct msg, o), > __alignof__(struct msg)); > if (!m || > @@ -367,24 +363,24 @@ int dhcp(const struct ctx *c, const struct pool *p) > for (i =3D 0; i < ARRAY_SIZE(opts); i++) > opts[i].clen =3D -1; > =20 > - opt_len =3D iov_tail_size(&data); > + opt_len =3D iov_tail_size(data); > while (opt_len >=3D 2) { > uint8_t olen_storage, type_storage; > const uint8_t *olen; > uint8_t *type; > =20 > - type =3D IOV_REMOVE_HEADER(&data, type_storage); > - olen =3D IOV_REMOVE_HEADER(&data, olen_storage); > + type =3D IOV_REMOVE_HEADER(data, type_storage); > + olen =3D IOV_REMOVE_HEADER(data, olen_storage); > if (!type || !olen) > return -1; > =20 > - opt_len =3D iov_tail_size(&data); > + opt_len =3D iov_tail_size(data); > if (opt_len < *olen) > return -1; > =20 > - iov_to_buf(&data.iov[0], data.cnt, data.off, &opts[*type].c, *olen); > + iov_to_buf(&data->iov[0], data->cnt, data->off, &opts[*type].c, *olen); > opts[*type].clen =3D *olen; > - iov_tail_drop(&data, *olen); > + iov_tail_drop(data, *olen); > opt_len -=3D *olen; > } > =20 > diff --git a/dhcp.h b/dhcp.h > index 87aeecd8dec8..cd50c99b8856 100644 > --- a/dhcp.h > +++ b/dhcp.h > @@ -6,7 +6,7 @@ > #ifndef DHCP_H > #define DHCP_H > =20 > -int dhcp(const struct ctx *c, const struct pool *p); > +int dhcp(const struct ctx *c, struct iov_tail *data); > void dhcp_init(void); > =20 > #endif /* DHCP_H */ > diff --git a/tap.c b/tap.c > index ace735cfc136..7d7e89304723 100644 > --- a/tap.c > +++ b/tap.c > @@ -785,11 +785,8 @@ resume: > if (iph->protocol =3D=3D IPPROTO_UDP) { > struct iov_tail eh_data; > =20 > - PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); > - > packet_get(in, i, &eh_data); > - packet_add(pkt, &eh_data); > - if (dhcp(c, pkt)) > + if (dhcp(c, &eh_data)) > continue; > } > =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 --+baFmIX1O3MsI5P7 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiS9ZIACgkQzQJF27ox 2Ge4Lg//R1xZ4paGCBW2l2DtVqWukSpHI6Ut9yI7l4EwFKXAokdU/n7If1LeEjL3 sU2Kndj2Q5VQWEVz3L5pFId9AYDUNNwtMQCwK7scdFr5bgybSdfU3491tA1Dz2t5 mPlaaqaYPj5uLp4V8337T11dOXrTWdr+eb6fPVkleSGI2FbKjVUYh8IB6G8LYcL6 1WLKHpOYNIHaSJnJzBmNceG/CaGTDNqkQx/SAEYdezl0eFYSepEDkownur1oyM/H CJZLrsxgxBnkhnuO4bnTkf0BUbcpKENV0YHZKRJA/eU4zH4hAgXSIax6+enlg0Zy SROzIC1OUUgP0JsaS+9mHSbJC7ITOqMSrgmPr8p/717mNsvf8bzFSKV9Cz465zcq XFh3aD/wrEPKp0TDX8SnH5JKfc6nOfB+lFAF8f5BS9lVa0XcLBI7mHyxmx+hd96z uzVsUrCjJEPfry5mKYZc0WRq+XMQlSXzXf57tCRjiELXv/jkve+RMXcb1rSwAi/f 040WFUbI3AHWRimdUc90O/cn1/AQLzCkWPGBfvV1NFbtQwIV6A5+bWKVX803tgz3 XOtkexl4y1/i26Q+kWekFaX6TH0J9lLO1qvTdCiIqPWZSV/32pPiy0z3pQeFhDtL g14mQ9764pDl9HVNunSNvnYiABpxwAEOU8yUA2h6K1XsKBQ675k= =mZU9 -----END PGP SIGNATURE----- --+baFmIX1O3MsI5P7--