DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net: fix GTP packet parsing
@ 2025-04-11  8:43 Dengdui Huang
  2025-04-11  9:54 ` Jie Hai
  2025-04-17 12:37 ` [PATCH v2] " Dengdui Huang
  0 siblings, 2 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-04-11  8:43 UTC (permalink / raw)
  To: dev
  Cc: jasvinder.singh, stephen, thomas, mb, lihuisong, fengchengwen,
	haijie1, liuyonglong

After parsing the GTP packet header, the next protocol type should
be converted from RTE_GTP_TYPE_IPV4/IPV6 to RTE_ETHER_TYPE_IPV4/IPV6.
Otherwise, the next protocol cannot be parsed.

Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 lib/net/rte_net.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index be24690fdf..1771588a09 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -231,7 +231,13 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		 */
 		if (gh->msg_type == 0xff) {
 			ip_ver = *(const uint8_t *)((const char *)gh + gtp_len);
-			*proto = (ip_ver) & 0xf0;
+			ip_ver = (ip_ver) & 0xf0;
+			if (ip_ver == RTE_GTP_TYPE_IPV4)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+			else if (ip_ver == RTE_GTP_TYPE_IPV6)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
+			else
+				*proto = 0;
 		} else {
 			*proto = 0;
 		}
-- 
2.33.0


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

* Re: [PATCH] net: fix GTP packet parsing
  2025-04-11  8:43 [PATCH] net: fix GTP packet parsing Dengdui Huang
@ 2025-04-11  9:54 ` Jie Hai
  2025-04-17 12:37 ` [PATCH v2] " Dengdui Huang
  1 sibling, 0 replies; 9+ messages in thread
From: Jie Hai @ 2025-04-11  9:54 UTC (permalink / raw)
  To: Dengdui Huang, dev
  Cc: jasvinder.singh, stephen, thomas, mb, lihuisong, fengchengwen,
	liuyonglong

Good job!

Acked-by: Jie Hai <haijie1@huawei.com>

On 2025/4/11 16:43, Dengdui Huang wrote:
> After parsing the GTP packet header, the next protocol type should
> be converted from RTE_GTP_TYPE_IPV4/IPV6 to RTE_ETHER_TYPE_IPV4/IPV6.
> Otherwise, the next protocol cannot be parsed.
> 
> Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> ---
>   lib/net/rte_net.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
> index be24690fdf..1771588a09 100644
> --- a/lib/net/rte_net.c
> +++ b/lib/net/rte_net.c
> @@ -231,7 +231,13 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
>   		 */
>   		if (gh->msg_type == 0xff) {
>   			ip_ver = *(const uint8_t *)((const char *)gh + gtp_len);
> -			*proto = (ip_ver) & 0xf0;
> +			ip_ver = (ip_ver) & 0xf0;
> +			if (ip_ver == RTE_GTP_TYPE_IPV4)
> +				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
> +			else if (ip_ver == RTE_GTP_TYPE_IPV6)
> +				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
> +			else
> +				*proto = 0;
>   		} else {
>   			*proto = 0;
>   		}

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

* [PATCH v2] net: fix GTP packet parsing
  2025-04-11  8:43 [PATCH] net: fix GTP packet parsing Dengdui Huang
  2025-04-11  9:54 ` Jie Hai
@ 2025-04-17 12:37 ` Dengdui Huang
  2025-05-06  6:02   ` huangdengdui
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
  1 sibling, 2 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-04-17 12:37 UTC (permalink / raw)
  To: dev; +Cc: jasvinder.singh, thomas, mb, lihuisong, fengchengwen, liuyonglong

After parsing the GTP packet header, the next protocol type should
be converted from RTE_GTP_TYPE_IPV4/IPV6 to RTE_ETHER_TYPE_IPV4/IPV6.
Otherwise, the next protocol cannot be parsed.

Bugzilla ID: 1672
Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Jie Hai <haijie1@huawei.com>
---
 lib/net/rte_net.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index be24690fdf..1771588a09 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -231,7 +231,13 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		 */
 		if (gh->msg_type == 0xff) {
 			ip_ver = *(const uint8_t *)((const char *)gh + gtp_len);
-			*proto = (ip_ver) & 0xf0;
+			ip_ver = (ip_ver) & 0xf0;
+			if (ip_ver == RTE_GTP_TYPE_IPV4)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+			else if (ip_ver == RTE_GTP_TYPE_IPV6)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
+			else
+				*proto = 0;
 		} else {
 			*proto = 0;
 		}
-- 
2.33.0


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

* Re: [PATCH v2] net: fix GTP packet parsing
  2025-04-17 12:37 ` [PATCH v2] " Dengdui Huang
