DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ip_frag: modify the fragment offset and mf
@ 2021-09-27 10:06 huichao cai
  2021-10-07 17:26 ` Ananyev, Konstantin
  2021-10-09  7:27 ` [dpdk-dev] [PATCH v2] ip_frag: fix fragmenting IPv4 fragment huichao cai
  0 siblings, 2 replies; 14+ messages in thread
From: huichao cai @ 2021-09-27 10:06 UTC (permalink / raw)
  To: konstantin.ananyev; +Cc: dev, huichao cai

From: huichao cai <chcchc88@163.com>

According to RFC791,the fragment offset value should be
calculated based on the long datagram,the more fragments flag
for the last fragment carries the same value as the long datagram.

Signed-off-by: huichao cai <chcchc88@163.com>
---
 lib/ip_frag/rte_ipv4_fragmentation.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/ip_frag/rte_ipv4_fragmentation.c b/lib/ip_frag/rte_ipv4_fragmentation.c
index 2e7739d..fead5a9 100644
--- a/lib/ip_frag/rte_ipv4_fragmentation.c
+++ b/lib/ip_frag/rte_ipv4_fragmentation.c
@@ -75,7 +75,7 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 	uint32_t out_pkt_pos, in_seg_data_pos;
 	uint32_t more_in_segs;
 	uint16_t fragment_offset, flag_offset, frag_size, header_len;
-	uint16_t frag_bytes_remaining;
+	uint16_t frag_bytes_remaining, not_last_frag;
 
 	/*
 	 * Formal parameter checking.
@@ -116,7 +116,9 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 	in_seg = pkt_in;
 	in_seg_data_pos = header_len;
 	out_pkt_pos = 0;
-	fragment_offset = 0;
+	fragment_offset = (uint16_t)((flag_offset &
+	    RTE_IPV4_HDR_OFFSET_MASK) << RTE_IPV4_HDR_FO_SHIFT);
+	not_last_frag = (uint16_t)(flag_offset & IPV4_HDR_MF_MASK);
 
 	more_in_segs = 1;
 	while (likely(more_in_segs)) {
@@ -186,7 +188,8 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 
 		__fill_ipv4hdr_frag(out_hdr, in_hdr, header_len,
 		    (uint16_t)out_pkt->pkt_len,
-		    flag_offset, fragment_offset, more_in_segs);
+		    flag_offset, fragment_offset,
+		    not_last_frag || more_in_segs);
 
 		fragment_offset = (uint16_t)(fragment_offset +
 		    out_pkt->pkt_len - header_len);
-- 
1.8.3.1


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

end of thread, other threads:[~2021-10-14  6:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 10:06 [dpdk-dev] [PATCH] ip_frag: modify the fragment offset and mf huichao cai
2021-10-07 17:26 ` Ananyev, Konstantin
2021-10-08  8:05   ` 蔡慧超
2021-10-08  8:33     ` Ananyev, Konstantin
2021-10-08  9:37       ` 蔡慧超
2021-10-08 10:24         ` Ananyev, Konstantin
2021-10-09  7:27 ` [dpdk-dev] [PATCH v2] ip_frag: fix fragmenting IPv4 fragment huichao cai
2021-10-12 10:16   ` Ananyev, Konstantin
2021-10-13  6:53     ` 蔡慧超
2021-10-13  9:12       ` Ananyev, Konstantin
2021-10-13  9:50         ` 蔡慧超
2021-10-14  6:51     ` Thomas Monjalon
2021-10-13 21:11   ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2021-10-14  3:30     ` 蔡慧超

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 NNTP newsgroup(s).