On Wed, Apr 02, 2025 at 07:23:37PM +0200, Laurent Vivier wrote:Use packet_base() and extract headers using IOV_REMOVE_HEADER() and IOV_PEEK_HEADER() rather than packet_get(). Signed-off-by: Laurent Vivier <lvivier(a)redhat.com> --- dhcpv6.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dhcpv6.c b/dhcpv6.c index 373a98869f9b..eb3f188af0b5 100644 --- a/dhcpv6.c +++ b/dhcpv6.c @@ -496,9 +496,15 @@ int dhcpv6(struct ctx *c, const struct pool *p, const struct msg_hdr *mh; const struct udphdr *uh; struct opt_hdr *bad_ia; + struct iov_tail data; + struct msg_hdr mhc; + struct udphdr uhc; size_t mlen, n; - uh = packet_get(p, 0, 0, sizeof(*uh), &mlen); + if (!packet_base(p, 0, &data)) + return -1; + + uh = IOV_REMOVE_HEADER(&data, uhc); if (!uh) return -1; @@ -511,6 +517,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, if (!IN6_IS_ADDR_MULTICAST(daddr)) return -1; + mlen = iov_tail_size(&data);The total length is useful in enough cases that I wonder if it makes sense for packet_base() to return it.if (mlen + sizeof(*uh) != ntohs(uh->len) || mlen < sizeof(*mh)) return -1; @@ -518,7 +525,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, src = &c->ip6.our_tap_ll; - mh = packet_get(p, 0, sizeof(*uh), sizeof(*mh), NULL); + mh = IOV_PEEK_HEADER(&data, mhc); if (!mh) return -1;-- 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