From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@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.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: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: f0a7b395adeff8e67fc86f5ee4ed6edfbe3fabaf
 **/
 test/validation/api/ipsec/ipsec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

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;

Reply via email to