[v2,4/4] app/test: add IP reassembly negative cases

Message ID 20220120164804.4163645-5-gakhil@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series app/test: add inline IPsec and reassembly cases |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/github-robot: build fail github build: failed

Commit Message

Akhil Goyal Jan. 20, 2022, 4:48 p.m. UTC
  test_inline_ipsec testsuite is added with cases where the IP reassembly
is incomplete and software will need to reassemble them later.
The failure cases added are:
- all fragments are not received.
- same fragment is received more than once.
- out of order fragments.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 app/test/test_security_inline_proto.c | 71 +++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
  

Patch

diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c
index d05325b205..b1794c1bc7 100644
--- a/app/test/test_security_inline_proto.c
+++ b/app/test/test_security_inline_proto.c
@@ -1179,6 +1179,68 @@  test_reassembly_ipv6_5frag(void)
 				      RTE_SECURITY_IPSEC_TUNNEL_IPV6);
 }
 
+static int
+test_reassembly_incomplete(void)
+{
+	/* Negative test case, not sending all fragments. */
+	struct reassembly_vector ipv4_incomplete_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f1,
+				.frags[1] = &pkt_ipv4_udp_p2_f2,
+				.nb_frags = 2,
+	};
+	test_vector_payload_populate(&pkt_ipv4_udp_p2, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f1, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f2, false);
+
+	return test_ipsec_encap_decap(&ipv4_incomplete_case,
+				      RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_overlap(void)
+{
+	/* Negative test case, sending 1 fragment twice. */
+	struct reassembly_vector ipv4_overlap_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p1,
+				.frags[0] = &pkt_ipv4_udp_p1_f1,
+				.frags[1] = &pkt_ipv4_udp_p1_f1, /* Overlap */
+				.frags[2] = &pkt_ipv4_udp_p1_f2,
+				.nb_frags = 3,
+	};
+	test_vector_payload_populate(&pkt_ipv4_udp_p2, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f1, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f2, false);
+
+	return test_ipsec_encap_decap(&ipv4_overlap_case,
+				      RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_out_of_order(void)
+{
+	/* Negative test case, out of order fragments. */
+	struct reassembly_vector ipv4_ooo_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f1,
+				.frags[1] = &pkt_ipv4_udp_p2_f3,
+				.frags[2] = &pkt_ipv4_udp_p2_f4,
+				.frags[3] = &pkt_ipv4_udp_p2_f2,
+				.nb_frags = 4,
+	};
+	test_vector_payload_populate(&pkt_ipv4_udp_p2, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f1, true);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f2, false);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f3, false);
+	test_vector_payload_populate(&pkt_ipv4_udp_p2_f4, false);
+
+	return test_ipsec_encap_decap(&ipv4_ooo_case,
+				      RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
 	.setup = testsuite_setup,
@@ -1214,6 +1276,15 @@  static struct unit_test_suite inline_ipsec_testsuite  = {
 		TEST_CASE_ST(ut_setup_inline_ipsec,
 				ut_teardown_inline_ipsec,
 				test_reassembly_ipv6_5frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_incomplete),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_overlap),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_out_of_order),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}