* [PATCH 1/3] tap: Move tap4_handler() / tap6_handler() adddress checks to own function
2026-11-24 2:40 [PATCH 0/3] Throttle messages for invalid addresses, drop v4-mapped packets Stefano Brivio
@ 2026-11-24 2:40 ` Stefano Brivio
2026-11-24 2:40 ` [PATCH 2/3] tap: Rate limit messages about filtered guest-side addresses Stefano Brivio
2026-11-24 2:40 ` [PATCH 3/3] tap: Drop IPv6 packets with outbound v4-mapped addresses as well Stefano Brivio
2 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2026-11-24 2:40 UTC (permalink / raw)
To: passt-dev; +Cc: Anders Ingemann, David Gibson
This avoids some duplication and makes upcoming patches less ugly.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tap.c | 60 ++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/tap.c b/tap.c
index 100afc8..78030f3 100644
--- a/tap.c
+++ b/tap.c
@@ -660,6 +660,39 @@ static void tap_packet_debug(const struct iphdr *iph,
}
}
+/**
+ * tap_filter_address() - Filter packets based on source and destination address
+ * @af: Address family, AF_INET or AF_INET6
+ * @saddr: Source address
+ * @daddr: Destination address
+ *
+ * Return: true if packet must be dropped, false otherwise
+ */
+static bool tap_filter_address(sa_family_t af,
+ const void *saddr, const void *daddr)
+{
+ /* The scope of sstr and dstr could be in theory reduced into the
+ * conditional block debug() expands to, but it's awkward and
+ * unreadable, so ignore this warning.
+ */
+ /* cppcheck-suppress [variableScope,unmatchedSuppression] */
+ char sstr[INANY_ADDRSTRLEN], dstr[INANY_ADDRSTRLEN];
+
+ if (af == AF_INET &&
+ !IN4_IS_ADDR_LOOPBACK(saddr) && !IN4_IS_ADDR_LOOPBACK(daddr))
+ return false;
+
+ if (af == AF_INET6 &&
+ !IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr))
+ return false;
+
+ debug("Invalid address on tap interface: %s -> %s",
+ inet_ntop(af, saddr, sstr, sizeof(sstr)),
+ inet_ntop(af, daddr, dstr, sizeof(dstr)));
+
+ return true;
+}
+
/**
* tap4_is_fragment() - Determine if a packet is an IP fragment
* @iph: IPv4 header (length already validated)
@@ -741,20 +774,8 @@ resume:
l4len = htons(iph->tot_len) - hlen;
- if (IN4_IS_ADDR_LOOPBACK(&iph->saddr) ||
- IN4_IS_ADDR_LOOPBACK(&iph->daddr)) {
- /* The scope of sstr and dstr could be in theory reduced
- * into the conditional block debug() expands to, but
- * it's awkward and unreadable, so ignore this warning.
- */
- /* cppcheck-suppress [variableScope,unmatchedSuppression] */
- char sstr[INET_ADDRSTRLEN], dstr[INET_ADDRSTRLEN];
-
- debug("Loopback address on tap interface: %s -> %s",
- inet_ntop(AF_INET, &iph->saddr, sstr, sizeof(sstr)),
- inet_ntop(AF_INET, &iph->daddr, dstr, sizeof(dstr)));
+ if (tap_filter_address(AF_INET, &iph->saddr, &iph->daddr))
continue;
- }
if (!c->ip4.addr_fixed &&
iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
@@ -983,19 +1004,8 @@ resume:
if (!ipv6_l4hdr(&data, &proto, &l4len))
continue;
- if (IN6_IS_ADDR_LOOPBACK(saddr) || IN6_IS_ADDR_LOOPBACK(daddr)) {
- /* The scope of sstr and dstr could be in theory reduced
- * into the conditional block debug() expands to, but
- * it's awkward and unreadable, so ignore this warning.
- */
- /* cppcheck-suppress [variableScope,unmatchedSuppression] */
- char sstr[INET6_ADDRSTRLEN], dstr[INET6_ADDRSTRLEN];
-
- debug("Loopback address on tap interface: %s -> %s",
- inet_ntop(AF_INET6, saddr, sstr, sizeof(sstr)),
- inet_ntop(AF_INET6, daddr, dstr, sizeof(dstr)));
+ if (tap_filter_address(AF_INET6, saddr, daddr))
continue;
- }
if (IN6_IS_ADDR_LINKLOCAL(saddr)) {
c->ip6.addr_ll_seen = *saddr;
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/3] tap: Rate limit messages about filtered guest-side addresses
2026-11-24 2:40 [PATCH 0/3] Throttle messages for invalid addresses, drop v4-mapped packets Stefano Brivio
2026-11-24 2:40 ` [PATCH 1/3] tap: Move tap4_handler() / tap6_handler() adddress checks to own function Stefano Brivio
@ 2026-11-24 2:40 ` Stefano Brivio
2026-11-24 2:40 ` [PATCH 3/3] tap: Drop IPv6 packets with outbound v4-mapped addresses as well Stefano Brivio
2 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2026-11-24 2:40 UTC (permalink / raw)
To: passt-dev; +Cc: Anders Ingemann, David Gibson
Even though those are debug messages, very frequent messages would
make debugging harder.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tap.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tap.c b/tap.c
index 78030f3..eb2f147 100644
--- a/tap.c
+++ b/tap.c
@@ -662,13 +662,14 @@ static void tap_packet_debug(const struct iphdr *iph,
/**
* tap_filter_address() - Filter packets based on source and destination address
+ * @now: Current timestamp
* @af: Address family, AF_INET or AF_INET6
* @saddr: Source address
* @daddr: Destination address
*
* Return: true if packet must be dropped, false otherwise
*/
-static bool tap_filter_address(sa_family_t af,
+static bool tap_filter_address(const struct timespec *now, sa_family_t af,
const void *saddr, const void *daddr)
{
/* The scope of sstr and dstr could be in theory reduced into the
@@ -686,9 +687,9 @@ static bool tap_filter_address(sa_family_t af,
!IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr))
return false;
- debug("Invalid address on tap interface: %s -> %s",
- inet_ntop(af, saddr, sstr, sizeof(sstr)),
- inet_ntop(af, daddr, dstr, sizeof(dstr)));
+ debug_ratelimit(now, "Invalid address on tap interface: %s -> %s",
+ inet_ntop(af, saddr, sstr, sizeof(sstr)),
+ inet_ntop(af, daddr, dstr, sizeof(dstr)));
return true;
}
@@ -774,7 +775,7 @@ resume:
l4len = htons(iph->tot_len) - hlen;
- if (tap_filter_address(AF_INET, &iph->saddr, &iph->daddr))
+ if (tap_filter_address(now, AF_INET, &iph->saddr, &iph->daddr))
continue;
if (!c->ip4.addr_fixed &&
@@ -1004,7 +1005,7 @@ resume:
if (!ipv6_l4hdr(&data, &proto, &l4len))
continue;
- if (tap_filter_address(AF_INET6, saddr, daddr))
+ if (tap_filter_address(now, AF_INET6, saddr, daddr))
continue;
if (IN6_IS_ADDR_LINKLOCAL(saddr)) {
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 3/3] tap: Drop IPv6 packets with outbound v4-mapped addresses as well
2026-11-24 2:40 [PATCH 0/3] Throttle messages for invalid addresses, drop v4-mapped packets Stefano Brivio
2026-11-24 2:40 ` [PATCH 1/3] tap: Move tap4_handler() / tap6_handler() adddress checks to own function Stefano Brivio
2026-11-24 2:40 ` [PATCH 2/3] tap: Rate limit messages about filtered guest-side addresses Stefano Brivio
@ 2026-11-24 2:40 ` Stefano Brivio
2026-11-24 2:59 ` David Gibson
2 siblings, 1 reply; 5+ messages in thread
From: Stefano Brivio @ 2026-11-24 2:40 UTC (permalink / raw)
To: passt-dev; +Cc: Anders Ingemann, David Gibson
...not just ones with loopback addresses. It was a convenient way to
try out stuff, but I don't think anybody is using this (also judging
from the current KubeVirt integration), while Anders reported it as
unexpected, and David points out that even though this never became an
RFC:
https://datatracker.ietf.org/doc/html/draft-itojun-v6ops-v4mapped-harmful-02
it's actually mentioned by RFC 4038 as a draft presenting legitimate
concerns. In the context of this draft, it's not obvious whether we
are a router, or a node, but, arguably, we implement at least some
notion of "wire".
So, while we don't really have any formal requirement to drop those,
err on the side of caution and filter them out just like we do with
packets with loopback addresses. Document it as well, just in case
somebody else used that trick.
Reported-by: Anders Ingemann <anders@ingemann.de>
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
passt.1 | 16 ++++++++++++++++
tap.c | 3 ++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/passt.1 b/passt.1
index 5d236bd..daceba1 100644
--- a/passt.1
+++ b/passt.1
@@ -1126,6 +1126,22 @@ appear to come from loopback in the namespace as well. The latter
behaviour used to be the default, but is usually undesirable, since it
can unintentionally expose namespace local services to the host.
+.SS Handling of IPv6 packets with IPv4-mapped addresses
+
+\fBpasst\fR and \fBpasta\fR implement some of the recommendations from the
+expired draft-itojun-v6ops-v4mapped-harmful-02 Internet-Draft:
+
+.nf
+ https://datatracker.ietf.org/doc/draft-itojun-v6ops-v4mapped-harmful/02/
+.fi
+
+by silently discarding outbound IPv6 packets with IPv4-mapped addresses used as
+source or destination. This means that IPv4 destinations can't be reached from
+the guest or container via IPv6 using their IPv4-mapped representation.
+
+If you have any use for traffic forwarding using IPv4-mapped addresses, refer to
+\fBREPORTING BUGS\fR below.
+
.SS Binding to low numbered ports (well-known or system ports, up to 1023)
If the port forwarding configuration requires binding to ports with numbers
diff --git a/tap.c b/tap.c
index eb2f147..13b31b1 100644
--- a/tap.c
+++ b/tap.c
@@ -684,7 +684,8 @@ static bool tap_filter_address(const struct timespec *now, sa_family_t af,
return false;
if (af == AF_INET6 &&
- !IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr))
+ !IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr) &&
+ !IN6_IS_ADDR_V4MAPPED(saddr) && !IN6_IS_ADDR_V4MAPPED(daddr))
return false;
debug_ratelimit(now, "Invalid address on tap interface: %s -> %s",
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] tap: Drop IPv6 packets with outbound v4-mapped addresses as well
2026-11-24 2:40 ` [PATCH 3/3] tap: Drop IPv6 packets with outbound v4-mapped addresses as well Stefano Brivio
@ 2026-11-24 2:59 ` David Gibson
0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2026-11-24 2:59 UTC (permalink / raw)
To: Stefano Brivio; +Cc: passt-dev, Anders Ingemann
[-- Attachment #1: Type: text/plain, Size: 3376 bytes --]
On Tue, Nov 24, 2026 at 03:40:12AM +0100, Stefano Brivio wrote:
> ...not just ones with loopback addresses. It was a convenient way to
> try out stuff, but I don't think anybody is using this (also judging
> from the current KubeVirt integration), while Anders reported it as
> unexpected, and David points out that even though this never became an
> RFC:
>
> https://datatracker.ietf.org/doc/html/draft-itojun-v6ops-v4mapped-harmful-02
>
> it's actually mentioned by RFC 4038 as a draft presenting legitimate
> concerns. In the context of this draft, it's not obvious whether we
> are a router, or a node, but, arguably, we implement at least some
> notion of "wire".
>
> So, while we don't really have any formal requirement to drop those,
> err on the side of caution and filter them out just like we do with
> packets with loopback addresses. Document it as well, just in case
> somebody else used that trick.
>
> Reported-by: Anders Ingemann <anders@ingemann.de>
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
> passt.1 | 16 ++++++++++++++++
> tap.c | 3 ++-
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/passt.1 b/passt.1
> index 5d236bd..daceba1 100644
> --- a/passt.1
> +++ b/passt.1
> @@ -1126,6 +1126,22 @@ appear to come from loopback in the namespace as well. The latter
> behaviour used to be the default, but is usually undesirable, since it
> can unintentionally expose namespace local services to the host.
>
> +.SS Handling of IPv6 packets with IPv4-mapped addresses
> +
> +\fBpasst\fR and \fBpasta\fR implement some of the recommendations from the
> +expired draft-itojun-v6ops-v4mapped-harmful-02 Internet-Draft:
> +
> +.nf
> + https://datatracker.ietf.org/doc/draft-itojun-v6ops-v4mapped-harmful/02/
> +.fi
> +
> +by silently discarding outbound IPv6 packets with IPv4-mapped addresses used as
> +source or destination. This means that IPv4 destinations can't be reached from
> +the guest or container via IPv6 using their IPv4-mapped representation.
Fwiw, I don't think that was _ever_ an intended use for IPv4-mapped
addresses (:ffff::/96). Rather that was the purpose of (deprecated)
IPv4-compatible IPv6 addresses (::/96).
> +If you have any use for traffic forwarding using IPv4-mapped addresses, refer to
> +\fBREPORTING BUGS\fR below.
> +
> .SS Binding to low numbered ports (well-known or system ports, up to 1023)
>
> If the port forwarding configuration requires binding to ports with numbers
> diff --git a/tap.c b/tap.c
> index eb2f147..13b31b1 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -684,7 +684,8 @@ static bool tap_filter_address(const struct timespec *now, sa_family_t af,
> return false;
>
> if (af == AF_INET6 &&
> - !IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr))
> + !IN6_IS_ADDR_LOOPBACK(saddr) && !IN6_IS_ADDR_LOOPBACK(daddr) &&
> + !IN6_IS_ADDR_V4MAPPED(saddr) && !IN6_IS_ADDR_V4MAPPED(daddr))
> return false;
>
> debug_ratelimit(now, "Invalid address on tap interface: %s -> %s",
> --
> 2.43.0
>
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread