[v2] net: fix GTP packet parsing

Message ID 20250417123739.2291519-1-huangdengdui@huawei.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [v2] net: fix GTP packet parsing |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Dengdui Huang April 17, 2025, 12:37 p.m. UTC
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(-)
  

Comments

Dengdui Huang May 6, 2025, 6:02 a.m. UTC | #1
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;
>  		}
  

Patch

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