@ 2025-05-06  6:02   ` huangdengdui
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
  1 sibling, 0 replies; 9+ messages in thread
From: huangdengdui @ 2025-05-06  6:02 UTC (permalink / raw)
  To: dev, songx.jiale
  Cc: jasvinder.singh, thomas, mb, lihuisong, fengchengwen, liuyonglong

Hi, Jiale, this patch can solve the issues[1] you reported. Can you review this patch and add a Tested-by tag?

[1]
https://bugs.dpdk.org/show_bug.cgi?id=1672

On 2025/4/17 20:37, Dengdui Huang wrote:
> After parsing the GTP packet header, the next protocol type should
> be converted from RTE_GTP_TYPE_IPV4/IPV6 to RTE_ETHER_TYPE_IPV4/IPV6.
> Otherwise, the next protocol cannot be parsed.
> 
> Bugzilla ID: 1672
> Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> Acked-by: Jie Hai <haijie1@huawei.com>
> ---
>  lib/net/rte_net.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
> index be24690fdf..1771588a09 100644
> --- a/lib/net/rte_net.c
> +++ b/lib/net/rte_net.c
> @@ -231,7 +231,13 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
>  		 */
>  		if (gh->msg_type == 0xff) {
>  			ip_ver = *(const uint8_t *)((const char *)gh + gtp_len);
> -			*proto = (ip_ver) & 0xf0;
> +			ip_ver = (ip_ver) & 0xf0;
> +			if (ip_ver == RTE_GTP_TYPE_IPV4)
> +				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
> +			else if (ip_ver == RTE_GTP_TYPE_IPV6)
> +				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
> +			else
> +				*proto = 0;
>  		} else {
>  			*proto = 0;
>  		}

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

* [PATCH v3 0/4] bugfix about parse tunnel packet with UDP
  2025-04-17 12:37 ` [PATCH v2] " Dengdui Huang
  2025-05-06  6:02   ` huangdengdui
@ 2025-05-16  9:28   ` Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 1/4] net: fix GTP packet parsing Dengdui Huang
                       ` (3 more replies)
  1 sibling, 4 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-05-16  9:28 UTC (permalink / raw)
  To: dev
  Cc: stephen, jasvinder.singh, thomas, aman.deep.singh, lihuisong,
	fengchengwen

Currently, there are some issues with testpmd and get ptype API in parsing tunnel packets,
and this patchset is fix it.

Dengdui Huang (4):
  net: fix GTP packet parsing
  net: fix parse the tunnel length of tunnel packet with UDP
  net: fix GENEVE packet parsing
  app/testpmd: fix obtain inner info of tunnel packet

 app/test-pmd/csumonly.c |  6 +++---
 lib/net/rte_net.c       | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

-- 
2.33.0


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

* [PATCH v3 1/4] net: fix GTP packet parsing
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
@ 2025-05-16  9:28     ` Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 2/4] net: fix parse the tunnel length of tunnel packet with UDP Dengdui Huang
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-05-16  9:28 UTC (permalink / raw)
  To: dev
  Cc: stephen, jasvinder.singh, thomas, aman.deep.singh, lihuisong,
	fengchengwen

After parsing the GTP packet header, the next protocol type should
be converted from RTE_GTP_TYPE_IPV4/IPV6 to RTE_ETHER_TYPE_IPV4/IPV6.
Otherwise, the next protocol cannot be parsed.

Bugzilla ID: 1672
Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Jie Hai <haijie1@huawei.com>
---
 lib/net/rte_net.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index be24690fdf..1771588a09 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -231,7 +231,13 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		 */
 		if (gh->msg_type == 0xff) {
 			ip_ver = *(const uint8_t *)((const char *)gh + gtp_len);
-			*proto = (ip_ver) & 0xf0;
+			ip_ver = (ip_ver) & 0xf0;
+			if (ip_ver == RTE_GTP_TYPE_IPV4)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+			else if (ip_ver == RTE_GTP_TYPE_IPV6)
+				*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
+			else
+				*proto = 0;
 		} else {
 			*proto = 0;
 		}
-- 
2.33.0


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

