Use packet_base() and extract headers using IOV_REMOVE_HEADER()
and IOV_PEEK_HEADER() rather than packet_get().
Signed-off-by: Laurent Vivier
---
dhcpv6.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dhcpv6.c b/dhcpv6.c
index 549ddbbea735..cf5c77d5af72 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;
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;
@@ -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;
--
2.49.0