[v2] ip_frag: fix fragmenting IPv4 fragment

Message ID 1633764424-17370-1-git-send-email-chcchc88@163.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] ip_frag: fix fragmenting IPv4 fragment |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Huichao Cai Oct. 9, 2021, 7:27 a.m. UTC
  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 <chcchc88@163.com>
---
v2:
* Reword commit message.

 lib/ip_frag/rte_ipv4_fragmentation.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Ananyev, Konstantin Oct. 12, 2021, 10:16 a.m. UTC | #1
> 
> 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 <chcchc88@163.com>
> ---
> 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);
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 1.8.3.1
  
Huichao Cai Oct. 13, 2021, 6:53 a.m. UTC | #2
Hi,Konstantin


I'm glad to receive your ack!


Follow the documentation 《Contributing Code to DPDK》:
1.Update Patchwork to mark your previous patches as “Superseded”.
--Who is responsible for this update, I just tried, prompt no permission update(
You don't have permissions to edit patch 'ip_frag: modify the fragment offset and mf').


2.Note: When acking patches please remove as much of the text of the patch email as possible. 
It is generally best to delete everything after the Signed-off-by: line.
--Does this require me to send another patch email?And the content is like this:


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 <chcchc88@163.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
v2:(delete)
* Reword commit message.(delete)


 lib/ip_frag/rte_ipv4_fragmentation.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)


Best regards.
Kevin
  
Ananyev, Konstantin Oct. 13, 2021, 9:12 a.m. UTC | #3
Hi Kevin,

AFAIK, no other action from your side is needed at the moment.
Now it is up to other reviewers (if any) to have a look,
and then DPDK maintainers to bring your patch in.
If they will have more comments/questions about the patch -
they will email you.
Meanwhile, as I said before, it would be really good to add a new
test-case to cover that case. It could be a new separate patch on top
of current one.

Konstantin

From: 蔡慧超 <chcchc88@163.com>
Sent: Wednesday, October 13, 2021 7:53 AM
To: Ananyev, Konstantin <konstantin.ananyev@intel.com>
Cc: dev@dpdk.org; stable@dpdk.org
Subject: Re:RE: [PATCH v2] ip_frag: fix fragmenting IPv4 fragment

Hi,Konstantin

I'm glad to receive your ack!

Follow the documentation 《Contributing Code to DPDK》:
1.Update Patchwork to mark your previous patches as “Superseded”.
--Who is responsible for this update, I just tried, prompt no permission update(
You don't have permissions to edit patch 'ip_frag: modify the fragment offset and mf').

2.Note: When acking patches please remove as much of the text of the patch email as possible.
It is generally best to delete everything after the Signed-off-by: line.
--Does this require me to send another patch email?And the content is like this:

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<mailto:stable@dpdk.org>

Signed-off-by: huichao cai <chcchc88@163.com<mailto:chcchc88@163.com>>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com<mailto:konstantin.ananyev@intel.com>>
---
v2:(delete)
* Reword commit message.(delete)

 lib/ip_frag/rte_ipv4_fragmentation.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Best regards.
Kevin
  
Huichao Cai Oct. 13, 2021, 9:50 a.m. UTC | #4
Hi,Konstantin


Meanwhile, as I said before, it would be really good to add a new

test-case to cover that case. It could be a new separate patch on top

of current one.
--Ok,I will.


Kevin
  
Thomas Monjalon Oct. 13, 2021, 9:11 p.m. UTC | #5
09/10/2021 09:27, huichao cai:
> 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 <chcchc88@163.com>

We use to capitalize name with family name at last.
Is it OK to assume this format for your name?
	Huichao Cai

I see that Konstantin is saying Kevin, is it your alias?

Thanks and welcome in DPDK community.
  
Huichao Cai Oct. 14, 2021, 3:30 a.m. UTC | #6
Hi,Monjalon
We use to capitalize name with family name at last.
Is it OK to assume this format for your name?
	Huichao Cai
--Yes,this is my real name.I'll change my name to "Huichao Cai".
--Thank you for your reminder.

I see that Konstantin is saying Kevin, is it your alias?

--Yes,this is my alias(my English name).
--The name comes from the company's previous foreign business.
--Just for the convenience of communication.
--If this causes ambiguity, I will only use my real name anywhere.
Best regards.
Huichao Cai
  
Thomas Monjalon Oct. 14, 2021, 6:51 a.m. UTC | #7
> > 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 <chcchc88@163.com>
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks.
  

Patch

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);