* [PATCH v3 2/4] net: fix parse the tunnel length of tunnel packet with UDP
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 1/4] net: fix GTP packet parsing Dengdui Huang
@ 2025-05-16  9:28     ` Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 3/4] net: fix GENEVE packet parsing Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 4/4] app/testpmd: fix obtain inner info of tunnel packet Dengdui Huang
  3 siblings, 0 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-05-16  9:28 UTC (permalink / raw)
  To: dev
  Cc: stephen, jasvinder.singh, thomas, aman.deep.singh, lihuisong,
	fengchengwen

Currently, the tunnel length info is not available when
get the tunnel packet type with UDP port. This patch
adds the parsing of the tunnel length info.

Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 lib/net/rte_net.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 1771588a09..67d57d5f04 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -197,6 +197,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 	switch (port_no) {
 	case RTE_VXLAN_DEFAULT_PORT: {
 		*off += sizeof(struct rte_vxlan_hdr);
+		hdr_lens->tunnel_len = sizeof(struct rte_vxlan_hdr);
 		hdr_lens->inner_l2_len = RTE_ETHER_VXLAN_HLEN;
 		*proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
 		return RTE_PTYPE_TUNNEL_VXLAN;
@@ -208,6 +209,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		if (unlikely(vgh == NULL))
 			return 0;
 		*off += sizeof(struct rte_vxlan_gpe_hdr);
+		hdr_lens->tunnel_len = sizeof(struct rte_vxlan_gpe_hdr);
 		hdr_lens->inner_l2_len = RTE_ETHER_VXLAN_GPE_HLEN;
 		*proto = vgh->proto;
 
@@ -243,6 +245,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		}
 		*off += gtp_len;
 		hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
+		hdr_lens->tunnel_len = gtp_len;
 		if (port_no == RTE_GTPC_UDP_PORT)
 			return RTE_PTYPE_TUNNEL_GTPC;
 		else if (port_no == RTE_GTPU_UDP_PORT)
@@ -258,6 +261,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 			return 0;
 		geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
 		*off = geneve_len;
+		hdr_lens->tunnel_len = geneve_len;
 		*proto = gnh->proto;
 		if (gnh->proto == 0)
 			*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
-- 
2.33.0


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

* [PATCH v3 3/4] net: fix GENEVE packet parsing
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 1/4] net: fix GTP packet parsing Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 2/4] net: fix parse the tunnel length of tunnel packet with UDP Dengdui Huang
@ 2025-05-16  9:28     ` Dengdui Huang
  2025-05-16  9:28     ` [PATCH v3 4/4] app/testpmd: fix obtain inner info of tunnel packet Dengdui Huang
  3 siblings, 0 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-05-16  9:28 UTC (permalink / raw)
  To: dev
  Cc: stephen, jasvinder.singh, thomas, aman.deep.singh, lihuisong,
	fengchengwen

When the GENEVE packet is processed, the offset is
not changed correctly. As a result, the inner packet
is incorrectly parsed. This patch fixes it.

Fixes: 64ed7f854cf4 ("net: add tunnel packet type parsing")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 lib/net/rte_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 67d57d5f04..cd8cc0d0c8 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -260,7 +260,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
 		if (unlikely(gnh == NULL))
 			return 0;
 		geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
-		*off = geneve_len;
+		*off += geneve_len;
 		hdr_lens->tunnel_len = geneve_len;
 		*proto = gnh->proto;
 		if (gnh->proto == 0)
-- 
2.33.0


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

* [PATCH v3 4/4] app/testpmd: fix obtain inner info of tunnel packet
  2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
                       ` (2 preceding siblings ...)
  2025-05-16  9:28     ` [PATCH v3 3/4] net: fix GENEVE packet parsing Dengdui Huang
@ 2025-05-16  9:28     ` Dengdui Huang
  3 siblings, 0 replies; 9+ messages in thread
From: Dengdui Huang @ 2025-05-16  9:28 UTC (permalink / raw)
  To: dev
  Cc: stephen, jasvinder.singh, thomas, aman.deep.singh, lihuisong,
	fengchengwen

l2_len for tunneling packets should contain Outer_L4_len.
Additionally, the current offset used for the inner Ethernet
header is incorrect. This patch fixes these issues.

Fixes: 76730c7b9b5a ("app/testpmd: use packet type parsing API")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 app/test-pmd/csumonly.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fa0002d321..6d93b7a04d 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -711,11 +711,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 		if (txp->parse_tunnel && RTE_ETH_IS_TUNNEL_PKT(ptype) != 0) {
 			info.is_tunnel = 1;
 			update_tunnel_outer(&info);
-			info.l2_len = hdr_lens.inner_l2_len + hdr_lens.tunnel_len;
+			info.l2_len = hdr_lens.inner_l2_len + hdr_lens.tunnel_len + hdr_lens.l4_len;
 			info.l3_len = hdr_lens.inner_l3_len;
 			info.l4_len = hdr_lens.inner_l4_len;
-			eth_hdr = (struct rte_ether_hdr *)(char *)l3_hdr +
-					info.outer_l3_len + hdr_lens.tunnel_len;
+			eth_hdr = (struct rte_ether_hdr *)((char *)l3_hdr +
+				hdr_lens.l3_len + hdr_lens.l4_len + hdr_lens.tunnel_len);
 			info.ethertype = get_ethertype_by_ptype(eth_hdr,
 						ptype & RTE_PTYPE_INNER_L3_MASK);
 			tx_ol_flags |= get_tunnel_ol_flags_by_ptype(ptype);
-- 
2.33.0


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

end of thread, other threads:[~2025-05-16  9:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-11  8:43 [PATCH] net: fix GTP packet parsing Dengdui Huang
2025-04-11  9:54 ` Jie Hai
2025-04-17 12:37 ` [PATCH v2] " Dengdui Huang
2025-05-06  6:02   ` huangdengdui
2025-05-16  9:28   ` [PATCH v3 0/4] bugfix about parse tunnel packet with UDP Dengdui Huang
2025-05-16  9:28     ` [PATCH v3 1/4] net: fix GTP packet parsing Dengdui Huang
2025-05-16  9:28     ` [PATCH v3 2/4] net: fix parse the tunnel length of tunnel packet with UDP Dengdui Huang
2025-05-16  9:28     ` [PATCH v3 3/4] net: fix GENEVE packet parsing Dengdui Huang
2025-05-16  9:28     ` [PATCH v3 4/4] app/testpmd: fix obtain inner info of tunnel packet Dengdui Huang

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