Skip to content

Commit 648abd4

Browse files
SruChallaAkhil Goyal
authored andcommitted
test/security: skip IPsec post process for negative tests
Skips calling test_ipsec_post_process for negative inline IPsec tests as received packet might not be valid for a negative case. Signed-off-by: Srujana Challa <[email protected]> Acked-by: Akhil Goyal <[email protected]>
1 parent d616e75 commit 648abd4

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

app/test/test_cryptodev_security_ipsec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ test_ipsec_post_process(const struct rte_mbuf *m, const struct ipsec_test_data *
916916
seg = seg->next;
917917
}
918918
len = RTE_MIN(len, data_len);
919+
TEST_ASSERT(len <= IPSEC_TEXT_MAX_LEN, "Invalid packet length: %u", len);
919920
/* Copy mbuf payload to continuous buffer */
920921
output = rte_pktmbuf_read(m, 0, len, output_text);
921922
if (output != output_text)

app/test/test_security_inline_proto.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,12 +1449,27 @@ test_ipsec_inline_proto_process(struct ipsec_test_data *td,
14491449
for (i = 0; i < nb_rx; i++) {
14501450
rte_pktmbuf_adj(rx_pkts_burst[i], RTE_ETHER_HDR_LEN);
14511451

1452-
ret = test_ipsec_post_process(rx_pkts_burst[i], td,
1453-
res_d, silent, flags);
1454-
if (ret != TEST_SUCCESS) {
1455-
for ( ; i < nb_rx; i++)
1452+
/* For tests with status as error for test success,
1453+
* skip verification
1454+
*/
1455+
if (td->ipsec_xform.direction ==
1456+
RTE_SECURITY_IPSEC_SA_DIR_INGRESS && (flags->icv_corrupt ||
1457+
flags->sa_expiry_pkts_hard || flags->tunnel_hdr_verify ||
1458+
td->ar_packet)) {
1459+
if (!(rx_pkts_burst[i]->ol_flags &
1460+
RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED)) {
14561461
rte_pktmbuf_free(rx_pkts_burst[i]);
1457-
goto out;
1462+
rx_pkts_burst[i] = NULL;
1463+
return TEST_FAILED;
1464+
}
1465+
} else {
1466+
ret = test_ipsec_post_process(rx_pkts_burst[i], td,
1467+
res_d, silent, flags);
1468+
if (ret != TEST_SUCCESS) {
1469+
for ( ; i < nb_rx; i++)
1470+
rte_pktmbuf_free(rx_pkts_burst[i]);
1471+
goto out;
1472+
}
14581473
}
14591474

14601475
ret = test_ipsec_stats_verify(ctx, ses, flags,

0 commit comments

Comments
 (0)