> From: Raslan Darawsheh [mailto:rasl...@nvidia.com] > Sent: Monday, 24 March 2025 09.50 > > 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: haij...@huawei.com > > Signed-off-by: Raslan Darawsheh <rasl...@nvidia.com> > --- > v2: update commit log > fixed pointer handling to actually move the pointer > --- > app/test-pmd/csumonly.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c > index 5b906eaa53..7bd1040c72 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -486,10 +486,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)) { > - vlan_hdr = (struct rte_vlan_hdr *) > - ((char *)eth_hdr + sizeof(*eth_hdr)); > + vlan_hdr = (struct rte_vlan_hdr *) RTE_PTR_ADD(eth_hdr, > + offsetof(struct rte_ether_hdr, ether_type)); > + while ((ethertype == _htons(RTE_ETHER_TYPE_VLAN) || > + ethertype == _htons(RTE_ETHER_TYPE_QINQ))) {
Two details: 1. Lines continuing on the next line must be indented by two TABs. 2. Please add the boundary check, as requested by Stephen. (I realize this mail may have crossed my response arguing why it is required.) > + vlan_hdr++; > ethertype = vlan_hdr->eth_proto; > } > return ethertype; > -- > 2.39.5 (Apple Git-154)