diff mbox series

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

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

Commit Message

Github ODP bot Dec. 12, 2017, 11 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: d96a8207591fbcaac25b79286d7d72a537354c1f
 ** Merge commit sha: 832a79461bc8bd90e572c396fa081e162e1dacb6
 **/
 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;