On Thu, 17 Apr 2025 18:51:22 +0200
Laurent Vivier
Use packet_data() and extract headers using IOV_REMOVE_HEADER() and IOV_PEEK_HEADER() rather than packet_get().
Signed-off-by: Laurent Vivier
Reviewed-by: David Gibson --- dhcpv6.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dhcpv6.c b/dhcpv6.c index 549ddbbea735..a52af1b7a0fe 100644 --- a/dhcpv6.c +++ b/dhcpv6.c @@ -534,9 +534,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;
Same as the comment to 10/29: how bad would it be to call those mh_storage and uh_storage?
size_t mlen, n;
- uh = packet_get(p, 0, 0, sizeof(*uh), &mlen); + if (!packet_data(p, 0, &data)) + return -1; + + uh = IOV_REMOVE_HEADER(&data, uhc); if (!uh) return -1;
@@ -549,6 +555,7 @@ int dhcpv6(struct ctx *c, const struct pool *p, if (!IN6_IS_ADDR_MULTICAST(daddr)) return -1;
+ mlen = iov_tail_size(&data); if (mlen + sizeof(*uh) != ntohs(uh->len) || mlen < sizeof(*mh)) return -1;
@@ -556,7 +563,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;
-- Stefano