X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_net%2Frte_net.c;h=315c37c55112fc1ac4faac0104428ca0c06738df;hb=6d13ea8e8e49ab957deae2bba5ecf4a4bfe747d1;hp=9eb7c74381dde70a7a734d010ede402f59bf92e3;hpb=8f0e4d6a78a52e929aa4852bf94601ce7dc2199f;p=dpdk.git diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index 9eb7c74381..315c37c551 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 */ @@ -228,8 +229,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, struct rte_net_hdr_lens *hdr_lens, uint32_t layers) { struct rte_net_hdr_lens local_hdr_lens; - const struct ether_hdr *eh; - struct ether_hdr eh_copy; + const struct rte_ether_hdr *eh; + struct rte_ether_hdr eh_copy; uint32_t pkt_type = RTE_PTYPE_L2_ETHER; uint32_t off = 0; uint16_t proto; @@ -252,8 +253,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, goto l3; /* fast path if packet is IPv4 */ if (proto == rte_cpu_to_be_16(ETHER_TYPE_VLAN)) { - const struct vlan_hdr *vh; - struct vlan_hdr vh_copy; + const struct rte_vlan_hdr *vh; + struct rte_vlan_hdr vh_copy; pkt_type = RTE_PTYPE_L2_ETHER_VLAN; vh = rte_pktmbuf_read(m, off, sizeof(*vh), &vh_copy); @@ -263,8 +264,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, hdr_lens->l2_len += sizeof(*vh); proto = vh->eth_proto; } else if (proto == rte_cpu_to_be_16(ETHER_TYPE_QINQ)) { - const struct vlan_hdr *vh; - struct vlan_hdr vh_copy; + const struct rte_vlan_hdr *vh; + struct rte_vlan_hdr vh_copy; pkt_type = RTE_PTYPE_L2_ETHER_QINQ; vh = rte_pktmbuf_read(m, off + sizeof(*vh), sizeof(*vh), @@ -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; @@ -383,8 +402,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, } if (proto == rte_cpu_to_be_16(ETHER_TYPE_VLAN)) { - const struct vlan_hdr *vh; - struct vlan_hdr vh_copy; + const struct rte_vlan_hdr *vh; + struct rte_vlan_hdr vh_copy; pkt_type &= ~RTE_PTYPE_INNER_L2_MASK; pkt_type |= RTE_PTYPE_INNER_L2_ETHER_VLAN; @@ -395,8 +414,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, hdr_lens->inner_l2_len += sizeof(*vh); proto = vh->eth_proto; } else if (proto == rte_cpu_to_be_16(ETHER_TYPE_QINQ)) { - const struct vlan_hdr *vh; - struct vlan_hdr vh_copy; + const struct rte_vlan_hdr *vh; + struct rte_vlan_hdr vh_copy; pkt_type &= ~RTE_PTYPE_INNER_L2_MASK; pkt_type |= RTE_PTYPE_INNER_L2_ETHER_QINQ;