public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Only drop IPv6 fragments, not all packets with extension headers
@ 2026-11-24  2:40 Stefano Brivio
  2026-11-24  2:40 ` [PATCH 1/2] tap: Don't drop all packets with extension headers in ipv6_l4hdr() Stefano Brivio
  2026-11-24  2:40 ` [PATCH 2/2] tap: Explicitly drop outbound IPv6 fragments, warn about them Stefano Brivio
  0 siblings, 2 replies; 3+ messages in thread
From: Stefano Brivio @ 2026-11-24  2:40 UTC (permalink / raw)
  To: passt-dev

...even though we can't forward extension headers.  RFC 7045 recommends
that we don't drop packets because of those, and it was actually
unintended.  Patch 1/2 fixes the unintended behaviour, patch 2/2
restores explicit filtering of fragments.

Stefano Brivio (2):
  tap: Don't drop all packets with extension headers in ipv6_l4hdr()
  tap: Explicitly drop outbound IPv6 fragments, warn about them

 tap.c | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] tap: Don't drop all packets with extension headers in ipv6_l4hdr()
  2026-11-24  2:40 [PATCH 0/2] Only drop IPv6 fragments, not all packets with extension headers Stefano Brivio
@ 2026-11-24  2:40 ` Stefano Brivio
  2026-11-24  2:40 ` [PATCH 2/2] tap: Explicitly drop outbound IPv6 fragments, warn about them Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2026-11-24  2:40 UTC (permalink / raw)
  To: passt-dev

The loop in ipv6_l4hdr() was intended to skip extension headers (which
we can't forward), but as we exit that function without dropping the
last one we find (if any), we'll actually discard packets because the
last extension header is used as Layer-4 header, which is later
handled as having an unknown protocol number.

This is in contrast with the recommendation from RFC 7045, which says
that any forwarding node should forward packets regardless of any
extension header.  Notably, that RFC, and no current normative
standards for that matter, doesn't introduce any particular
requirement regarding the forwarding of extension headers themselves,
so it's probably fine that we drop them (we have no choice anyway).

Drop the last extension header we find, before leaving ipv6_l4hdr().

Fixing this carries the unintendend consequence that IPv6 fragments
would be forwarded (not as fragments though), but, just like we do
for IPv4, we want to drop them instead.  The next patch will take care
of that.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 tap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tap.c b/tap.c
index 13b31b1..bfb2532 100644
--- a/tap.c
+++ b/tap.c
@@ -935,9 +935,9 @@ static bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen)
 		nh = o->nexthdr;
 		hdrlen = (o->hdrlen + 1) * 8;
 
-		if (IPV6_NH_OPT(nh))
-			iov_drop_header(data, hdrlen);
-		else
+		iov_drop_header(data, hdrlen);
+
+		if (!IPV6_NH_OPT(nh))
 			goto found;
 	}
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tap: Explicitly drop outbound IPv6 fragments, warn about them
  2026-11-24  2:40 [PATCH 0/2] Only drop IPv6 fragments, not all packets with extension headers Stefano Brivio
  2026-11-24  2:40 ` [PATCH 1/2] tap: Don't drop all packets with extension headers in ipv6_l4hdr() Stefano Brivio
@ 2026-11-24  2:40 ` Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2026-11-24  2:40 UTC (permalink / raw)
  To: passt-dev

In the previous patch, we fixed the loop in ipv6_l4hdr(), which was
previously, implicitly, dropping IPv6 fragments.  Now we have to
reintroduce dropping of IPv6 fragments in an explicit way.  Adopt the
same approach as we have for IPv4 with a separate function,
tap6_is_fragment(), counting fragments and reporting rate-limited
warnings.

From a standards perspective, note that RFC 7045 doesn't mention any
particular recommendation but refers to an expired Internet-Draft,
draft-taylor-v6ops-fragdrop-02, which concludes, in section 2.1.5:

   Operators weigh the risks associated with each of the considerations
   just enumerated, and come up with the most suitable policy for their
   circumstances.  It is likely that at least some operators will find
   it desirable to drop fragments in at least some cases.

given that forwarding fragments makes little sense in our case, and
that it would add substantial complexity, consider it desirable and
continue dropping them.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 tap.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/tap.c b/tap.c
index bfb2532..d37e2e3 100644
--- a/tap.c
+++ b/tap.c
@@ -900,6 +900,28 @@ append:
 	return in->count;
 }
 
+/**
+ * tap6_is_fragment() - Determine if header type indicates a fragment, log it
+ * @nh:		Next extension header type
+ * @now:	Current timestamp
+ *
+ * Return: true if @nh indicates a fragment header, false otherwise
+ */
+static bool tap6_is_fragment(uint8_t nh, const struct timespec *now)
+{
+	if (nh == IPPROTO_FRAGMENT) {
+		static unsigned num_dropped;
+
+		num_dropped++;
+		warn_ratelimit(now, "Can't process IPv6 fragments (%u dropped)",
+			       num_dropped);
+
+		return true;
+	}
+
+	return false;
+}
+
 #define IPV6_NH_OPT(nh)							\
 	((nh) == 0   || (nh) == 43  || (nh) == 44  || (nh) == 50  ||	\
 	 (nh) == 51  || (nh) == 60  || (nh) == 135 || (nh) == 139 ||	\
@@ -910,11 +932,13 @@ append:
  * @data:	IPv6 packet
  * @proto:	Filled with L4 protocol number
  * @dlen:	Data length (payload excluding header extensions), set on return
+ * @now:	Current timestamp
  *
  * Return: true if the L4 header is found and @data, @proto, @dlen are set,
  * 	   false on error. Outputs are indeterminate on failure.
  */
-static bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen)
+static bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen,
+		       const struct timespec *now)
 {
 	struct ipv6_opt_hdr o_storage;
 	const struct ipv6_opt_hdr *o;
@@ -931,10 +955,16 @@ static bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen)
 	if (!IPV6_NH_OPT(nh))
 		goto found;
 
+	if (tap6_is_fragment(nh, now))
+		return false;
+
 	while ((o = IOV_PEEK_HEADER(data, o_storage))) {
 		nh = o->nexthdr;
 		hdrlen = (o->hdrlen + 1) * 8;
 
+		if (tap6_is_fragment(nh, now))
+			return false;
+
 		iov_drop_header(data, hdrlen);
 
 		if (!IPV6_NH_OPT(nh))
@@ -1003,7 +1033,7 @@ resume:
 		if (plen != check)
 			continue;
 
-		if (!ipv6_l4hdr(&data, &proto, &l4len))
+		if (!ipv6_l4hdr(&data, &proto, &l4len, now))
 			continue;
 
 		if (tap_filter_address(now, AF_INET6, saddr, daddr))
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-24  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24  2:40 [PATCH 0/2] Only drop IPv6 fragments, not all packets with extension headers Stefano Brivio
2026-11-24  2:40 ` [PATCH 1/2] tap: Don't drop all packets with extension headers in ipv6_l4hdr() Stefano Brivio
2026-11-24  2:40 ` [PATCH 2/2] tap: Explicitly drop outbound IPv6 fragments, warn about them Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).