X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=blobdiff_plain;f=lib%2Flibrte_net%2Frte_net.c;h=378a4126c6b1b35b7fe6752527a4a5324a0c5147;hp=9eb7c74381dde70a7a734d010ede402f59bf92e3;hb=140af04e63d77e8f57f5db1ffadfada38b677e53;hpb=e480cf487a0d77ead8fa606532ead1e35eb2426f diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index 9eb7c74381..378a4126c6 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /* get l3 packet type from ip6 next protocol */ @@ -274,9 +275,27 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, off += 2 * sizeof(*vh); hdr_lens->l2_len += 2 * sizeof(*vh); proto = vh->eth_proto; + } else if ((proto == rte_cpu_to_be_16(ETHER_TYPE_MPLS)) || + (proto == rte_cpu_to_be_16(ETHER_TYPE_MPLSM))) { + unsigned int i; + const struct mpls_hdr *mh; + struct mpls_hdr mh_copy; + +#define MAX_MPLS_HDR 5 + for (i = 0; i < MAX_MPLS_HDR; i++) { + mh = rte_pktmbuf_read(m, off + (i * sizeof(*mh)), + sizeof(*mh), &mh_copy); + if (unlikely(mh == NULL)) + return pkt_type; + } + if (i == MAX_MPLS_HDR) + return pkt_type; + pkt_type = RTE_PTYPE_L2_ETHER_MPLS; + hdr_lens->l2_len += (sizeof(*mh) * i); + return pkt_type; } - l3: +l3: if ((layers & RTE_PTYPE_L3_MASK) == 0) return pkt_type;