[PATCH v3] lib/net: add MPLS insert and strip functionality
Stephen Hemminger
stephen at networkplumber.org
Thu Oct 3 20:46:23 CEST 2024
On Fri, 24 Feb 2023 16:06:19 +0500
Tanzeel-inline <tanxeel1.ahmed at gmail.com> wrote:
> +static inline int
> +rte_mpls_strip_over_l2(struct rte_mbuf *m)
> +{
> + struct rte_ether_hdr *eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> + struct rte_mpls_hdr *mph;
> + bool mpls_exist = true;
> +
> + if (eh->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS))
> + return -1;
> +
> + /* Stripping all MPLS header */
> + while (mpls_exist) {
> + mph = rte_pktmbuf_mtod_offset(m, struct rte_mpls_hdr*,
space required (i.e "struct rte_mpls_hdr *")
> + sizeof(struct rte_ether_hdr));
> + if (mph->bs & 1)
> + mpls_exist = false;
> + memmove(rte_pktmbuf_adj(m, sizeof(struct rte_mpls_hdr)),
> + eh, sizeof(struct rte_ether_hdr));
> + eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> + }
> +
> + return 0;
> +}
This function will fail for the case of segmented mbuf.
Also need to handle case where mbuf is corrupted and just has stack of mpls
tags and the last one is incomplete.
More information about the dev
mailing list