diff mbox series

[API-NEXT,v1,5/11] linux-gen: ipsec: take ipsec_out_opt flags into account

Message ID 1519657209-30140-6-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/11] linux-gen: packet: add odp_packet_l2_type() implementation | expand

Commit Message

Github ODP bot Feb. 26, 2018, 3 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Only override frag_mode if respective flag is set.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 502 (lumag:ipsec-imp-upd)
 ** https://github.com/Linaro/odp/pull/502
 ** Patch: https://github.com/Linaro/odp/pull/502.patch
 ** Base sha: c91eae61d19350dd19aacf18c1148c9491398c14
 ** Merge commit sha: 8c909084626ccef140542645cd34549ce7f4bcde
 **/
 platform/linux-generic/odp_ipsec.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c
index 8c3d6cd63..cfdfa9dc9 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -1296,6 +1296,7 @@  static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
 	int rc;
 	odp_crypto_packet_result_t crypto; /**< Crypto operation result */
 	odp_packet_hdr_t *pkt_hdr;
+	odp_ipsec_frag_mode_t frag_mode;
 	uint32_t mtu;
 
 	state.ip_offset = odp_packet_l3_offset(pkt);
@@ -1307,8 +1308,10 @@  static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt,
 	ipsec_sa = _odp_ipsec_sa_use(sa);
 	ODP_ASSERT(NULL != ipsec_sa);
 
-	if ((opt && opt->frag_mode == ODP_IPSEC_FRAG_CHECK) ||
-	    (!opt && ipsec_sa->out.frag_mode == ODP_IPSEC_FRAG_CHECK))
+	frag_mode = ipsec_sa->out.frag_mode;
+	if (opt->flag.frag_mode)
+		frag_mode = opt->frag_mode;
+	if (frag_mode == ODP_IPSEC_FRAG_CHECK)
 		mtu = ipsec_sa->out.mtu;
 	else
 		mtu = UINT32_MAX;
@@ -1467,6 +1470,8 @@  int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in,
 	return in_pkt;
 }
 
+static odp_ipsec_out_opt_t default_out_opt;
+
 int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
 		  odp_packet_t pkt_out[], int *num_out,
 		  const odp_ipsec_out_param_t *param)
@@ -1495,7 +1500,7 @@  int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in,
 		ODP_ASSERT(ODP_IPSEC_SA_INVALID != sa);
 
 		if (0 == param->num_opt)
-			opt = NULL;
+			opt = &default_out_opt;
 		else
 			opt = &param->opt[opt_idx];
 
@@ -1602,7 +1607,7 @@  int odp_ipsec_out_enq(const odp_packet_t pkt_in[], int num_in,
 		ODP_ASSERT(ODP_IPSEC_SA_INVALID != sa);
 
 		if (0 == param->num_opt)
-			opt = NULL;
+			opt = &default_out_opt;
 		else
 			opt = &param->opt[opt_idx];
 
@@ -1697,7 +1702,7 @@  int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int num_in,
 		}
 
 		if (0 == param->num_opt)
-			opt = NULL;
+			opt = &default_out_opt;
 		else
 			opt = &param->opt[opt_idx];
 
@@ -1801,6 +1806,8 @@  int _odp_ipsec_init_global(void)
 {
 	odp_ipsec_config_init(&ipsec_config);
 
+	memset(&default_out_opt, 0, sizeof(default_out_opt));
+
 	return 0;
 }