diff options
author | Janne Peltonen <janne.peltonen@nokia.com> | 2021-03-27 11:58:24 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-04-01 15:02:59 +0300 |
commit | 1cff5a434422db01eabe43e020e443619a3f3082 (patch) | |
tree | 56fa6c88f9559ef5490ebc5feffbe53235d92a01 /test/validation/api | |
parent | be429f2f63c0ab746d1e7e5635e9056ac30d6b71 (diff) |
validation: ipsec: reduce code duplication in TFC tests
Combine the common part of the two dummy TFC packet tunneling tests.
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_test_out.c | 83 |
1 files changed, 18 insertions, 65 deletions
diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index 5bc6b7a16..1c7f55bf0 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -1132,27 +1132,18 @@ static void test_out_ipv6_esp_udp_null_sha256(void) ipsec_sa_destroy(sa); } -static void test_out_dummy_esp_null_sha256_tun_ipv4(void) +static void test_out_dummy_esp_null_sha256_tun(odp_ipsec_tunnel_param_t tunnel) { - odp_ipsec_tunnel_param_t tunnel; odp_ipsec_sa_param_t param; odp_ipsec_sa_t sa; odp_ipsec_sa_t sa2; - uint32_t src = IPV4ADDR(10, 0, 111, 2); - uint32_t dst = IPV4ADDR(10, 0, 222, 2); ipsec_test_part test; ipsec_test_part test_empty; memset(&test, 0, sizeof(ipsec_test_part)); memset(&test_empty, 0, sizeof(ipsec_test_part)); - memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t)); - tunnel.type = ODP_IPSEC_TUNNEL_IPV4; - tunnel.ipv4.src_addr = &src; - tunnel.ipv4.dst_addr = &dst; - tunnel.ipv4.ttl = 64; - - /* This test will not work properly inbound inline mode. + /* This test will not work properly in inbound inline mode. * Packet might be dropped and we will not check for that. */ if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) return; @@ -1200,14 +1191,24 @@ static void test_out_dummy_esp_null_sha256_tun_ipv4(void) ipsec_sa_destroy(sa); } +static void test_out_dummy_esp_null_sha256_tun_ipv4(void) +{ + odp_ipsec_tunnel_param_t tunnel; + uint32_t src = IPV4ADDR(10, 0, 111, 2); + uint32_t dst = IPV4ADDR(10, 0, 222, 2); + + memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t)); + tunnel.type = ODP_IPSEC_TUNNEL_IPV4; + tunnel.ipv4.src_addr = &src; + tunnel.ipv4.dst_addr = &dst; + tunnel.ipv4.ttl = 64; + + test_out_dummy_esp_null_sha256_tun(tunnel); +} + static void test_out_dummy_esp_null_sha256_tun_ipv6(void) { odp_ipsec_tunnel_param_t tunnel; - odp_ipsec_sa_param_t param; - odp_ipsec_sa_t sa; - odp_ipsec_sa_t sa2; - ipsec_test_part test; - ipsec_test_part test_empty; uint8_t src[16] = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, @@ -1217,61 +1218,13 @@ static void test_out_dummy_esp_null_sha256_tun_ipv6(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, }; - memset(&test, 0, sizeof(ipsec_test_part)); - memset(&test_empty, 0, sizeof(ipsec_test_part)); - memset(&tunnel, 0, sizeof(odp_ipsec_tunnel_param_t)); tunnel.type = ODP_IPSEC_TUNNEL_IPV6; tunnel.ipv6.src_addr = src; tunnel.ipv6.dst_addr = dst; tunnel.ipv6.hlimit = 64; - /* This test will not work properly inbound inline mode. - * Packet might be dropped and we will not check for that. */ - if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) - return; - - ipsec_sa_param_fill(¶m, - false, false, 123, &tunnel, - ODP_CIPHER_ALG_NULL, NULL, - ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, - NULL, NULL); - - sa = odp_ipsec_sa_create(¶m); - - CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); - - ipsec_sa_param_fill(¶m, - true, false, 123, &tunnel, - ODP_CIPHER_ALG_NULL, NULL, - ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, - NULL, NULL); - - sa2 = odp_ipsec_sa_create(¶m); - - CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa2); - - test.pkt_in = &pkt_test_nodata; - test.num_opt = 1; - test.opt .flag.tfc_dummy = 1; - test.opt.tfc_pad_len = 16; - test.num_pkt = 1; - test.out[0].l3_type = ODP_PROTO_L3_TYPE_IPV4; - test.out[0].l4_type = ODP_PROTO_L4_TYPE_NO_NEXT; - - test_empty.pkt_in = &pkt_test_empty; - test_empty.num_opt = 1; - 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 = ODP_PROTO_L3_TYPE_IPV4; - test_empty.out[0].l4_type = ODP_PROTO_L4_TYPE_NO_NEXT; - - ipsec_check_out_in_one(&test, sa, sa2); - ipsec_check_out_in_one(&test_empty, sa, sa2); - - ipsec_sa_destroy(sa2); - ipsec_sa_destroy(sa); + test_out_dummy_esp_null_sha256_tun(tunnel); } static void test_out_ipv4_udp_esp_null_sha256(void) |