diff mbox series

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

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

Commit Message

Github ODP bot Nov. 30, 2017, 1 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: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 6f6906b608f0626d119b255b3733a4a0863aa8d1
 **/
 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;