From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D56D2A0547; Mon, 27 Sep 2021 12:10:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F6F840686; Mon, 27 Sep 2021 12:10:19 +0200 (CEST) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.227]) by mails.dpdk.org (Postfix) with ESMTP id 225B340686 for ; Mon, 27 Sep 2021 12:06:43 +0200 (CEST) HMM_SOURCE_IP: 172.18.0.218:60532.1236246008 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-10.133.11.244 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id C0AE328009D; Mon, 27 Sep 2021 18:06:36 +0800 (CST) X-189-SAVE-TO-SEND: caihc1@chinatelecom.cn Received: from ([172.18.0.218]) by app0025 with ESMTP id 25ff542911f240768b87e021847da662 for konstantin.ananyev@intel.com; Mon, 27 Sep 2021 18:06:37 CST X-Transaction-ID: 25ff542911f240768b87e021847da662 X-Real-From: caihc1@chinatelecom.cn X-Receive-IP: 172.18.0.218 From: huichao cai To: konstantin.ananyev@intel.com Cc: dev@dpdk.org, huichao cai Date: Mon, 27 Sep 2021 18:06:14 +0800 Message-Id: <1632737174-86870-1-git-send-email-caihc1@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 X-Mailman-Approved-At: Mon, 27 Sep 2021 12:10:18 +0200 Subject: [dpdk-dev] [PATCH] ip_frag: modify the fragment offset and mf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: huichao cai 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 --- 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