diff mbox series

[API-NEXT,v11,14/16] validation: ipsec: fix out inline with NULL pkt_out

Message ID 1513094423-671-15-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v11,1/16] validation: ipsec: add ipv4 name parts | expand

Commit Message

Github ODP bot Dec. 12, 2017, 4 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


pkt_out can be NULL if we expect an error. IPsec outbound inline needs
proper outer header to function. Pass L2 header from inbound packet if
outbound packet is NULL.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@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: 65d690fbcf03c6a4d5eb3f01bde36807833feaaa
 ** Merge commit sha: 2212038b2ceac423819d283ce07106fabe438631
 **/
 test/validation/api/ipsec/ipsec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index 7b39c2c5a..aa46a236e 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -583,10 +583,18 @@  static int ipsec_send_out_one(const ipsec_test_part *part,
 	} else {
 		struct odp_ipsec_out_inline_param_t inline_param;
 		odp_queue_t queue;
-		uint32_t hdr_len = part->out[0].pkt_out->l3_offset;
-		uint8_t hdr[hdr_len];
+		uint32_t hdr_len;
+		uint8_t hdr[32];
 
-		memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+		if (NULL != part->out[0].pkt_out) {
+			hdr_len = part->out[0].pkt_out->l3_offset;
+			CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+			memcpy(hdr, part->out[0].pkt_out->data, hdr_len);
+		} else {
+			hdr_len = part->pkt_in->l3_offset;
+			CU_ASSERT_FATAL(hdr_len <= sizeof(hdr));
+			memcpy(hdr, part->pkt_in->data, hdr_len);
+		}
 		inline_param.pktio = suite_context.pktio;
 		inline_param.outer_hdr.ptr = hdr;
 		inline_param.outer_hdr.len = hdr_len;