All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Raslan Darawsheh <rasland@nvidia.com>
Cc: dev@dpdk.org, stephen@networkplumber.org, haijie1@huawei.com,
	"Morten Brørup" <mb@smartsharesystems.com>
Subject: Re: [PATCH v3] app/testpmd: fix VLAN header parsing
Date: Mon, 24 Mar 2025 17:59:57 +0100	[thread overview]
Message-ID: <6263413.MHq7AAxBmi@thomas> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9FB4B@smartserver.smartshare.dk>

24/03/2025 14:18, Morten Brørup:
> > From: Raslan Darawsheh [mailto:rasland@nvidia.com]
> > Sent: Monday, 24 March 2025 10.34
> > 
> > When processing VLAN or QinQ packets, an infinite loop occurred,
> > preventing the csum forward engine from proceeding and causing
> > testpmd to hang during shutdown attempts.
> > 
> > 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>
> > ---
> > v3: fixed wrong indentation
> >     add boundaries check for 8 VLANs at max
> > 
> > v2: update commit log
> >     fixed pointer handling to actually move the pointer
> > ---
> >  app/test-pmd/csumonly.c | 16 +++++++++++-----
> >  1 file changed, 11 insertions(+), 5 deletions(-)
> > 
> > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
> > index 5b906eaa53..710967ca4d 100644
> > --- a/app/test-pmd/csumonly.c
> > +++ b/app/test-pmd/csumonly.c
> > @@ -59,6 +59,8 @@
> >  #define GRE_SUPPORTED_FIELDS	(GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT
> > |\
> >  				 GRE_SEQUENCE_PRESENT)
> > 
> > +#define MAX_VLAN_HEADERS 8
> > +
> >  /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
> >  #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
> >  #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) &
> > 0xff00U) >> 8)))
> > @@ -466,9 +468,10 @@ pkts_ip_csum_recalc(struct rte_mbuf **pkts_burst,
> > const uint16_t nb_pkts, uint64
> >  static uint32_t
> >  get_ethertype_by_ptype(struct rte_ether_hdr *eth_hdr, uint32_t ptype)
> >  {
> > -	struct rte_vlan_hdr *vlan_hdr;
> > +	struct rte_vlan_hdr *vlan_hdr, *max_vlans;
> >  	uint16_t ethertype;
> > 
> > +
> 
> Please omit adding an extra empty line.
> 
> >  	switch (ptype) {
> >  	case RTE_PTYPE_L3_IPV4:
> >  	case RTE_PTYPE_L3_IPV4_EXT:
> > @@ -486,10 +489,13 @@ 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)) {
> > -			vlan_hdr = (struct rte_vlan_hdr *)
> > -				((char *)eth_hdr + sizeof(*eth_hdr));
> > +		vlan_hdr = (struct rte_vlan_hdr *) RTE_PTR_ADD(eth_hdr,

useless type cast

> > +					offsetof(struct rte_ether_hdr,
> > ether_type));
> 
> Above line indentation with 2, not 3 TABs.
> 
> > +		max_vlans = vlan_hdr + MAX_VLAN_HEADERS;
> > +		while (((ethertype == _htons(RTE_ETHER_TYPE_VLAN) ||
> 
> Superfluous parenthesis: "while ( ((x || y)) && z)".
> 
> > +			ethertype == _htons(RTE_ETHER_TYPE_QINQ))) &&
> > +			vlan_hdr < max_vlans) {
> 
> Above two lines indentation with 2, not 1 TAB.
> 
> > +			vlan_hdr++;
> >  			ethertype = vlan_hdr->eth_proto;
> >  		}
> >  		return ethertype;
> > --
> > 2.39.5 (Apple Git-154)
> 
> With above nits fixed (can be fixed when merging),
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>

All nits fixed and applied, thanks.



      reply	other threads:[~2025-03-24 17:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6263413.MHq7AAxBmi@thomas \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=haijie1@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=rasland@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.