[v5] gro: bug fix in identifying fragmented packets

Message ID 20220627103114.94924-1-kumaraparmesh92@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v5] gro: bug fix in identifying fragmented packets |

Checks

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

Commit Message

Kumara Parameshwaran June 27, 2022, 10:31 a.m. UTC
  From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>

A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP
(0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in
rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the
GRO layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for
RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the
ip header should be parsed to recognize the appropriate IP type and
invoke the respective gro handler.

Fixes: 1ca5e6740852 ("gro: support UDP/IPv4")
Cc: stable@dpdk.org
Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
---
v1:
* Introduce IS_IPV4_FRAGMENT macro to check if fragmented packet and
  if true extract the IP header to identify the protocol type and
  invoke the appropriate gro handler. This is done for both
  rte_gro_reassemble and rte_gro_reassemble_burst APIs.
v2,v3,v4:
* Fix extra whitespace and column limit warnings
v5
* Use RTE_PTYPE_L4_FRAG to identify the fragmented packets in 
  IS_IPV4_TCP_PKT and IS_IPV4_VXLAN_TCP4_PKT

 lib/gro/rte_gro.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Hu, Jiayu June 29, 2022, 6:57 a.m. UTC | #1
Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>

Thanks,
Jiayu

> -----Original Message-----
> From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
> Sent: Monday, June 27, 2022 6:31 PM
> To: Hu, Jiayu <jiayu.hu@intel.com>
> Cc: dev@dpdk.org; Kumara Parameshwaran
> <kumaraparamesh92@gmail.com>; stable@dpdk.org
> Subject: [PATCH v5] gro: bug fix in identifying fragmented packets
> 
> From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
> 
> A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP
> (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in
> rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the
> GRO layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for
> RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip
> header should be parsed to recognize the appropriate IP type and invoke the
> respective gro handler.
> 
> Fixes: 1ca5e6740852 ("gro: support UDP/IPv4")
> Cc: stable@dpdk.org
> Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
> ---
> v1:
> * Introduce IS_IPV4_FRAGMENT macro to check if fragmented packet and
>   if true extract the IP header to identify the protocol type and
>   invoke the appropriate gro handler. This is done for both
>   rte_gro_reassemble and rte_gro_reassemble_burst APIs.
> v2,v3,v4:
> * Fix extra whitespace and column limit warnings
> v5
> * Use RTE_PTYPE_L4_FRAG to identify the fragmented packets in
>   IS_IPV4_TCP_PKT and IS_IPV4_VXLAN_TCP4_PKT
> 
>  lib/gro/rte_gro.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index
> 6f7dd4d709..e35399fd42 100644
> --- a/lib/gro/rte_gro.c
> +++ b/lib/gro/rte_gro.c
> @@ -32,6 +32,7 @@ static gro_tbl_pkt_count_fn
> tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
> 
>  #define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
>  		((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
> +		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) &&
> \
>  		(RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
> 
>  #define IS_IPV4_UDP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \ @@ -
> 40,6 +41,7 @@ static gro_tbl_pkt_count_fn
> tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
> 
>  #define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype)
> && \
>  		((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \
> +		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) &&
> \
>  		((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \
>  		 RTE_PTYPE_TUNNEL_VXLAN) && \
>  		((ptype & RTE_PTYPE_INNER_L4_TCP) == \
> --
> 2.25.1
  
Thomas Monjalon July 5, 2022, 4:30 p.m. UTC | #2
> > From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
> > 
> > A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP
> > (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in
> > rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the
> > GRO layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for
> > RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip
> > header should be parsed to recognize the appropriate IP type and invoke the
> > respective gro handler.
> > 
> > Fixes: 1ca5e6740852 ("gro: support UDP/IPv4")
> > Cc: stable@dpdk.org
> > Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
> 
> Reviewed-by: Jiayu Hu <jiayu.hu@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c
index 6f7dd4d709..e35399fd42 100644
--- a/lib/gro/rte_gro.c
+++ b/lib/gro/rte_gro.c
@@ -32,6 +32,7 @@  static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
 
 #define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
 		((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
+		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
 		(RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
 
 #define IS_IPV4_UDP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
@@ -40,6 +41,7 @@  static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
 
 #define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
 		((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \
+		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
 		((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \
 		 RTE_PTYPE_TUNNEL_VXLAN) && \
 		((ptype & RTE_PTYPE_INNER_L4_TCP) == \