aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api
diff options
context:
space:
mode:
authorJanne Peltonen <janne.peltonen@nokia.com>2021-03-27 11:58:43 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2021-04-01 15:02:59 +0300
commitaf42de5a0a8109c202ca7d9ce9c867ccbc5d2011 (patch)
treeef3f3cb2f019799943f5576a6add2ddbd8724f9f /test/validation/api
parent7fa8b1953c89c762ad0afd9d5dafda755f6e10cb (diff)
validation: ipsec: clean up user pointer checking logic
User pointer of the result packet is null after outbound inline IPsec operation only if the operation is successful in which case the result packet goes through the loop interface before getting checked. In case the operation fails (as it does for some negative tests), the result packet is the original packet that gets delivered directly as an event, without the loop interface being involved. In this case the user pointer has the original non-NULL value. The current code does not take this into account, although the check is not currently done in cases where it would incorrectly fail. Fix the user pointer checking logic and move the checking up in the chain so that it is done for all packets. Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com> Reviewed-by: Anoob Joseph <anoobj@marvell.com>
Diffstat (limited to 'test/validation/api')
-rw-r--r--test/validation/api/ipsec/ipsec.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 4acdc55b3..625c749d5 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -423,7 +423,6 @@ static void ipsec_check_packet(const ipsec_test_packet *itp, odp_packet_t pkt,
uint8_t data[len];
const odph_ipv4hdr_t *itp_ip;
odph_ipv4hdr_t *ip;
- int inline_mode = 0;
if (NULL == itp)
return;
@@ -432,19 +431,6 @@ static void ipsec_check_packet(const ipsec_test_packet *itp, odp_packet_t pkt,
if (ODP_PACKET_INVALID == pkt)
return;
- if ((!is_outbound &&
- suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) ||
- (is_outbound &&
- suite_context.outbound_op_mode == ODP_IPSEC_OP_MODE_INLINE))
- inline_mode = 1;
-
- if (inline_mode) {
- /* User pointer is reset during inline mode (packet IO) */
- CU_ASSERT(odp_packet_user_ptr(pkt) == NULL);
- } else {
- CU_ASSERT(odp_packet_user_ptr(pkt) == PACKET_USER_PTR);
- }
-
l3 = odp_packet_l3_offset(pkt);
l4 = odp_packet_l4_offset(pkt);
odp_packet_copy_to_mem(pkt, 0, len, data);
@@ -835,6 +821,7 @@ void ipsec_check_in_one(const ipsec_test_part *part, odp_ipsec_sa_t sa)
for (i = 0; i < num_out; i++) {
odp_ipsec_packet_result_t result;
+ void *expected_user_ptr = PACKET_USER_PTR;
if (ODP_PACKET_INVALID == pkto[i]) {
CU_FAIL("ODP_PACKET_INVALID received");
@@ -843,7 +830,7 @@ void ipsec_check_in_one(const ipsec_test_part *part, odp_ipsec_sa_t sa)
if (ODP_EVENT_PACKET_IPSEC !=
odp_event_subtype(odp_packet_to_event(pkto[i]))) {
- /* Inline packet went through loop */
+ /* Inline packet failed SA lookup */
CU_ASSERT_EQUAL(1, part->out[i].status.error.sa_lookup);
} else {
CU_ASSERT_EQUAL(0, odp_ipsec_result(&result, pkto[i]));
@@ -869,6 +856,10 @@ void ipsec_check_in_one(const ipsec_test_part *part, odp_ipsec_sa_t sa)
ipsec_check_packet(part->out[i].pkt_res,
pkto[i],
false);
+ if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE)
+ expected_user_ptr = NULL;
+ CU_ASSERT(odp_packet_user_ptr(pkto[i]) == expected_user_ptr);
+
if (part->out[i].pkt_res != NULL &&
part->out[i].l3_type != _ODP_PROTO_L3_TYPE_UNDEF)
CU_ASSERT_EQUAL(part->out[i].l3_type,
@@ -923,6 +914,7 @@ int ipsec_check_out(const ipsec_test_part *part, odp_ipsec_sa_t sa,
odp_event_subtype(odp_packet_to_event(pkto[i]))) {
/* Inline packet went through loop */
CU_ASSERT_EQUAL(0, part->out[i].status.error.all);
+ CU_ASSERT(odp_packet_user_ptr(pkto[i]) == NULL);
/* L2 header must match the requested one */
check_l2_header(part->out[i].pkt_res, pkto[i]);
} else {
@@ -936,6 +928,7 @@ int ipsec_check_out(const ipsec_test_part *part, odp_ipsec_sa_t sa,
CU_ASSERT_EQUAL(sa, result.sa);
CU_ASSERT_EQUAL(IPSEC_SA_CTX,
odp_ipsec_sa_context(sa));
+ CU_ASSERT(odp_packet_user_ptr(pkto[i]) == PACKET_USER_PTR);
/* Parse the packet to set L4 offset and type */
parse_ip(pkto[i]);