net/i40e: fix PPPoL2TP packet type parsing
[dpdk.git] / examples / ipsec-secgw / ipsec-secgw.c
index 22249f3..b45b87b 100644 (file)
@@ -330,6 +330,7 @@ prepare_tx_pkt(struct rte_mbuf *pkt, uint16_t port)
                pkt->l3_len = sizeof(struct ip);
                pkt->l2_len = ETHER_HDR_LEN;
 
+               ip->ip_sum = 0;
                ethhdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
        } else {
                pkt->ol_flags |= PKT_TX_IPV6;
@@ -509,11 +510,13 @@ outbound_sp(struct sp_ctx *sp, struct traffic_type *ip,
                sa_idx = ip->res[i] & PROTECT_MASK;
                if (ip->res[i] & DISCARD)
                        rte_pktmbuf_free(m);
+               else if (ip->res[i] & BYPASS)
+                       ip->pkts[j++] = m;
                else if (sa_idx < IPSEC_SA_MAX_ENTRIES) {
                        ipsec->res[ipsec->num] = sa_idx;
                        ipsec->pkts[ipsec->num++] = m;
-               } else /* BYPASS */
-                       ip->pkts[j++] = m;
+               } else /* invalid SA idx */
+                       rte_pktmbuf_free(m);
        }
        ip->num = j;
 }
@@ -1440,7 +1443,7 @@ cryptodevs_init(void)
                dev_conf.nb_queue_pairs = qp;
 
                uint32_t dev_max_sess = cdev_info.sym.max_nb_sessions;
-               if (dev_max_sess < (CDEV_MP_NB_OBJS / 2))
+               if (dev_max_sess != 0 && dev_max_sess < (CDEV_MP_NB_OBJS / 2))
                        rte_exit(EXIT_FAILURE,
                                "Device does not support at least %u "
                                "sessions", CDEV_MP_NB_OBJS / 2);