aboutsummaryrefslogtreecommitdiff
path: root/test/validation
diff options
context:
space:
mode:
authorAnoob Joseph <anoobj@marvell.com>2021-10-06 11:29:01 +0000
committerPetri Savolainen <petri.savolainen@nokia.com>2021-10-11 09:46:19 +0300
commit95c4e73efaa09a332bedc8b793a70af212896cf8 (patch)
treef350b3bbee682c2d524c2a6dfac892d1edc52a9c /test/validation
parentda72b9fbbec5bc68a6dbedfcead2742d3c63c00e (diff)
validation: ipsec: update orig IP len to cover reassembly cases
In case of successful reassembly tests, the original IP length would be the aggregate of IP lengths of all individual fragments. Update the test framework to have a field 'orig_ip_len' to be able to cover cases when expected len differs from that of the input test packet available with 'ipsec_test_part'. Signed-off-by: Anoob Joseph <anoobj@marvell.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'test/validation')
-rw-r--r--test/validation/api/ipsec/ipsec.c7
-rw-r--r--test/validation/api/ipsec/ipsec.h5
-rw-r--r--test/validation/api/ipsec/ipsec_test_in.c17
3 files changed, 28 insertions, 1 deletions
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 5453bb8f6..d458c257f 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -949,7 +949,12 @@ static void verify_in(const ipsec_test_part *part,
CU_ASSERT_EQUAL(IPSEC_SA_CTX,
odp_ipsec_sa_context(sa));
if (suite_context.inbound_op_mode != ODP_IPSEC_OP_MODE_SYNC) {
- uint32_t len = part->pkt_in->len - part->pkt_in->l3_offset;
+ uint32_t len;
+
+ if (part->out[i].orig_ip_len)
+ len = part->out[i].orig_ip_len;
+ else
+ len = part->pkt_in->len - part->pkt_in->l3_offset;
CU_ASSERT(result.orig_ip_len == 0 ||
result.orig_ip_len == len);
diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h
index 6edce03d0..c136f9fd6 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -96,6 +96,11 @@ typedef struct {
odp_proto_l3_type_t l3_type;
odp_proto_l4_type_t l4_type;
uint32_t seq_num;
+ /*
+ * Expected original IP length. Non zero only when expected len
+ * differs from that of input test packet (pkt_in).
+ */
+ uint32_t orig_ip_len;
} out[MAX_FRAGS];
} ipsec_test_part;
diff --git a/test/validation/api/ipsec/ipsec_test_in.c b/test/validation/api/ipsec/ipsec_test_in.c
index bcdcd4e83..fb3d0221e 100644
--- a/test/validation/api/ipsec/ipsec_test_in.c
+++ b/test/validation/api/ipsec/ipsec_test_in.c
@@ -1777,6 +1777,7 @@ static void test_multi_out_in(odp_ipsec_sa_t out_sa,
{
uint8_t ver_ihl = result_packet->data[result_packet->l3_offset];
odp_bool_t is_result_ipv6 = (ODPH_IPV4HDR_VER(ver_ihl) == ODPH_IPV6);
+ uint32_t orig_ip_len = 0;
int i;
for (i = 0; i < num_input_packets; i++) {
@@ -1784,6 +1785,7 @@ static void test_multi_out_in(odp_ipsec_sa_t out_sa,
ipsec_test_part test_in;
ipsec_test_packet test_pkt;
odp_packet_t pkt = ODP_PACKET_INVALID;
+ uint32_t l3_off, pkt_len;
/*
* Convert plain text packet to IPsec packet through
@@ -1798,11 +1800,26 @@ static void test_multi_out_in(odp_ipsec_sa_t out_sa,
* Expect result packet only for the last packet.
*/
memset(&test_in, 0, sizeof(test_in));
+
+ /*
+ * In case of complete reassembly, the original IP length is the
+ * sum of IP lengths of the ESP packets that contained the
+ * individual fragments.
+ */
+ if (reass_status == ODP_PACKET_REASS_COMPLETE) {
+ pkt_len = odp_packet_len(pkt);
+ l3_off = odp_packet_l3_offset(pkt);
+ CU_ASSERT(ODP_PACKET_OFFSET_INVALID != l3_off)
+
+ orig_ip_len += pkt_len - l3_off;
+ }
+
if (i == num_input_packets - 1) {
part_prep_plain(&test_in, 1, is_result_ipv6, true);
test_in.out[0].pkt_res = result_packet;
test_in.out[0].reass_status = reass_status;
test_in.out[0].num_frags = num_input_packets;
+ test_in.out[0].orig_ip_len = orig_ip_len;
}
ipsec_test_packet_from_pkt(&test_pkt, &pkt);
test_in.pkt_in = &test_pkt;