aboutsummaryrefslogtreecommitdiff
path: root/test/validation/api
diff options
context:
space:
mode:
authorJanne Peltonen <janne.peltonen@nokia.com>2021-03-27 11:58:50 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2021-04-01 15:02:59 +0300
commita660d1648222a77ad48ca9acdd554363966ca5c3 (patch)
treef712cf56f9c2838dcceef0b7efb699bf0f8fc313 /test/validation/api
parent7e344e84a70b2b07a8004b7933ba6d6f23ff16b6 (diff)
validation: ipsec: always check packet type after ipsec output
The L3 and L4 type of an outbound IPsec processed packet is not checked if the packet cannot be compared with an expected result packet (there are no expected result packets in combined output+input tests nor in TFC dummy tests). Improve testing by checking outbound processed packet against expected L3 and L4 types when there is no expected result packet. Set correct expected L3 and L4 types in output test parameters of various tests that did not have them. Fix the ethertype of the ethernet header of outbound inline processed packets so that parsing the packet for the L3 and L4 types works. 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.c36
-rw-r--r--test/validation/api/ipsec/ipsec_test_out.c34
2 files changed, 55 insertions, 15 deletions
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 9afc16a79..96deb58d5 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -638,7 +638,7 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
} else {
struct odp_ipsec_out_inline_param_t inline_param;
uint32_t hdr_len;
- uint8_t hdr[32];
+ odph_ethhdr_t hdr;
odp_queue_t queue = ODP_QUEUE_INVALID;
if (NULL != part->out[0].pkt_res) {
@@ -649,16 +649,16 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
*/
hdr_len = part->out[0].pkt_res->l3_offset;
CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
- memcpy(hdr, part->out[0].pkt_res->data, hdr_len);
- } else if (part->pkt_in->l3_offset !=
- ODP_PACKET_OFFSET_INVALID) {
- hdr_len = part->pkt_in->l3_offset;
- CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
- memcpy(hdr, part->pkt_in->data, hdr_len);
+ memcpy(&hdr, part->out[0].pkt_res->data, hdr_len);
} else {
- /* Dummy header */
hdr_len = 14;
- memset(hdr, 0xff, hdr_len);
+ memset(&hdr, 0xff, hdr_len);
+
+ if (part->out[0].l3_type == ODP_PROTO_L3_TYPE_IPV6) {
+ hdr.type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV6);
+ } else {
+ hdr.type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
+ }
}
if (part->flags.inline_hdr_in_packet) {
@@ -681,14 +681,14 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
CU_ASSERT_FATAL(ret >= 0);
odp_packet_l2_offset_set(pkt, new_l2_offset);
odp_packet_l3_offset_set(pkt, new_l3_offset);
- odp_packet_copy_from_mem(pkt, new_l2_offset, hdr_len, hdr);
+ odp_packet_copy_from_mem(pkt, new_l2_offset, hdr_len, &hdr);
if (l4_offset != ODP_PACKET_OFFSET_INVALID)
odp_packet_l4_offset_set(pkt, new_l3_offset +
l4_offset - l3_offset);
inline_param.outer_hdr.ptr = NULL;
} else {
- inline_param.outer_hdr.ptr = hdr;
+ inline_param.outer_hdr.ptr = (void *)&hdr;
}
inline_param.pktio = suite_context.pktio;
@@ -943,6 +943,20 @@ int ipsec_check_out(const ipsec_test_part *part, odp_ipsec_sa_t sa,
ipsec_check_packet(part->out[i].pkt_res,
pkto[i],
true);
+
+ /*
+ * If we did not have an expected packet to compare the
+ * result packet with, we will check the l3 and l4 types
+ * against the expected ones.
+ */
+ if (part->out[i].pkt_res == NULL) {
+ if (part->out[i].l3_type != _ODP_PROTO_L3_TYPE_UNDEF)
+ CU_ASSERT(part->out[i].l3_type ==
+ odp_packet_l3_type(pkto[i]));
+ if (part->out[i].l4_type != _ODP_PROTO_L4_TYPE_UNDEF)
+ CU_ASSERT(part->out[i].l4_type ==
+ odp_packet_l4_type(pkto[i]));
+ }
}
return num_out;
}
diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c
index 92f6566ac..9b2662041 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -478,6 +478,8 @@ static void test_out_in_common(ipsec_test_flags *flags,
odp_ipsec_stats_t stats;
odp_ipsec_sa_t sa_out;
odp_ipsec_sa_t sa_in;
+ odp_proto_l3_type_t out_l3_type = ODP_PROTO_L3_TYPE_IPV4;
+ odp_proto_l4_type_t out_l4_type = ODP_PROTO_L4_TYPE_ESP;
CU_ASSERT_NOT_EQUAL_FATAL(flags, NULL);
@@ -530,14 +532,22 @@ static void test_out_in_common(ipsec_test_flags *flags,
CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa_in);
+ if ((flags->tunnel && flags->tunnel_is_v6) ||
+ (!flags->tunnel && flags->v6))
+ out_l3_type = ODP_PROTO_L3_TYPE_IPV6;
+ if (flags->ah)
+ out_l4_type = ODP_PROTO_L4_TYPE_AH;
+ if (flags->udp_encap)
+ out_l4_type = ODP_PROTO_L4_TYPE_UDP;
+
ipsec_test_part test_out = {
.pkt_in = &pkt_ipv4_icmp_0,
.num_pkt = 1,
.out = {
{ .status.warn.all = 0,
.status.error.all = 0,
- .l3_type = ODP_PROTO_L3_TYPE_IPV4,
- .l4_type = ODP_PROTO_L4_TYPE_ICMPV4,
+ .l3_type = out_l3_type,
+ .l4_type = out_l4_type,
},
},
};
@@ -797,6 +807,8 @@ static void test_out_ipv4_ah_sha256_frag_check(void)
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
test.out[0].status.error.mtu = 1;
+ test.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4;
+ test.out[0].l4_type = ODP_PROTO_L4_TYPE_ICMPV4;
test2.pkt_in = &pkt_ipv4_icmp_0;
test2.num_opt = 1;
@@ -835,6 +847,8 @@ static void test_out_ipv4_ah_sha256_frag_check_2(void)
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
test.out[0].status.error.mtu = 1;
+ test.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4;
+ test.out[0].l4_type = ODP_PROTO_L4_TYPE_ICMPV4;
ipsec_test_part test2 = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -881,6 +895,8 @@ static void test_out_ipv4_esp_null_sha256_frag_check(void)
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
test.out[0].status.error.mtu = 1;
+ test.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4;
+ test.out[0].l4_type = ODP_PROTO_L4_TYPE_ICMPV4;
test2.pkt_in = &pkt_ipv4_icmp_0;
test2.num_opt = 1;
@@ -920,6 +936,8 @@ static void test_out_ipv4_esp_null_sha256_frag_check_2(void)
test.pkt_in = &pkt_ipv4_icmp_0;
test.num_pkt = 1;
test.out[0].status.error.mtu = 1;
+ test.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4;
+ test.out[0].l4_type = ODP_PROTO_L4_TYPE_ICMPV4;
ipsec_test_part test2 = {
.pkt_in = &pkt_ipv4_icmp_0,
@@ -1209,6 +1227,10 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
ipsec_test_part test;
ipsec_test_part test_in;
ipsec_test_part test_empty;
+ odp_proto_l3_type_t out_l3_type = ODP_PROTO_L3_TYPE_IPV4;
+
+ if (tunnel.type == ODP_IPSEC_TUNNEL_IPV6)
+ out_l3_type = ODP_PROTO_L3_TYPE_IPV6;
memset(&test, 0, sizeof(ipsec_test_part));
memset(&test_in, 0, sizeof(ipsec_test_part));
@@ -1244,6 +1266,8 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
test.opt.flag.tfc_dummy = 1;
test.opt.tfc_pad_len = 16;
test.num_pkt = 1;
+ test.out[0].l3_type = out_l3_type;
+ test.out[0].l4_type = ODP_PROTO_L4_TYPE_ESP;
test_in.num_pkt = 1;
test_in.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4;
@@ -1254,6 +1278,8 @@ static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel)
test_empty.opt.flag.tfc_dummy = 1;
test_empty.opt.tfc_pad_len = 16;
test_empty.num_pkt = 1;
+ test_empty.out[0].l3_type = out_l3_type;
+ test_empty.out[0].l4_type = ODP_PROTO_L4_TYPE_ESP;
ipsec_check_out_in_one(&test, &test_in, sa, sa2);
ipsec_check_out_in_one(&test_empty, &test_in, sa, sa2);
@@ -1431,7 +1457,7 @@ static void test_sa_info(void)
{ .status.warn.all = 0,
.status.error.all = 0,
.l3_type = ODP_PROTO_L3_TYPE_IPV4,
- .l4_type = ODP_PROTO_L4_TYPE_ICMPV4,
+ .l4_type = ODP_PROTO_L4_TYPE_ESP,
},
},
};
@@ -1644,7 +1670,7 @@ static void test_max_num_sa(void)
{ .status.warn.all = 0,
.status.error.all = 0,
.l3_type = ODP_PROTO_L3_TYPE_IPV4,
- .l4_type = ODP_PROTO_L4_TYPE_ICMPV4,
+ .l4_type = ODP_PROTO_L4_TYPE_ESP,
},
},
};