diff options
author | Janne Peltonen <janne.peltonen@nokia.com> | 2021-03-27 11:58:12 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-04-01 15:02:59 +0300 |
commit | 6bbda08633477970b25c227bacd31ecf0ed2c946 (patch) | |
tree | 3ec2fb499ee7ddd3191ae2b67e2843b88af249b7 /test/validation/api | |
parent | 3b8ce4a6a6d6de8b0a025e815152b0cfb139dc9e (diff) |
validation: ipsec: do not assume that l4 offset is always set
Fix the incorrect assumption that l4 offset is set in the output
packets of odp_ipsec_out() and odp_ipsec_out_enq(). Parse the output
packets to set the l4 offset.
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.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index f36ca5769..d8d905a49 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -910,6 +910,31 @@ void ipsec_check_in_one(const ipsec_test_part *part, odp_ipsec_sa_t sa) } } +static void parse_ip(odp_packet_t pkt) +{ + uint8_t *ver_ihl; + odp_proto_t proto = ODP_PROTO_NONE; + uint32_t l3 = odp_packet_l3_offset(pkt); + + ver_ihl = odp_packet_l3_ptr(pkt, NULL); + if ((*ver_ihl >> 4) == 4) + proto = ODP_PROTO_IPV4; + else if ((*ver_ihl >> 4) == 6) + proto = ODP_PROTO_IPV6; + else + CU_FAIL("Invalid IP version"); + + odp_packet_parse_param_t param = { + .proto = proto, + .last_layer = ODP_PROTO_LAYER_L4, + }; + /* + * odp_packet_parse() is buggy in linux generic ODP. Intentionally + * ignore the return value until the bug has been fixed. + */ + (void)odp_packet_parse(pkt, l3, ¶m); +} + void ipsec_check_out_one(const ipsec_test_part *part, odp_ipsec_sa_t sa) { int num_out = part->num_pkt; @@ -943,6 +968,9 @@ void ipsec_check_out_one(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)); + + /* Parse the packet to set L4 offset and type */ + parse_ip(pkto[i]); } ipsec_check_packet(part->out[i].pkt_res, pkto[i], |