mbuf: add a copy routine
[dpdk.git] / app / test / test_ipsec.c
index 2610d9d..4007eff 100644 (file)
@@ -452,8 +452,10 @@ ut_teardown(void)
 
        for (i = 0; i < BURST_SIZE; i++) {
                /* free crypto operation structure */
-               if (ut_params->cop[i])
+               if (ut_params->cop[i]) {
                        rte_crypto_op_free(ut_params->cop[i]);
+                       ut_params->cop[i] = NULL;
+               }
 
                /*
                 * free mbuf - both obuf and ibuf are usually the same,
@@ -463,17 +465,17 @@ ut_teardown(void)
                if (ut_params->obuf[i]) {
                        rte_pktmbuf_free(ut_params->obuf[i]);
                        if (ut_params->ibuf[i] == ut_params->obuf[i])
-                               ut_params->ibuf[i] = 0;
-                       ut_params->obuf[i] = 0;
+                               ut_params->ibuf[i] = NULL;
+                       ut_params->obuf[i] = NULL;
                }
                if (ut_params->ibuf[i]) {
                        rte_pktmbuf_free(ut_params->ibuf[i]);
-                       ut_params->ibuf[i] = 0;
+                       ut_params->ibuf[i] = NULL;
                }
 
                if (ut_params->testbuf[i]) {
                        rte_pktmbuf_free(ut_params->testbuf[i]);
-                       ut_params->testbuf[i] = 0;
+                       ut_params->testbuf[i] = NULL;
                }
        }
 
@@ -572,7 +574,7 @@ setup_test_string_tunneled(struct rte_mempool *mpool, const char *string,
        struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
        uint32_t hdrlen = sizeof(struct rte_ipv4_hdr) +
                sizeof(struct rte_esp_hdr);
-       uint32_t taillen = sizeof(struct esp_tail);
+       uint32_t taillen = sizeof(struct rte_esp_tail);
        uint32_t t_len = len + hdrlen + taillen;
        uint32_t padlen;
 
@@ -584,7 +586,7 @@ setup_test_string_tunneled(struct rte_mempool *mpool, const char *string,
        padlen = RTE_ALIGN(t_len, 4) - t_len;
        t_len += padlen;
 
-       struct esp_tail espt  = {
+       struct rte_esp_tail espt = {
                .pad_len = padlen,
                .next_proto = IPPROTO_IPIP,
        };
@@ -881,6 +883,19 @@ lksd_proto_ipsec(uint16_t num_pkts)
        return TEST_SUCCESS;
 }
 
+static void
+dump_grp_pkt(uint32_t i, struct rte_ipsec_group *grp, uint32_t k)
+{
+       RTE_LOG(ERR, USER1,
+               "After rte_ipsec_pkt_process grp[%d].cnt=%d k=%d fail\n",
+               i, grp[i].cnt, k);
+       RTE_LOG(ERR, USER1,
+               "After rte_ipsec_pkt_process grp[%d].m=%p grp[%d].m[%d]=%p\n",
+               i, grp[i].m, i, k, grp[i].m[k]);
+
+       rte_pktmbuf_dump(stdout, grp[i].m[k], grp[i].m[k]->data_len);
+}
+
 static int
 crypto_ipsec_2sa(void)
 {
@@ -916,7 +931,7 @@ crypto_ipsec_2sa(void)
                ut_params->obuf, grp, BURST_SIZE);
        if (ng != BURST_SIZE) {
                RTE_LOG(ERR, USER1, "rte_ipsec_pkt_crypto_group fail ng=%d\n",
-                               ng);
+                       ng);
                return TEST_FAILED;
        }
 
@@ -924,7 +939,7 @@ crypto_ipsec_2sa(void)
        for (i = 0; i < ng; i++) {
                k = rte_ipsec_pkt_process(grp[i].id.ptr, grp[i].m, grp[i].cnt);
                if (k != grp[i].cnt) {
-                       RTE_LOG(ERR, USER1, "rte_ipsec_pkt_process fail\n");
+                       dump_grp_pkt(i, grp, k);
                        return TEST_FAILED;
                }
        }
@@ -1059,7 +1074,7 @@ crypto_ipsec_2sa_4grp(void)
        for (i = 0; i < ng; i++) {
                k = rte_ipsec_pkt_process(grp[i].id.ptr, grp[i].m, grp[i].cnt);
                if (k != grp[i].cnt) {
-                       RTE_LOG(ERR, USER1, "rte_ipsec_pkt_process fail\n");
+                       dump_grp_pkt(i, grp, k);
                        return TEST_FAILED;
                }
                rc = crypto_ipsec_4grp_check_cnt(i, grp);
@@ -1156,9 +1171,11 @@ static void
 destroy_sa(uint32_t j)
 {
        struct ipsec_unitest_params *ut = &unittest_params;
+       struct ipsec_testsuite_params *ts = &testsuite_params;
 
        rte_ipsec_sa_fini(ut->ss[j].sa);
        rte_free(ut->ss[j].sa);
+       rte_cryptodev_sym_session_clear(ts->valid_dev, ut->ss[j].crypto.ses);
        rte_cryptodev_sym_session_free(ut->ss[j].crypto.ses);
        memset(&ut->ss[j], 0, sizeof(ut->ss[j]));
 }