aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2025-09-02 09:52:49 +0200
committerStefano Brivio <sbrivio@redhat.com>2025-09-03 20:43:44 +0200
commit2eb845a0e78c4ce0cd6f79c5cd9057f30c819595 (patch)
treea5fe89fb757d6017eaed0de6f546fedc50df6f6c
parent76de6f5119972e51504929df63f44f50444ee445 (diff)
downloadpasst-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar.gz
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar.bz2
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar.lz
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar.xz
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.tar.zst
passt-2eb845a0e78c4ce0cd6f79c5cd9057f30c819595.zip
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 <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--ndp.c19
-rw-r--r--ndp.h4
-rw-r--r--tap.c10
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);