L4 protocol retrieval from L3 header
cover L4 protocol retrieval from L3 header
Mainly processed the IPv6 extension header without offsetting to the start position of the extension header. The parsed inner protocol is incorrect.
Mingjin Ye (2):
app/testpmd: revert L4 protocol retrieval from L3 header app/testpmd: fix the IPv6 extension offset
app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 app/testpmd: revert L4 protocol retrieval from L3 header
This reverts commit 496159613ffc7b6ba592432a1ba4d1a38f6935de.
When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
--- app/test-pmd/csumonly.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
app/test-pmd/csumonly.c +23 -16
@@ -525,8 +525,20 @@ get_tunnel_ol_flags_by_ptype(uint32_t ptype) } } +static void +parse_inner_l4_proto (void *outer_l3_hdr, +struct testpmd_offload_info *info) +{ +struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; +struct rte_ipv6_hdr *ipv6_hdr = outer_l3_hdr; +if (info->ethertype ==_htons (RTE_ETHER_TYPE_IPV4 )) + info->l4_proto = ipv4_hdr->next_proto_id; +else + info->l4_proto = ipv6_hdr->proto; +} +static uint8_t -parse_l4_proto (const struct rte_mbuf *m,uint32_t off,uint32_t ptype,bool parse_inner) +parse_l4_proto (const struct rte_mbuf *m,uint32_t off,uint32_t ptype) {int frag =0 , ret;
@@ -545,19 +557,16 @@ parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype, bool parsif (unlikely (ip6h ==NULL ))return 0 ; -if (!parse_inner && (ptype &RTE_PTYPE_L3_MASK ) !=RTE_PTYPE_L3_IPV6_EXT ) -return ip6h->proto; - -if (parse_inner && (ptype &RTE_PTYPE_INNER_L3_MASK ) !=RTE_PTYPE_INNER_L3_IPV6_EXT ) -return ip6h->proto; +if ((ptype &RTE_PTYPE_INNER_L3_MASK ) == +RTE_PTYPE_INNER_L3_IPV6_EXT ) { + ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag); +if (ret <0 ) +return 0 ; +return ret; + } - off +=sizeof (struct rte_ipv6_hdr ); - ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag); -if (ret <0 ) -return 0 ; -return ret; +return ip6h->proto; } -return 0 ; }
@@ -696,7 +705,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l4_len = hdr_lens.l4_len; info.ethertype =get_ethertype_by_ptype (eth_hdr, ptype &RTE_PTYPE_L3_MASK ); - info.l4_proto =parse_l4_proto (m, info.l2_len, ptype, false); + info.l4_proto =parse_l4_proto (m, info.l2_len, ptype); l3_hdr = (char *)eth_hdr + info.l2_len;/* check if it's a supported tunnel */
@@ -714,11 +723,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) }/* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -uint16_t l3_off = info.outer_l2_len + info.outer_l3_len + info.l2_len; - outer_l3_hdr = l3_hdr; l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; - info.l4_proto =parse_l4_proto (m, l3_off, ptype, true); +parse_inner_l4_proto (l3_hdr, &info); }/* step 2: depending on user command line configuration, * recompute checksum either in software or flag the
Signature · 1 line
2.25.1
Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 header
Hi Mingjin,
Could you please detail the step of testcase? we will try to reproduce it and see how to solve it.
Thanks.
Quoted 9 lines · Mingjin Ye
This reverts commit
496159613ffc7b6ba592432a1ba4d1a38f6935de.When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
Fixes 496159613ffc ("app/testpmd: fix L4 protocol retrieval from L3 header")Signed-off-by Mingjin Ye <[email protected]>
RE: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 header
Hi Chengwen,
Please refer to Bugzilla for more information.
Bugzilla: https://bugs.dpdk.org/show_bug.cgi?id=1813
Thanks~
Quoted 26 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Monday, November 10, 2025 5:56 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: [email protected]; Singh, Aman Deep <[email protected]>
Subject: Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 headerHi Mingjin,
Could you please detail the step of testcase? we will try to reproduce it and see how to solve it.
Thanks.
Quoted 10 lines · Mingjin Ye
This reverts commit
496159613ffc7b6ba592432a1ba4d1a38f6935de.When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
Fixes 496159613ffc ("app/testpmd: fix L4 protocol retrieval from L3header")
Cc: [email protected]Signed-off-by Mingjin Ye <[email protected]>
Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 header
Hi Mingjin,
We have reproduce this bug in our platform, and trying to fix the solution.
Thanks
Quoted 34 lines · MingjinX
Hi Chengwen,
Please refer to Bugzilla for more information.
Bugzilla: https://bugs.dpdk.org/show_bug.cgi?id=1813Thanks~
Quoted 26 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Monday, November 10, 2025 5:56 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: [email protected]; Singh, Aman Deep <[email protected]>
Subject: Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 headerHi Mingjin,
Could you please detail the step of testcase? we will try to reproduce it and see how to solve it.
Thanks.
Quoted 10 lines · Mingjin Ye
This reverts commit
496159613ffc7b6ba592432a1ba4d1a38f6935de.When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
Fixes 496159613ffc ("app/testpmd: fix L4 protocol retrieval from L3header")
Cc: [email protected]Signed-off-by Mingjin Ye <[email protected]>
Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 header
Hi Mingjin,
I send a bugfix patch [1] to this problem, and also cc to you, could you help test it?
[1] https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Thanks
Quoted 42 lines · fengchengwen
Hi Mingjin,
We have reproduce this bug in our platform, and trying to fix the solution.
Thanks
Quoted 34 lines · MingjinX
Hi Chengwen,
Please refer to Bugzilla for more information.
Bugzilla: https://bugs.dpdk.org/show_bug.cgi?id=1813Thanks~
Quoted 26 lines
-----Original Message-----
From: fengchengwen <[email protected]>
Sent: Monday, November 10, 2025 5:56 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Cc: [email protected]; Singh, Aman Deep <[email protected]>
Subject: Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 headerHi Mingjin,
Could you please detail the step of testcase? we will try to reproduce it and see how to solve it.
Thanks.
Quoted 10 lines · Mingjin Ye
This reverts commit
496159613ffc7b6ba592432a1ba4d1a38f6935de.When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
Fixes 496159613ffc ("app/testpmd: fix L4 protocol retrieval from L3header")
Cc: [email protected]Signed-off-by Mingjin Ye <[email protected]>
Re: [PATCH 1/2] app/testpmd: revert L4 protocol retrieval from L3 header
In reply to Mingjin YeQuoted 21 lines · Mingjin Ye
This reverts commit
496159613ffc7b6ba592432a1ba4d1a38f6935de.When the TX IP checksum offload feature is enabled, it may result in internal UDP checksum errors in VXLAN tunnel packets.
Fixes 496159613ffc ("app/testpmd: fix L4 protocol retrieval from L3 header")Signed-off-by Mingjin Ye <[email protected]>--- app/test-pmd/csumonly.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)app/test-pmd/csumonly.c +0
-0@@ -525,8 +525,20 @@ get_tunnel_ol_flags_by_ptype(uint32_t ptype) } }
app/test-pmd/csumonly.c get_tunnel_ol_flags_by_ptype(uint32_t ptype) · line 537
Quoted 10 lines
app/test-pmd/csumonly.c +10
-0+static void +parse_inner_l4_proto (void *outer_l3_hdr, +struct testpmd_offload_info *info) +{ +struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; +struct rte_ipv6_hdr *ipv6_hdr = outer_l3_hdr; +if (info->ethertype ==_htons (RTE_ETHER_TYPE_IPV4 )) + info->l4_proto = ipv4_hdr->next_proto_id; +else + info->l4_proto = ipv6_hdr->proto;
this function get L4 proto direct from header which can't handle inner IPv6 with option.
Quoted 12 lines
app/test-pmd/csumonly.c +3
-1+} +static uint8_t -parse_l4_proto (const struct rte_mbuf *m,uint32_t off,uint32_t ptype,bool parse_inner) +parse_l4_proto (const struct rte_mbuf *m,uint32_t off,uint32_t ptype) {int frag =0 , ret;@@ -545,19 +557,16 @@ parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype, bool parsif (unlikely (ip6h ==NULL ))return 0 ;
app/test-pmd/csumonly.c parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype, bool pars · line 564
Quoted 10 lines
app/test-pmd/csumonly.c +5
-5-if (!parse_inner && (ptype &RTE_PTYPE_L3_MASK ) !=RTE_PTYPE_L3_IPV6_EXT ) -return ip6h->proto; - -if (parse_inner && (ptype &RTE_PTYPE_INNER_L3_MASK ) !=RTE_PTYPE_INNER_L3_IPV6_EXT ) -return ip6h->proto; +if ((ptype &RTE_PTYPE_INNER_L3_MASK ) == +RTE_PTYPE_INNER_L3_IPV6_EXT ) { + ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag); +if (ret <0 ) +return 0 ;
this logic has problem: parse_l4_proto was used to prase outer L4 if in tunnel case, but it depend on whether inner is L3_IPV6_EXT.
Quoted 36 lines
app/test-pmd/csumonly.c +5
-10+return ret; + } - off +=sizeof (struct rte_ipv6_hdr ); - ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag); -if (ret <0 ) -return 0 ; -return ret; +return ip6h->proto; } -return 0 ; }@@ -696,7 +705,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) info.l4_len = hdr_lens.l4_len; info.ethertype =get_ethertype_by_ptype (eth_hdr, ptype &RTE_PTYPE_L3_MASK ); - info.l4_proto =parse_l4_proto (m, info.l2_len, ptype, false); + info.l4_proto =parse_l4_proto (m, info.l2_len, ptype); l3_hdr = (char *)eth_hdr + info.l2_len;/* check if it's a supported tunnel */ @@ -714,11 +723,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) }/* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -uint16_t l3_off = info.outer_l2_len + info.outer_l3_len + info.l2_len; - outer_l3_hdr = l3_hdr; l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; - info.l4_proto =parse_l4_proto (m, l3_off, ptype, true); +parse_inner_l4_proto (l3_hdr, &info); }/* step 2: depending on user command line configuration, * recompute checksum either in software or flag the
PATCH 2/2 app/testpmd: fix the IPv6 extension offset
In reply to Mingjin YeThe skip ipv6 extension must be offset after the IPv6 header.
--- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +1 -0
@@ -559,6 +559,7 @@ parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype)if ((ptype &RTE_PTYPE_INNER_L3_MASK ) ==RTE_PTYPE_INNER_L3_IPV6_EXT ) { + off +=sizeof (struct rte_ipv6_hdr ); ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag);if (ret <0 )return 0 ;
Signature · 1 line
2.25.1
Re: [PATCH 2/2] app/testpmd: fix the IPv6 extension offset
Quoted 15 lines · Mingjin Ye
The skip ipv6 extension must be offset after the IPv6 header.
Fixes 76730c7b9b5a ("app/testpmd: use packet type parsing API")Signed-off-by Mingjin Ye <[email protected]>--- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+)app/test-pmd/csumonly.c +0
-0
app/test-pmd/csumonly.c parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype) · line 563
Quoted 5 lines
app/test-pmd/csumonly.c +1
-0@@ -559,6 +559,7 @@ parse_l4_proto(const struct rte_mbuf *m, uint32_t off, uint32_t ptype)if ((ptype &RTE_PTYPE_INNER_L3_MASK ) ==RTE_PTYPE_INNER_L3_IPV6_EXT ) { + off +=sizeof (struct rte_ipv6_hdr ); ret =rte_net_skip_ip6_ext (ip6h->proto, m, &off, &frag);
As patch [1/2] said, this logic has problem, consider following case:
ether + ipv6-with-option + tcp
and enable TSO offload.
It will not do TSO really, because the ptype is 0x1C1 which the INNER_L3 was not set, then the parse_l4_proc could not identify is ipv6-with-option, it can't identify this packet is TCP, then it will don't do TCP on this packet.
Quoted 2 lines
app/test-pmd/csumonly.c +0
-0if (ret <0 )return 0 ;