DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org,
	Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: [PATCH 1/2] ip_frag: generate a fragment identification for IPv6
Date: Sat, 21 Nov 2026 08:51:52 -0800	[thread overview]
Message-ID: <20261121165311.1547352-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20261121165311.1547352-1-stephen@networkplumber.org>

The current ip_frag library always writes id of zero in the
fragment header. This can cause problems at receiver because all
fragments between the same addresses are then interchangeable,
so a lost fragment splices two datagrams instead of timing out.

The existing code does not follow the relevant RFC's for this.
RFC 8200 section 4.5 wants an Identification distinct from
other recent packets between those addresses,
RFC 7739 an unpredictable one.

Bugzilla ID: 2153
Fixes: 0aa31d7a5929 ("ip_frag: add IPv6 fragmentation support")
Cc: stable@dpdk.org

Reported-by: Anthropic OSS scanner (ANT-2026-70V47B5Y)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ip_frag/rte_ipv6_fragmentation.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/ip_frag/rte_ipv6_fragmentation.c b/lib/ip_frag/rte_ipv6_fragmentation.c
index 791193f181..69ac9012b1 100644
--- a/lib/ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/ip_frag/rte_ipv6_fragmentation.c
@@ -6,6 +6,7 @@
 #include <errno.h>
 
 #include <eal_export.h>
+#include <rte_random.h>
 
 #include "ip_frag_common.h"
 
@@ -19,7 +20,7 @@
 static inline void
 __fill_ipv6hdr_frag(struct rte_ipv6_hdr *dst,
 		const struct rte_ipv6_hdr *src, uint16_t len, uint16_t fofs,
-		uint32_t mf)
+		uint32_t mf, rte_be32_t id)
 {
 	struct rte_ipv6_fragment_ext *fh;
 
@@ -31,7 +32,7 @@ __fill_ipv6hdr_frag(struct rte_ipv6_hdr *dst,
 	fh->next_header = src->proto;
 	fh->reserved = 0;
 	fh->frag_data = rte_cpu_to_be_16(RTE_IPV6_SET_FRAG_DATA(fofs, mf));
-	fh->id = 0;
+	fh->id = id;
 }
 
 static inline void
@@ -78,6 +79,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 	uint32_t more_in_segs;
 	uint16_t fragment_offset, frag_size;
 	uint64_t frag_bytes_remaining;
+	rte_be32_t frag_id;
 
 	/*
 	 * Formal parameter checking.
@@ -117,6 +119,12 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 	out_pkt_pos = 0;
 	fragment_offset = 0;
 
+	/*
+	 * An unfragmented packet carries no Identification, so generate one.
+	 * RFC 8200 wants it distinct per packet, RFC 7739 unpredictable.
+	 */
+	frag_id = (rte_be32_t)rte_rand();
+
 	more_in_segs = 1;
 	while (likely(more_in_segs)) {
 		struct rte_mbuf *out_pkt = NULL, *out_seg_prev = NULL;
@@ -188,7 +196,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
 
 		__fill_ipv6hdr_frag(out_hdr, in_hdr,
 		    (uint16_t) out_pkt->pkt_len - sizeof(struct rte_ipv6_hdr),
-		    fragment_offset, more_in_segs);
+		    fragment_offset, more_in_segs, frag_id);
 
 		fragment_offset = (uint16_t)(fragment_offset +
 		    out_pkt->pkt_len - sizeof(struct rte_ipv6_hdr)
-- 
2.53.0


  reply	other threads:[~2026-11-21 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 16:51 [PATCH 0/2] ip_frag: fix IPV6 frag id Stephen Hemminger
2026-11-21 16:51 ` Stephen Hemminger [this message]
2026-11-21 16:51 ` [PATCH 2/2] test: add test for IPv6 fragmentation id Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261121165311.1547352-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox