DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix VLAN header parsing
@ 2025-03-23 12:28 Raslan Darawsheh
  2025-03-23 13:14 ` Morten Brørup
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Raslan Darawsheh @ 2025-03-23 12:28 UTC (permalink / raw)
  To: thomas; +Cc: dev, haijie1

Updated the `get_ethertype_by_ptype` function to correctly parse VLAN
headers.

Fixes: 76730c7b9b5a ("app/testpmd: use packet type parsing API")
Cc: haijie1@huawei.com

Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
---
 app/test-pmd/csumonly.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 5b906eaa53..302cc4cc66 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -468,6 +468,7 @@ get_ethertype_by_ptype(struct rte_ether_hdr *eth_hdr, uint32_t ptype)
 {
 	struct rte_vlan_hdr *vlan_hdr;
 	uint16_t ethertype;
+	uint32_t i = 0;
 
 	switch (ptype) {
 	case RTE_PTYPE_L3_IPV4:
@@ -486,10 +487,11 @@ get_ethertype_by_ptype(struct rte_ether_hdr *eth_hdr, uint32_t ptype)
 		return _htons(RTE_ETHER_TYPE_IPV6);
 	default:
 		ethertype = eth_hdr->ether_type;
-		while (eth_hdr->ether_type == _htons(RTE_ETHER_TYPE_VLAN) ||
-			eth_hdr->ether_type == _htons(RTE_ETHER_TYPE_QINQ)) {
+		while (ethertype == _htons(RTE_ETHER_TYPE_VLAN) ||
+			ethertype == _htons(RTE_ETHER_TYPE_QINQ)) {
 			vlan_hdr = (struct rte_vlan_hdr *)
-				((char *)eth_hdr + sizeof(*eth_hdr));
+				((char *)eth_hdr + sizeof(*eth_hdr) +
+				(i * sizeof(struct rte_vlan_hdr)));
 			ethertype = vlan_hdr->eth_proto;
 		}
 		return ethertype;
-- 
2.39.5 (Apple Git-154)


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

end of thread, other threads:[~2025-03-24 17:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-23 12:28 [PATCH] app/testpmd: fix VLAN header parsing Raslan Darawsheh
2025-03-23 13:14 ` Morten Brørup
2025-03-24  7:34   ` Raslan Darawsheh
2025-03-24  7:43     ` Morten Brørup
2025-03-24  7:44     ` Morten Brørup
2025-03-24  8:32       ` Raslan Darawsheh
2025-03-24  8:45         ` Morten Brørup
2025-03-23 16:00 ` Stephen Hemminger
2025-03-24  7:37   ` Raslan Darawsheh
2025-03-23 16:39 ` Thomas Monjalon
2025-03-24  7:38   ` Raslan Darawsheh
2025-03-24  8:50 ` [PATCH v2] " Raslan Darawsheh
2025-03-24  9:04   ` Morten Brørup
2025-03-24  9:40     ` Raslan Darawsheh
2025-03-24  9:33 ` [PATCH v3] " Raslan Darawsheh
2025-03-24 13:18   ` Morten Brørup
2025-03-24 16:59     ` Thomas Monjalon

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