crypto/snow3g: add to meson build
[dpdk.git] / examples / ipsec-secgw / ipsec-secgw.c
index b253eea..478dd80 100644 (file)
@@ -438,11 +438,11 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
        for (i = 0; i < ip->num; i++) {
                m = ip->pkts[i];
                res = ip->res[i];
-               if (res & BYPASS) {
+               if (res == BYPASS) {
                        ip->pkts[j++] = m;
                        continue;
                }
-               if (res & DISCARD) {
+               if (res == DISCARD) {
                        rte_pktmbuf_free(m);
                        continue;
                }
@@ -453,9 +453,8 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
                        continue;
                }
 
-               sa_idx = ip->res[i] & PROTECT_MASK;
-               if (sa_idx >= IPSEC_SA_MAX_ENTRIES ||
-                               !inbound_sa_check(sa, m, sa_idx)) {
+               sa_idx = SPI2IDX(res);
+               if (!inbound_sa_check(sa, m, sa_idx)) {
                        rte_pktmbuf_free(m);
                        continue;
                }
@@ -541,16 +540,15 @@ outbound_sp(struct sp_ctx *sp, struct traffic_type *ip,
        j = 0;
        for (i = 0; i < ip->num; i++) {
                m = ip->pkts[i];
-               sa_idx = ip->res[i] & PROTECT_MASK;
-               if (ip->res[i] & DISCARD)
+               sa_idx = SPI2IDX(ip->res[i]);
+               if (ip->res[i] == DISCARD)
                        rte_pktmbuf_free(m);
-               else if (ip->res[i] & BYPASS)
+               else if (ip->res[i] == BYPASS)
                        ip->pkts[j++] = m;
-               else if (sa_idx < IPSEC_SA_MAX_ENTRIES) {
+               else {
                        ipsec->res[ipsec->num] = sa_idx;
                        ipsec->pkts[ipsec->num++] = m;
-               } else /* invalid SA idx */
-                       rte_pktmbuf_free(m);
+               }
        }
        ip->num = j;
 }
@@ -1439,7 +1437,7 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)
 int
 add_dst_ethaddr(uint16_t port, const struct ether_addr *addr)
 {
-       if (port > RTE_DIM(ethaddr_tbl))
+       if (port >= RTE_DIM(ethaddr_tbl))
                return -EINVAL;
 
        ethaddr_tbl[port].dst = ETHADDR_TO_UINT64(addr);
@@ -1793,7 +1791,7 @@ cryptodevs_init(void)
                                rte_eth_dev_get_sec_ctx(port_id)) {
                        int socket_id = rte_eth_dev_socket_id(port_id);
 
-                       if (!socket_ctx[socket_id].session_pool) {
+                       if (!socket_ctx[socket_id].session_priv_pool) {
                                char mp_name[RTE_MEMPOOL_NAMESIZE];
                                struct rte_mempool *sess_mp;
 
@@ -1813,7 +1811,8 @@ cryptodevs_init(void)
                                else
                                        printf("Allocated session pool "
                                                "on socket %d\n", socket_id);
-                               socket_ctx[socket_id].session_pool = sess_mp;
+                               socket_ctx[socket_id].session_priv_pool =
+                                               sess_mp;
                        }
                }
        }