From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org>
---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 test/validation/api/ipsec/ipsec.c          |   4 +-
 test/validation/api/ipsec/ipsec.h          |   2 +
 test/validation/api/ipsec/ipsec_test_out.c | 194 +++++++++++++++++++++++++++++
 3 files changed, 198 insertions(+), 2 deletions(-)

diff --git a/test/validation/api/ipsec/ipsec.c 
b/test/validation/api/ipsec/ipsec.c
index aa46a236e..097216730 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -556,8 +556,8 @@ static int ipsec_send_out_one(const ipsec_test_part *part,
        memset(&param, 0, sizeof(param));
        param.num_sa = 1;
        param.sa = &sa;
-       param.num_opt = 0;
-       param.opt = NULL;
+       param.num_opt = part->num_opt;
+       param.opt = &part->opt;
 
        if (ODP_IPSEC_OP_MODE_SYNC == suite_context.outbound_op_mode) {
                CU_ASSERT_EQUAL(part->out_pkt, odp_ipsec_out(&pkt, 1,
diff --git a/test/validation/api/ipsec/ipsec.h 
b/test/validation/api/ipsec/ipsec.h
index 9a24dd38c..f2ebd388c 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -45,6 +45,8 @@ typedef struct {
 typedef struct {
        const ipsec_test_packet *pkt_in;
        odp_bool_t lookup;
+       int num_opt;
+       odp_ipsec_out_opt_t opt;
        int out_pkt;
        struct {
                odp_ipsec_op_status_t status;
diff --git a/test/validation/api/ipsec/ipsec_test_out.c 
b/test/validation/api/ipsec/ipsec_test_out.c
index 2ee8a1319..4751e6ec8 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -500,6 +500,192 @@ static void test_out_ipv4_esp_null_aes_gmac_128(void)
        ipsec_sa_destroy(sa);
 }
 
+static void test_out_ipv4_ah_sha256_frag_check(void)
+{
+       odp_ipsec_sa_param_t param;
+       odp_ipsec_sa_t sa;
+
+       ipsec_sa_param_fill(&param,
+                           false, true, 123, NULL,
+                           ODP_CIPHER_ALG_NULL, NULL,
+                           ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
+                           NULL);
+       param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+       param.outbound.mtu = 100;
+
+       sa = odp_ipsec_sa_create(&param);
+
+       CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+       ipsec_test_part test = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.mtu = 1,
+                         .pkt_out = NULL },
+               },
+       };
+
+       ipsec_test_part test2 = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .num_opt = 1,
+               .opt = { .mode = ODP_IPSEC_FRAG_DISABLED, },
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.all = 0,
+                         .pkt_out = &pkt_ipv4_icmp_0_ah_sha256_1 },
+               },
+       };
+
+       ipsec_check_out_one(&test, sa);
+
+       ipsec_check_out_one(&test2, sa);
+
+       ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_ah_sha256_frag_check_2(void)
+{
+       odp_ipsec_sa_param_t param;
+       odp_ipsec_sa_t sa;
+
+       ipsec_sa_param_fill(&param,
+                           false, true, 123, NULL,
+                           ODP_CIPHER_ALG_NULL, NULL,
+                           ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
+                           NULL);
+       param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+       param.outbound.mtu = 100;
+
+       sa = odp_ipsec_sa_create(&param);
+
+       CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+       ipsec_test_part test = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.mtu = 1,
+                         .pkt_out = NULL },
+               },
+       };
+
+       ipsec_test_part test2 = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.all = 0,
+                         .pkt_out = &pkt_ipv4_icmp_0_ah_sha256_1 },
+               },
+       };
+
+       ipsec_check_out_one(&test, sa);
+
+       odp_ipsec_sa_mtu_update(sa, 256);
+
+       ipsec_check_out_one(&test2, sa);
+
+       ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_esp_null_sha256_frag_check(void)
+{
+       odp_ipsec_sa_param_t param;
+       odp_ipsec_sa_t sa;
+
+       ipsec_sa_param_fill(&param,
+                           false, false, 123, NULL,
+                           ODP_CIPHER_ALG_NULL, NULL,
+                           ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
+                           NULL);
+
+       param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+       param.outbound.mtu = 100;
+
+       sa = odp_ipsec_sa_create(&param);
+
+       CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+       ipsec_test_part test = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.mtu = 1,
+                         .pkt_out = NULL },
+               },
+       };
+
+       ipsec_test_part test2 = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .num_opt = 1,
+               .opt = { .mode = ODP_IPSEC_FRAG_DISABLED, },
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.all = 0,
+                         .pkt_out = &pkt_ipv4_icmp_0_esp_null_sha256_1 },
+               },
+       };
+
+       ipsec_check_out_one(&test, sa);
+
+       ipsec_check_out_one(&test2, sa);
+
+       ipsec_sa_destroy(sa);
+}
+
+static void test_out_ipv4_esp_null_sha256_frag_check_2(void)
+{
+       odp_ipsec_sa_param_t param;
+       odp_ipsec_sa_t sa;
+
+       ipsec_sa_param_fill(&param,
+                           false, false, 123, NULL,
+                           ODP_CIPHER_ALG_NULL, NULL,
+                           ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256,
+                           NULL);
+
+       param.outbound.frag_mode = ODP_IPSEC_FRAG_CHECK;
+       param.outbound.mtu = 100;
+
+       sa = odp_ipsec_sa_create(&param);
+
+       CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa);
+
+       ipsec_test_part test = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.mtu = 1,
+                         .pkt_out = NULL },
+               },
+       };
+
+       ipsec_test_part test2 = {
+               .pkt_in = &pkt_ipv4_icmp_0,
+               .out_pkt = 1,
+               .out = {
+                       { .status.warn.all = 0,
+                         .status.error.all = 0,
+                         .pkt_out = &pkt_ipv4_icmp_0_esp_null_sha256_1 },
+               },
+       };
+
+       ipsec_check_out_one(&test, sa);
+
+       odp_ipsec_sa_mtu_update(sa, 256);
+
+       ipsec_check_out_one(&test2, sa);
+
+       ipsec_sa_destroy(sa);
+}
+
 static void test_out_ipv6_ah_sha256(void)
 {
        odp_ipsec_sa_param_t param;
@@ -792,6 +978,14 @@ odp_testinfo_t ipsec_out_suite[] = {
                                  ipsec_check_ah_aes_gmac_128),
        ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_aes_gmac_128,
                                  ipsec_check_esp_null_aes_gmac_128),
+       ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check,
+                                 ipsec_check_ah_sha256),
+       ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check_2,
+                                 ipsec_check_ah_sha256),
+       ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_sha256_frag_check,
+                                 ipsec_check_esp_null_sha256),
+       ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_sha256_frag_check_2,
+                                 ipsec_check_esp_null_sha256),
        ODP_TEST_INFO_CONDITIONAL(test_out_ipv6_ah_sha256,
                                  ipsec_check_ah_sha256),
        ODP_TEST_INFO_CONDITIONAL(test_out_ipv6_ah_sha256_tun_ipv4,

Reply via email to