* [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
@ 2025-07-28 13:12 Khadem Ullah
2025-07-28 13:28 ` Ivan Malov
2025-07-31 10:21 ` Andrew Rybchenko
0 siblings, 2 replies; 9+ messages in thread
From: Khadem Ullah @ 2025-07-28 13:12 UTC (permalink / raw)
To: dev, jasvinder.singh, bruce.richardson
Cc: thomas, andrew.rybchenko, stable, Khadem Ullah
Fix incorrect inner_l2_len values for VXLAN, VXLAN-GPE, GTPU, and Geneve.
These protocols carry full Ethernet frames, so inner_l2_len should be
set to the size of an Ethernet header (14 bytes), not include tunnel or
UDP headers.
Fixes: 64ed7f854c ('net: add tunnel packet type parsing')
Cc: stable@dpdk.org
Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
---
lib/net/rte_net.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 44fb6c0f51..adcddeb670 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -198,7 +198,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
return RTE_PTYPE_TUNNEL_VXLAN;
}
@@ -210,7 +210,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = vgh->proto;
return RTE_PTYPE_TUNNEL_VXLAN_GPE;
@@ -244,7 +244,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
*proto = 0;
}
*off += gtp_len;
- hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
hdr_lens->tunnel_len = gtp_len;
if (port_no == RTE_GTPC_UDP_PORT)
return RTE_PTYPE_TUNNEL_GTPC;
@@ -262,7 +262,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
*off += geneve_len;
hdr_lens->tunnel_len = geneve_len;
- hdr_lens->inner_l2_len = sizeof(struct rte_udp_hdr) + geneve_len;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = gnh->proto;
if (gnh->proto == 0)
*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
@@ -498,7 +498,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
pkt_type |= RTE_PTYPE_INNER_L2_ETHER;
proto = eh->ether_type;
off += sizeof(*eh);
- hdr_lens->inner_l2_len += sizeof(*eh);
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
}
if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
@@ -511,7 +511,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
if (unlikely(vh == NULL))
return pkt_type;
off += sizeof(*vh);
- hdr_lens->inner_l2_len += sizeof(*vh);
+ hdr_lens->inner_l2_len += sizeof(struct rte_vlan_hdr);
proto = vh->eth_proto;
} else if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
const struct rte_vlan_hdr *vh;
@@ -524,7 +524,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
if (unlikely(vh == NULL))
return pkt_type;
off += 2 * sizeof(*vh);
- hdr_lens->inner_l2_len += 2 * sizeof(*vh);
+ hdr_lens->inner_l2_len += 2 * sizeof(struct rte_vlan_hdr);
proto = vh->eth_proto;
}
--
2.47.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-07-28 13:12 [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets Khadem Ullah
@ 2025-07-28 13:28 ` Ivan Malov
2025-07-29 5:06 ` Khadem Ullah
2025-07-31 10:21 ` Andrew Rybchenko
1 sibling, 1 reply; 9+ messages in thread
From: Ivan Malov @ 2025-07-28 13:28 UTC (permalink / raw)
To: Khadem Ullah
Cc: dev, jasvinder.singh, bruce.richardson, thomas, andrew.rybchenko, stable
Hi,
On Mon, 28 Jul 2025, Khadem Ullah wrote:
> Fix incorrect inner_l2_len values for VXLAN, VXLAN-GPE, GTPU, and Geneve.
> These protocols carry full Ethernet frames, so inner_l2_len should be
> set to the size of an Ethernet header (14 bytes), not include tunnel or
> UDP headers.
Does the bug break 'testpmd' (see 'inner_l2_len' over there) or what? How can
this be reproduced?
Also, how well does the patch agree with what is currently said in 'rte_net.h'?
> /* Outer_L4_len + ... + inner L2_len for tunneling pkt. */
> uint8_t inner_l2_len;
Is the comment also wrong or do we have a fundamental confusion in DPDK?
I know, for example, that in mbufs, in the case of a tunneled (VXLAN) packet,
fields 'outer_l2_len' and 'outer_l3_len' are Ethernet and IP sizes respectively,
whilst 'l2_len' is a sum of the UDP size, VXLAN size and inner Ethernet header.
But that's in mbuf, which does not have a separate 'tunnel_len' field.
So either there's some confusion, or the patch also needs to fix other places,
such as the header file mentioned ('rte_net.h').
Thank you.
>
> Fixes: 64ed7f854c ('net: add tunnel packet type parsing')
> Cc: stable@dpdk.org
>
> Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
> ---
> lib/net/rte_net.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
> index 44fb6c0f51..adcddeb670 100644
> --- a/lib/net/rte_net.c
> +++ b/lib/net/rte_net.c
> @@ -198,7 +198,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> 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;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
> return RTE_PTYPE_TUNNEL_VXLAN;
> }
> @@ -210,7 +210,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> 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;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = vgh->proto;
>
> return RTE_PTYPE_TUNNEL_VXLAN_GPE;
> @@ -244,7 +244,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> *proto = 0;
> }
> *off += gtp_len;
> - hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> hdr_lens->tunnel_len = gtp_len;
> if (port_no == RTE_GTPC_UDP_PORT)
> return RTE_PTYPE_TUNNEL_GTPC;
> @@ -262,7 +262,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
> *off += geneve_len;
> hdr_lens->tunnel_len = geneve_len;
> - hdr_lens->inner_l2_len = sizeof(struct rte_udp_hdr) + geneve_len;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = gnh->proto;
> if (gnh->proto == 0)
> *proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
> @@ -498,7 +498,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> pkt_type |= RTE_PTYPE_INNER_L2_ETHER;
> proto = eh->ether_type;
> off += sizeof(*eh);
> - hdr_lens->inner_l2_len += sizeof(*eh);
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> }
>
> if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
> @@ -511,7 +511,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> if (unlikely(vh == NULL))
> return pkt_type;
> off += sizeof(*vh);
> - hdr_lens->inner_l2_len += sizeof(*vh);
> + hdr_lens->inner_l2_len += sizeof(struct rte_vlan_hdr);
> proto = vh->eth_proto;
> } else if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
> const struct rte_vlan_hdr *vh;
> @@ -524,7 +524,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> if (unlikely(vh == NULL))
> return pkt_type;
> off += 2 * sizeof(*vh);
> - hdr_lens->inner_l2_len += 2 * sizeof(*vh);
> + hdr_lens->inner_l2_len += 2 * sizeof(struct rte_vlan_hdr);
> proto = vh->eth_proto;
> }
>
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-07-28 13:28 ` Ivan Malov
@ 2025-07-29 5:06 ` Khadem Ullah
2025-07-31 10:26 ` Andrew Rybchenko
0 siblings, 1 reply; 9+ messages in thread
From: Khadem Ullah @ 2025-07-29 5:06 UTC (permalink / raw)
To: dev, ivan.malov, jasvinder.singh, bruce.richardson
Cc: thomas, andrew.rybchenko, stable
Hi Ivan,
No, it does not breaking testpmd or any other applications.
Yes, the structure is correct in rte_net.h and comment as well.
You can run testpmd in rxonly mode and set verbose to 3, send the following packet from remote and you will observe the output as given below:
pkt=Ether(src="04:3f:72:f3:7a:43",dst="C8:0A:A9:04:49:1A")/IP(src="19.168.1.1",dst="19.168.1.1")/UDP(dport=4789)/VXLAN(vni=4094)/Ether(dst="22:11:11:11:11:10")/IP(dst="19.168.1.1")/UDP()
port 0/queue 0: received 1 packets
src=04:3F:72:F3:7A:43 - dst=C8:0A:A9:04:49:1A - pool=mb_pool_0 - type=0x0800 - length=92 - nb_segs=1 - hw ptype: L2_ETHER L3_IPV4_EXT_UNKNOWN L4_UDP - sw ptype: L2_ETHER L3_IPV4 L4_UDP TUNNEL_VXLAN INNER_L2_ETHER INNER_L3_IPV4 INNER_L4_UDP - l2_len=14 - l3_len=20 - l4_len=8 - tunnel_len=8 - inner_l2_len=30 - inner_l3_len=20 - inner_l4_len=8 - Destination UDP port=4789 - Receive queue=0x0
ol_flags: RTE_MBUF_F_RX_L4_CKSUM_GOOD RTE_MBUF_F_RX_IP_CKSUM_GOOD RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN
The length is 92 bytes which is correct but inner_l2_len=30 which is incorrect. According to standard, the following calculation is true of VXLAN header (50 bytes) and VXLAN packet size(92 bytes).
50-byte VXLAN header =(14-byte outer ethernet header + 20-byte outer IP header + 8-byte outer UDP header + 8-byte VXLAN header )
92-bytes VXLAN packet size= (14-byte outer Ethernet header + 20-byte outer IP header + 8-byte outer UDP header + 8-byte VXLAN header )+ (14-byte inner Ethernet header + 20-byte inner IP header + 8-byte inner UDP)
This patch correct the inner_l2_len which is 14 bytes.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-07-28 13:12 [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets Khadem Ullah
2025-07-28 13:28 ` Ivan Malov
@ 2025-07-31 10:21 ` Andrew Rybchenko
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Rybchenko @ 2025-07-31 10:21 UTC (permalink / raw)
To: Khadem Ullah, dev, jasvinder.singh, bruce.richardson; +Cc: thomas, stable
On 7/28/25 16:12, Khadem Ullah wrote:
> Fix incorrect inner_l2_len values for VXLAN, VXLAN-GPE, GTPU, and Geneve.
> These protocols carry full Ethernet frames, so inner_l2_len should be
> set to the size of an Ethernet header (14 bytes), not include tunnel or
> UDP headers.
Please, take a look at the definition of the inner_l2_len in rte_net.h.
NACK
>
> Fixes: 64ed7f854c ('net: add tunnel packet type parsing')
> Cc: stable@dpdk.org
>
> Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
> ---
> lib/net/rte_net.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
> index 44fb6c0f51..adcddeb670 100644
> --- a/lib/net/rte_net.c
> +++ b/lib/net/rte_net.c
> @@ -198,7 +198,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> 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;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
> return RTE_PTYPE_TUNNEL_VXLAN;
> }
> @@ -210,7 +210,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> 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;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = vgh->proto;
>
> return RTE_PTYPE_TUNNEL_VXLAN_GPE;
> @@ -244,7 +244,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> *proto = 0;
> }
> *off += gtp_len;
> - hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> hdr_lens->tunnel_len = gtp_len;
> if (port_no == RTE_GTPC_UDP_PORT)
> return RTE_PTYPE_TUNNEL_GTPC;
> @@ -262,7 +262,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
> geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
> *off += geneve_len;
> hdr_lens->tunnel_len = geneve_len;
> - hdr_lens->inner_l2_len = sizeof(struct rte_udp_hdr) + geneve_len;
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> *proto = gnh->proto;
> if (gnh->proto == 0)
> *proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
> @@ -498,7 +498,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> pkt_type |= RTE_PTYPE_INNER_L2_ETHER;
> proto = eh->ether_type;
> off += sizeof(*eh);
> - hdr_lens->inner_l2_len += sizeof(*eh);
> + hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
> }
>
> if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
> @@ -511,7 +511,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> if (unlikely(vh == NULL))
> return pkt_type;
> off += sizeof(*vh);
> - hdr_lens->inner_l2_len += sizeof(*vh);
> + hdr_lens->inner_l2_len += sizeof(struct rte_vlan_hdr);
> proto = vh->eth_proto;
> } else if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
> const struct rte_vlan_hdr *vh;
> @@ -524,7 +524,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> if (unlikely(vh == NULL))
> return pkt_type;
> off += 2 * sizeof(*vh);
> - hdr_lens->inner_l2_len += 2 * sizeof(*vh);
> + hdr_lens->inner_l2_len += 2 * sizeof(struct rte_vlan_hdr);
> proto = vh->eth_proto;
> }
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-07-29 5:06 ` Khadem Ullah
@ 2025-07-31 10:26 ` Andrew Rybchenko
2025-08-01 11:28 ` Khadem Ullah
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Rybchenko @ 2025-07-31 10:26 UTC (permalink / raw)
To: Khadem Ullah, dev, ivan.malov, jasvinder.singh, bruce.richardson
Cc: thomas, stable
On 7/29/25 08:06, Khadem Ullah wrote:
> Hi Ivan,
>
> No, it does not breaking testpmd or any other applications.
> Yes, the structure is correct in rte_net.h and comment as well.
>
> You can run testpmd in rxonly mode and set verbose to 3, send the following packet from remote and you will observe the output as given below:
>
> pkt=Ether(src="04:3f:72:f3:7a:43",dst="C8:0A:A9:04:49:1A")/IP(src="19.168.1.1",dst="19.168.1.1")/UDP(dport=4789)/VXLAN(vni=4094)/Ether(dst="22:11:11:11:11:10")/IP(dst="19.168.1.1")/UDP()
>
>
> port 0/queue 0: received 1 packets
> src=04:3F:72:F3:7A:43 - dst=C8:0A:A9:04:49:1A - pool=mb_pool_0 - type=0x0800 - length=92 - nb_segs=1 - hw ptype: L2_ETHER L3_IPV4_EXT_UNKNOWN L4_UDP - sw ptype: L2_ETHER L3_IPV4 L4_UDP TUNNEL_VXLAN INNER_L2_ETHER INNER_L3_IPV4 INNER_L4_UDP - l2_len=14 - l3_len=20 - l4_len=8 - tunnel_len=8 - inner_l2_len=30 - inner_l3_len=20 - inner_l4_len=8 - Destination UDP port=4789 - Receive queue=0x0
> ol_flags: RTE_MBUF_F_RX_L4_CKSUM_GOOD RTE_MBUF_F_RX_IP_CKSUM_GOOD RTE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN
>
> The length is 92 bytes which is correct but inner_l2_len=30 which is incorrect. According to standard, the following calculation is true of VXLAN header (50 bytes) and VXLAN packet size(92 bytes).
>
> 50-byte VXLAN header =(14-byte outer ethernet header + 20-byte outer IP header + 8-byte outer UDP header + 8-byte VXLAN header )
>
> 92-bytes VXLAN packet size= (14-byte outer Ethernet header + 20-byte outer IP header + 8-byte outer UDP header + 8-byte VXLAN header )+ (14-byte inner Ethernet header + 20-byte inner IP header + 8-byte inner UDP)
>
> This patch correct the inner_l2_len which is 14 bytes.
No, you're incorrectly assume that sum of all *_len fields should give
you a length of all packet headers. It is wrong assumption in accordance
with the definition of inner_l2_len which includes outer-l4-len (UDP),
tunnel header (VXLAN) and inner Ethernet header for the packet.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-07-31 10:26 ` Andrew Rybchenko
@ 2025-08-01 11:28 ` Khadem Ullah
2025-08-01 13:23 ` Ivan Malov
0 siblings, 1 reply; 9+ messages in thread
From: Khadem Ullah @ 2025-08-01 11:28 UTC (permalink / raw)
To: dev, andrew.rybchenko, jasvinder.singh, bruce.richardson
Cc: thomas, ivan.malov, stable
Hi Andrew,
Thanks for your feedback.
Please check mbuf packet types and the following test case:
https://doc.dpdk.org/dts-20.02/test_plans/uni_pkt_test_plan.html#test-case-vxlan-tunnel-packet-type-detect
sendp([Ether()/IP()/UDP()/Vxlan()/Ether()/IP(frag=5)/Raw('\0'*40)],
iface=txItf)
(outer) L2 type: ETHER
(outer) L3 type: IPV4_EXT_UNKNOWN
(outer) L4 type: Unknown
Tunnel type: GRENAT
Inner L2 type: ETHER
Inner L3 type: IPV4_EXT_UNKNOWN
Inner L4 type: L4_FRAG
union {
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
__extension__
struct {
uint8_t l2_type:4; /**< (Outer) L2 type. */
uint8_t l3_type:4; /**< (Outer) L3 type. */
uint8_t l4_type:4; /**< (Outer) L4 type. */
uint8_t tun_type:4; /**< Tunnel type. */
union {
uint8_t inner_esp_next_proto;
/**< ESP next protocol type, valid if
* RTE_PTYPE_TUNNEL_ESP tunnel type is set
* on both Tx and Rx.
*/
__extension__
struct {
uint8_t inner_l2_type:4;
/**< Inner L2 type. */
uint8_t inner_l3_type:4;
/**< Inner L3 type. */
};
};
uint8_t inner_l4_type:4; /**< Inner L4 type. */
};
};
Based on the above, it seems that inner_l2_len have to the length of Ether.
Ther might need to be some correspondent between both fields to potray the same information.
Or, the inner_l2_type and inner_l2_len are completly different ?
Best Regards,
Khadem
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
2025-08-01 11:28 ` Khadem Ullah
@ 2025-08-01 13:23 ` Ivan Malov
0 siblings, 0 replies; 9+ messages in thread
From: Ivan Malov @ 2025-08-01 13:23 UTC (permalink / raw)
To: Khadem Ullah
Cc: dev, andrew.rybchenko, jasvinder.singh, bruce.richardson, thomas, stable
Hi,
On Fri, 1 Aug 2025, Khadem Ullah wrote:
> Hi Andrew,
>
> Thanks for your feedback.
>
> Please check mbuf packet types and the following test case:
> https://doc.dpdk.org/dts-20.02/test_plans/uni_pkt_test_plan.html#test-case-vxlan-tunnel-packet-type-detect
> sendp([Ether()/IP()/UDP()/Vxlan()/Ether()/IP(frag=5)/Raw('\0'*40)],
> iface=txItf)
>
> (outer) L2 type: ETHER
> (outer) L3 type: IPV4_EXT_UNKNOWN
> (outer) L4 type: Unknown
> Tunnel type: GRENAT
> Inner L2 type: ETHER
> Inner L3 type: IPV4_EXT_UNKNOWN
> Inner L4 type: L4_FRAG
>
>
> union {
> uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
> __extension__
> struct {
> uint8_t l2_type:4; /**< (Outer) L2 type. */
> uint8_t l3_type:4; /**< (Outer) L3 type. */
> uint8_t l4_type:4; /**< (Outer) L4 type. */
> uint8_t tun_type:4; /**< Tunnel type. */
> union {
> uint8_t inner_esp_next_proto;
> /**< ESP next protocol type, valid if
> * RTE_PTYPE_TUNNEL_ESP tunnel type is set
> * on both Tx and Rx.
> */
> __extension__
> struct {
> uint8_t inner_l2_type:4;
> /**< Inner L2 type. */
> uint8_t inner_l3_type:4;
> /**< Inner L3 type. */
> };
> };
> uint8_t inner_l4_type:4; /**< Inner L4 type. */
> };
> };
>
>
> Based on the above, it seems that inner_l2_len have to the length of Ether.
> Ther might need to be some correspondent between both fields to potray the same information.
> Or, the inner_l2_type and inner_l2_len are completly different ?
On the one hand, there is mbuf structure, which has got no 'tunnel_len' field.
It has 'l2_len' field [1] with a comment saying that for a tunnel packet, it
includes some extra terms apart from just 'inner L2 header size'. This use of
the 'l2_len' mbuf field is absolutely legitimate, and PMDs confirm this stance.
On the other hand, there is 'rte_net_hdr_lens' structure [2], which does have a
separate 'tunnel_len' field and, in general, has got slightly different naming.
And the 'inner_l2_len' field has a comment that looks almost like a copy-paste
from the mbuf structure. So does 'inner_l2_len' really need to include extra
terms, given the presence of a dedicated 'tunnel_len' field? Is it at all
correct or could it have been overlooked? One should take a closer look.
[1] https://github.com/DPDK/dpdk/blob/b222395561638f89562e4ef42e1eabf2d6db43dd/lib/mbuf/rte_mbuf_core.h#L628
[2] https://github.com/DPDK/dpdk/blob/b222395561638f89562e4ef42e1eabf2d6db43dd/lib/net/rte_net.h#L22
Thank you.
>
> Best Regards,
> Khadem
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
@ 2025-07-28 12:30 Khadem Ullah
0 siblings, 0 replies; 9+ messages in thread
From: Khadem Ullah @ 2025-07-28 12:30 UTC (permalink / raw)
To: dev, jasvinder.singh, bruce.richardson
Cc: thomas, andrew.rybchenko, stable, Khadem Ullah
Fix incorrect inner_l2_len values for VXLAN, VXLAN-GPE, GTPU, and Geneve.
These protocols carry full Ethernet frames, so inner_l2_len should be
set to the size of an Ethernet header (14 bytes), not include tunnel or
UDP headers.
Fixes: 64ed7f854c ('net: add tunnel packet type parsing')
Cc: stable@dpdk.org
Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
---
lib/net/rte_net.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 44fb6c0f51..ca9260a67b 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -198,7 +198,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
return RTE_PTYPE_TUNNEL_VXLAN;
}
@@ -210,7 +210,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = vgh->proto;
return RTE_PTYPE_TUNNEL_VXLAN_GPE;
@@ -244,7 +244,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
*proto = 0;
}
*off += gtp_len;
- hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
hdr_lens->tunnel_len = gtp_len;
if (port_no == RTE_GTPC_UDP_PORT)
return RTE_PTYPE_TUNNEL_GTPC;
@@ -262,7 +262,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
*off += geneve_len;
hdr_lens->tunnel_len = geneve_len;
- hdr_lens->inner_l2_len = sizeof(struct rte_udp_hdr) + geneve_len;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = gnh->proto;
if (gnh->proto == 0)
*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
--
2.47.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets
@ 2025-07-28 12:21 Khadem Ullah
0 siblings, 0 replies; 9+ messages in thread
From: Khadem Ullah @ 2025-07-28 12:21 UTC (permalink / raw)
To: dev, jasvinder.singh, bruce.richardson
Cc: thomas, andrew.rybchenko, stable, Khadem Ullah
Fix incorrect inner_l2_len values for VXLAN, VXLAN-GPE, GTPU, and Geneve.
These protocols carry full Ethernet frames, so inner_l2_len should be
set to the size of an Ethernet header (14 bytes), not include tunnel or
UDP headers.
Fixes: 44fb6c0f51 ('net: initial tunnel type parser')
Cc: stable@dpdk.org
Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
---
lib/net/rte_net.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 44fb6c0f51..ca9260a67b 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -198,7 +198,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = RTE_VXLAN_GPE_TYPE_ETH; /* just for eth header parse. */
return RTE_PTYPE_TUNNEL_VXLAN;
}
@@ -210,7 +210,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
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;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = vgh->proto;
return RTE_PTYPE_TUNNEL_VXLAN_GPE;
@@ -244,7 +244,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
*proto = 0;
}
*off += gtp_len;
- hdr_lens->inner_l2_len = gtp_len + sizeof(struct rte_udp_hdr);
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
hdr_lens->tunnel_len = gtp_len;
if (port_no == RTE_GTPC_UDP_PORT)
return RTE_PTYPE_TUNNEL_GTPC;
@@ -262,7 +262,7 @@ ptype_tunnel_with_udp(uint16_t *proto, const struct rte_mbuf *m,
geneve_len = sizeof(*gnh) + gnh->opt_len * 4;
*off += geneve_len;
hdr_lens->tunnel_len = geneve_len;
- hdr_lens->inner_l2_len = sizeof(struct rte_udp_hdr) + geneve_len;
+ hdr_lens->inner_l2_len = sizeof(struct rte_ether_hdr);
*proto = gnh->proto;
if (gnh->proto == 0)
*proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
--
2.47.1
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-01 13:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-28 13:12 [PATCH] net/rte_net: fix inner L2 length for tunneled Ethernet packets Khadem Ullah
2025-07-28 13:28 ` Ivan Malov
2025-07-29 5:06 ` Khadem Ullah
2025-07-31 10:26 ` Andrew Rybchenko
2025-08-01 11:28 ` Khadem Ullah
2025-08-01 13:23 ` Ivan Malov
2025-07-31 10:21 ` Andrew Rybchenko
-- strict thread matches above, loose matches on Subject: below --
2025-07-28 12:30 Khadem Ullah
2025-07-28 12:21 Khadem Ullah
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).