examples/ipsec-secgw: set and use packet type
authorVladimir Medvedkin <vladimir.medvedkin@intel.com>
Fri, 31 Jan 2020 17:39:44 +0000 (17:39 +0000)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 5 Feb 2020 14:20:51 +0000 (15:20 +0100)
Set mbuf ptype in prepare_one_packet() after parsing ether_type.
Use mbuf ptype after to recognize packet's address family.

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
examples/ipsec-secgw/ipsec-secgw.c
examples/ipsec-secgw/sad.h

index 32ecd26..4799bc9 100644 (file)
@@ -323,6 +323,7 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)
                }
                pkt->l2_len = 0;
                pkt->l3_len = sizeof(*iph4);
+               pkt->packet_type |= RTE_PTYPE_L3_IPV4;
        } else if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
                int next_proto;
                size_t l3len, ext_len;
@@ -357,6 +358,7 @@ prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)
                }
                pkt->l2_len = 0;
                pkt->l3_len = l3len;
+               pkt->packet_type |= RTE_PTYPE_L3_IPV6;
        } else {
                /* Unknown/Unsupported type, drop the packet */
                RTE_LOG(ERR, IPSEC, "Unsupported packet type 0x%x\n",
index 3f92db2..55712ba 100644 (file)
@@ -93,7 +93,7 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
                esp = rte_pktmbuf_mtod_offset(pkts[i], struct rte_esp_hdr *,
                                pkts[i]->l3_len);
 
-               is_ipv4 = ((ipv4->version_ihl >> 4) == IPVERSION);
+               is_ipv4 = pkts[i]->packet_type & RTE_PTYPE_L3_IPV4;
                spi = rte_be_to_cpu_32(esp->spi);
                cache_idx = SPI2IDX(spi, cache->mask);