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
---
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 fb2bf1161b66..09d43546b91e 100644
--- a/ndp.c
+++ b/ndp.c
@@ -337,13 +337,20 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst)
* @c: Execution context
* @ih: ICMPv6 header
* @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;
@@ -353,12 +360,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 683da5b6d431..964e036d8de5 100644
--- a/tap.c
+++ b/tap.c
@@ -940,9 +940,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;
@@ -950,10 +948,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);
--
2.49.0