diff mbox series

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

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

Commit Message

Github ODP bot Feb. 27, 2018, 8 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: ce5c4f9e7ce9fe504451c29429b9ae9fb68083ae
 ** Merge commit sha: fcd6960c97fe9a0a399be4f3418ba3dd83134544
 **/
 platform/linux-generic/odp_ipsec.c | 16 +++++++++++-----
 1 file changed, 11 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..3c9d88cc6 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,9 @@  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 = opt->flag.frag_mode ? opt->frag_mode :
+					  ipsec_sa->out.frag_mode;
+	if (frag_mode == ODP_IPSEC_FRAG_CHECK)
 		mtu = ipsec_sa->out.mtu;
 	else
 		mtu = UINT32_MAX;
@@ -1467,6 +1469,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 +1499,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 +1606,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 +1701,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 +1805,8 @@  int _odp_ipsec_init_global(void)
 {
 	odp_ipsec_config_init(&ipsec_config);
 
+	memset(&default_out_opt, 0, sizeof(default_out_opt));
+
 	return 0;
 }