From 2eb845a0e78c4ce0cd6f79c5cd9057f30c819595 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Tue, 2 Sep 2025 09:52:49 +0200 Subject: ndp: use iov_tail rather than pool The ndp() function signature is changed to accept `struct iov_tail *data` directly, replacing the previous `const struct pool *p` and `const struct icmp6hdr *ih` parameters. This change simplifies callers, like tap6_handler(), which now provide the iov_tail representing the L4 ICMPv6 segment directly to ndp(). Signed-off-by: Laurent Vivier Reviewed-by: David Gibson Signed-off-by: Stefano Brivio --- ndp.c | 19 +++++++++++-------- ndp.h | 4 ++-- tap.c | 10 +++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ndp.c b/ndp.c index ba87a0a..eb090cd 100644 --- a/ndp.c +++ b/ndp.c @@ -336,13 +336,20 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst) * ndp() - Check for NDP solicitations, reply as needed * @c: Execution context * @saddr: Source IPv6 address - * @p: Packet pool + * @data: Single packet with ICMPv6 header * * Return: 0 if not handled here, 1 if handled, -1 on failure */ -int ndp(const struct ctx *c, const struct icmp6hdr *ih, - const struct in6_addr *saddr, const struct pool *p) +int ndp(const struct ctx *c, const struct in6_addr *saddr, + struct iov_tail *data) { + struct icmp6hdr ih_storage; + const struct icmp6hdr *ih; + + ih = IOV_PEEK_HEADER(data, ih_storage); + if (!ih) + return -1; + if (ih->icmp6_type < RS || ih->icmp6_type > NA) return 0; @@ -352,12 +359,8 @@ int ndp(const struct ctx *c, const struct icmp6hdr *ih, if (ih->icmp6_type == NS) { struct ndp_ns ns_storage; const struct ndp_ns *ns; - struct iov_tail data; - - if (!packet_get(p, 0, &data)) - return -1; - ns = IOV_REMOVE_HEADER(&data, ns_storage); + ns = IOV_REMOVE_HEADER(data, ns_storage); if (!ns) return -1; diff --git a/ndp.h b/ndp.h index 41c2000..b1dd5e8 100644 --- a/ndp.h +++ b/ndp.h @@ -8,8 +8,8 @@ struct icmp6hdr; -int ndp(const struct ctx *c, const struct icmp6hdr *ih, - const struct in6_addr *saddr, const struct pool *p); +int ndp(const struct ctx *c, const struct in6_addr *saddr, + struct iov_tail *data); void ndp_timer(const struct ctx *c, const struct timespec *now); #endif /* NDP_H */ diff --git a/tap.c b/tap.c index 1a7088a..7081041 100644 --- a/tap.c +++ b/tap.c @@ -942,9 +942,7 @@ resume: } if (proto == IPPROTO_ICMPV6) { - struct icmp6hdr l4h_storage; - const struct icmp6hdr *l4h; - PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); + struct iov_tail ndp_data; if (c->no_icmp) continue; @@ -952,10 +950,8 @@ resume: if (l4len < sizeof(struct icmp6hdr)) continue; - packet_add(pkt, &data); - - l4h = IOV_PEEK_HEADER(&data, l4h_storage); - if (ndp(c, (struct icmp6hdr *)l4h, saddr, pkt)) + ndp_data = data; + if (ndp(c, saddr, &ndp_data)) continue; tap_packet_debug(NULL, ip6h, NULL, proto, NULL, 1); -- cgit v1.2.3