[PATCH 4/5] net: fix MPLS parsing in software ptype parser
Stephen Hemminger
stephen at networkplumber.org
Thu Nov 12 20:54:45 CET 2026
The MPLS branch of rte_net_get_ptype() never sets a packet type. The loop
has no break, so it always runs to i == MAX_MPLS_HDR and returns on the
test that follows, leaving the two statements after it unreachable. The
cause is that the loop ignores the bottom of stack bit and cannot tell
how many labels are present.
Break on the bottom of stack bit, which terminates the loop at the last
label, and count i + 1 labels in l2_len.
Bugzilla ID: 2118
Fixes: 140af04e63d7 ("net: support MPLS in software packet type parser")
Cc: stable at dpdk.org
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/net/rte_net.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 882ebf1467..56b6f23ad4 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -403,11 +403,14 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
sizeof(*mh), &mh_copy);
if (unlikely(mh == NULL))
return pkt_type;
+ /* the bottom of stack bit ends the label stack */
+ if (mh->bs)
+ break;
}
if (i == MAX_MPLS_HDR)
return pkt_type;
pkt_type = RTE_PTYPE_L2_ETHER_MPLS;
- hdr_lens->l2_len += (sizeof(*mh) * i);
+ hdr_lens->l2_len += (sizeof(*mh) * (i + 1));
return pkt_type;
}
--
2.53.0
More information about the stable
mailing list