On Tue, Aug 05, 2025 at 05:46:24PM +0200, Laurent Vivier wrote:
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
--- 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 ba87a0aaa6e9..eb090cd2c5a7 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 41c2000356ec..b1dd5e82c085 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 48152a84674c..d327ec0c3d54 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);
-- 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