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 D2C7CA0C43 for ; Sat, 9 Oct 2021 09:27:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C01674067A; Sat, 9 Oct 2021 09:27:25 +0200 (CEST) Received: from m12-11.163.com (m12-11.163.com [220.181.12.11]) by mails.dpdk.org (Postfix) with ESMTP id 722904003C; Sat, 9 Oct 2021 09:27:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=K8B10 CJlKJieCvOAuzqhgjHDuriXKd0azJEI+d+6Y1Q=; b=inCVHXt3eWhw1cNmIstCW vSs9JN3JmDFxrigdn3faHIv/cO5TGevDrfhGVfYnpNMbgtoEhH0z1EAqHHuGbBT9 xChww5aNP6YUuG3z/qFVITtfJ8xZH5lHPUkvXYWgnDqx4Usfh9ubg5jXmghXI8sT z5JyiUr0rfYEp0mPKb7j6A= Received: from bogon.localdomain (unknown [36.111.88.18]) by smtp7 (Coremail) with SMTP id C8CowAC3u4tTRGFhS9600w--.32886S2; Sat, 09 Oct 2021 15:27:19 +0800 (CST) From: huichao cai To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, stable@dpdk.org Date: Sat, 9 Oct 2021 15:27:04 +0800 Message-Id: <1633764424-17370-1-git-send-email-chcchc88@163.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1632737174-86870-1-git-send-email-caihc1@chinatelecom.cn> References: <1632737174-86870-1-git-send-email-caihc1@chinatelecom.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: C8CowAC3u4tTRGFhS9600w--.32886S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KFy7Ar17tF4kCw1DGr13XFb_yoW8ur1xpa 48tr9Iq3WrtF1kGw4kXrs0q3yrJas7KF4jgr95Grn3tF4jkr95tayakr1jkw1xKFykA3s3 A39xKFy5ua1xWa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j0UDJUUUUU= X-Originating-IP: [36.111.88.18] X-CM-SenderInfo: pfkfuxrfyyqiywtou0bp/1tbiMRgnF1UMZro3HQAAs2 Subject: [dpdk-stable] [PATCH v2] ip_frag: fix fragmenting IPv4 fragment X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Current implementation of rte_ipv4_fragment_packet() doesn’t take into account offset and flag values of the given packet, but blindly assumes they are always zero (original packet is not fragmented). According to RFC791, fragment and flag values for new fragment should take into account values provided in the original IPv4 packet. Fixes: 4c38e5532a07 ("ip_frag: refactor IPv4 fragmentation into a proper library") Cc: stable@dpdk.org Signed-off-by: huichao cai --- v2: * Reword commit message. 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