Skip to contentSkip to conversation

examples/ipsec-secgw: add fallback session

PATCH Superseded Marcin Smoczynski 7 participants 67 messages Aug 14, 2019 – Nov 5, 2019

lore
Share & tools
lore
#0 lore raw

cover examples/ipsec-secgw: add fallback session

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

Marcin Smoczynski (2):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature

 doc/guides/sample_app_ug/ipsec_secgw.rst |  17 ++-
 examples/ipsec-secgw/esp.c               |  35 ++++--
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++-
 examples/ipsec-secgw/ipsec.c             |  99 ++++++++-------
 examples/ipsec-secgw/ipsec.h             |  61 +++++++--
 examples/ipsec-secgw/ipsec_process.c     | 113 ++++++++++-------
 examples/ipsec-secgw/sa.c                | 153 +++++++++++++++++------
 7 files changed, 334 insertions(+), 160 deletions(-)

--
2.17.1

#1 lore raw

PATCH 1/2 examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst | 17 +++-
 examples/ipsec-secgw/esp.c               |  4 +-
 examples/ipsec-secgw/ipsec-secgw.c       | 16 ++--
 examples/ipsec-secgw/ipsec.c             | 10 +--
 examples/ipsec-secgw/ipsec.h             | 40 ++++++++--
 examples/ipsec-secgw/ipsec_process.c     | 85 +++++++++++++-------
 examples/ipsec-secgw/sa.c                | 99 ++++++++++++++++++++----
 7 files changed, 210 insertions(+), 61 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +16 -1
index ad2d79e75..9ded5fb70 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,21 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for packets that inline processor failed to process.
+
+ * Optional: Yes, by default there is *no fallback* session type.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol offload to HW accelerator
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +86 -13

206 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

v2 cover examples/ipsec-secgw: add fallback session

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
Signature · 1 line
2.21.0.windows.1
#4 lore raw

PATCH v2 1/3 examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
#5 lore raw

PATCH v2 2/3 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  17 +++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +--
 examples/ipsec-secgw/ipsec.h             |  40 +++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 ++++++++++++------
 examples/ipsec-secgw/sa.c                | 110 +++++++++++++++++++----
 7 files changed, 218 insertions(+), 64 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +16 -1
index ad2d79e75..9ded5fb70 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,21 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for packets that inline processor failed to process.
+
+ * Optional: Yes, by default there is *no fallback* session type.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol offload to HW accelerator
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +94 -16

235 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
#6 lore raw

PATCH v2 3/3 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.21.0.windows.1
#7 lore raw
In reply to Marcin Smoczynski

Hi Marcin,

Sorry for the late response. But how do you plan to handle "inline protocol" processed packets?

Thanks,
Anoob

Quoted 47 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped.
A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#8 lore raw

Hi Anoob,

Quoted 4 lines

Hi Marcin,

Sorry for the late response. But how do you plan to handle "inline protocol" processed packets?

Right now that feature is supported for "inline crypto" only. For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.). Konstantin

Quoted 51 lines

Thanks,
Anoob

Quoted 47 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped.
A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#9 lore raw

Hi Konstantin,

Please see inline.

Thanks,
Anoob

Quoted 15 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Wednesday, September 18, 2019 2:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Narayana Prasad Raju Athreya <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Hi Anoob,

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Hi Marcin,

Sorry for the late response. But how do you plan to handle "inline protocol"

processed packets?

Right now that feature is supported for "inline crypto" only.

[Anoob] The description says "inline processed" packets. Hence the confusion.

Quoted 3 lines

For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.).

[Anoob] In case of inline ipsec processing, the ipsec state (which would track sequence number etc) will be internal to the PMDs. So anti-replay/ESN would have to be done either in the h/w or PMD. This would mean application will not have state information regarding ipsec processing. Hence fallback handling with the above scheme will not work in that case.

To address this properly for inline protocol, we will have to come up with some logic to share session private data b/w "eligible" PMDs. This would involve library changes to rte_security, etc. Once that is proposed, there will be one kind of handling for inline protocol processing and another kind for inline crypto processing. Would you be fine with that?

Quoted 54 lines

Konstantin

Quoted 52 lines

Thanks,
Anoob

Quoted 48 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create mode
100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#10 lore raw

Hi Anoob,

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Sorry for the late response. But how do you plan to handle "inline protocol"

processed packets?

Right now that feature is supported for "inline crypto" only.

[Anoob] The description says "inline processed" packets. Hence the confusion.

Quoted 7 lines
Quoted 3 lines

For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.).

[Anoob] In case of inline ipsec processing, the ipsec state (which would track sequence number etc) will be internal to the PMDs. So anti- replay/ESN would have to be done either in the h/w or PMD. This would mean application will not have state information regarding ipsec processing. Hence fallback handling with the above scheme will not work in that case.

Agree, that's why I wrote above that current wok might work for inline-proto *only* if replay window and ESN is disabled.

Quoted 3 lines

To address this properly for inline protocol, we will have to come up with some logic to share session private data b/w "eligible" PMDs. This would involve library changes to rte_security, etc.

Again, totally agree.
As I remember we already discussed it about a year ago, but didn't come up with any concrete proposal.

Quoted 2 lines

Once that is proposed, there will be one kind of handling for inline protocol processing and another kind for inline crypto processing. Would you be fine with that?

For sure something needs to be changed for inline-proto to sync replay-window/ESN related data between HW/PMD and SW.
What it should be - new function, or something else - hard to tell right now. Konstantin

Quoted 55 lines
Quoted 55 lines

Konstantin

Quoted 52 lines

Thanks,
Anoob

Quoted 48 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create mode
100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#11 lore raw

Hi Konstantin,

Please see inline.

Thanks,
Anoob

Quoted 27 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, September 19, 2019 3:49 AM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Narayana Prasad Raju Athreya <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Hi Anoob,

Quoted 1 line
Quoted 1 line
Quoted 1 line

Sorry for the late response. But how do you plan to handle "inline

protocol"

Quoted 10 lines
Quoted 3 lines

processed packets?

Right now that feature is supported for "inline crypto" only.

[Anoob] The description says "inline processed" packets. Hence the confusion.

Quoted 3 lines

For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.).

Quoted 8 lines
Quoted 3 lines

[Anoob] In case of inline ipsec processing, the ipsec state (which would track sequence number etc) will be internal to the PMDs. So anti- replay/ESN would have to be done either in the h/w or PMD. This would

mean application will not have state information regarding ipsec processing. Hence fallback handling with the above scheme will not work in that case.

Agree, that's why I wrote above that current wok might work for inline-proto *only* if replay window and ESN is disabled.

[Anoob] Any feature that makes use of protocol "state" would fail with this scheme. In case of inline ipsec, that is anti-replay & ESN. I see that you are not planning for fallback session for outbound. If at all that is planned, this scheme will fail to co-ordinate sequence number between original and fallback sessions.

Quoted 10 lines
Quoted 4 lines

To address this properly for inline protocol, we will have to come up with some logic to share session private data b/w "eligible" PMDs. This would

involve library changes to rte_security, etc.

Again, totally agree.
As I remember we already discussed it about a year ago, but didn't come up with any concrete proposal.

Quoted 7 lines
Quoted 2 lines

Once that is proposed, there will be one kind of handling for inline protocol processing and another kind for inline crypto processing. Would you

be fine with that?

For sure something needs to be changed for inline-proto to sync replay- window/ESN related data between HW/PMD and SW.
What it should be - new function, or something else - hard to tell right now.

[Anoob] No disagreement. My only concern is the incompleteness of this solution. We will have to propose a totally new scheme for inline protocol. You do agree that this approach will not help inline protocol offloading, right? If you are okay with having different solutions for inline crypto & inline protocol, I don't have any issue with this series.

Also, how do you plan to pass "state" info to lookaside protocol session? That will be required to handle ESN/anti-replay in lookaside protocol capable PMD as well.

Quoted 60 lines

Konstantin

Quoted 16 lines
Quoted 16 lines

Konstantin

Quoted 13 lines

Thanks,
Anoob

Quoted 9 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is

dropped.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create

mode
100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs .sh create mode 100644 examples/ipsec- secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#12 lore raw

Hi Anoob,

Quoted 18 lines
Quoted 18 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Sorry for the late response. But how do you plan to handle "inline

protocol"

Quoted 6 lines
Quoted 3 lines

processed packets?

Right now that feature is supported for "inline crypto" only.

[Anoob] The description says "inline processed" packets. Hence the confusion.

Quoted 7 lines
Quoted 3 lines

For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.).

[Anoob] In case of inline ipsec processing, the ipsec state (which would track sequence number etc) will be internal to the PMDs. So anti- replay/ESN would have to be done either in the h/w or PMD. This would

mean application will not have state information regarding ipsec processing. Hence fallback handling with the above scheme will not work in that case.

Quoted 6 lines
Quoted 2 lines

Agree, that's why I wrote above that current wok might work for inline-proto *only* if replay window and ESN is disabled.

[Anoob] Any feature that makes use of protocol "state" would fail with this scheme. In case of inline ipsec, that is anti-replay & ESN. I see that you are not planning for fallback session for outbound. If at all that is planned, this scheme will fail to co-ordinate sequence number between original and fallback sessions.

Right now we don't do outbound fallback sessions.
Again, similar scheme would work for TX with lookaside-none and inline-crypto, but not for inline/lookaside-proto. Of course few extra changes would be needed - move fragmentation before ipsec processing part.

Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

To address this properly for inline protocol, we will have to come up with some logic to share session private data b/w "eligible" PMDs. This would

involve library changes to rte_security, etc.

Again, totally agree.
As I remember we already discussed it about a year ago, but didn't come up with any concrete proposal.

Quoted 2 lines

Once that is proposed, there will be one kind of handling for inline protocol processing and another kind for inline crypto processing. Would you

be fine with that?

Quoted 7 lines
Quoted 3 lines

For sure something needs to be changed for inline-proto to sync replay- window/ESN related data between HW/PMD and SW.
What it should be - new function, or something else - hard to tell right now.

[Anoob] No disagreement. My only concern is the incompleteness of this solution. We will have to propose a totally new scheme for inline
protocol.

Sure, looking forward for it.
In fact, I asked these questions a year ago but as I said before there was no progress on that.

Quoted 1 line

You do agree that this approach will not help inline protocol offloading, right?

Yes, see above.

Quoted 5 lines

If you are okay with having different solutions for
inline crypto & inline protocol, I don't have any issue with this series.

Also, how do you plan to pass "state" info to lookaside protocol session? That will be required to handle ESN/anti-replay in lookaside protocol capable PMD as well.

Obviously there is no such API for any *-proto devices, see above.
Not sure why do you keep repeating it, I already agreed with you, see above :) Just to summarize:
1. Yes I think for lookaiside/iniline-proto devices there is a need for some extra API to sync session state between HW and SW.
Right now, I don't have a clear idea how exactly it should look like.
2. Intel team doesn't plan to work on this API right now.
3. I am happy to review with what you guys will come-up with and provide my feedback. Hope that makes things clear.
Konstantin

Quoted 61 lines
Quoted 61 lines

Konstantin

Quoted 16 lines
Quoted 16 lines

Konstantin

Quoted 13 lines

Thanks,
Anoob

Quoted 9 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is

dropped.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be dropped. A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)  create

mode
100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs .sh create mode 100644 examples/ipsec- secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#13 lore raw

Hi Konstantin,

Please see inline.

Thanks,
Anoob

Quoted 42 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, September 19, 2019 1:04 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Narayana Prasad Raju Athreya <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Hi Anoob,

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Sorry for the late response. But how do you plan to handle "inline

protocol"

Quoted 5 lines
Quoted 3 lines

processed packets?

Right now that feature is supported for "inline crypto" only.

[Anoob] The description says "inline processed" packets. Hence the

confusion.

Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines

For the case when SA doesn't enable replay window and/or ESN current patch should also work for "inline proto" too, but this is just my understanding (not tested, etc.).

[Anoob] In case of inline ipsec processing, the ipsec state (which would track sequence number etc) will be internal to the PMDs. So anti- replay/ESN would have to be done either in the h/w or PMD. This would

mean application will not have state information regarding ipsec processing. Hence fallback handling with the above scheme will not work in that case.

Quoted 7 lines
Quoted 3 lines

Agree, that's why I wrote above that current wok might work for inline-proto
*only* if replay window and ESN is disabled.

[Anoob] Any feature that makes use of protocol "state" would fail with this scheme. In case of inline ipsec, that is anti-replay & ESN. I see that you are not planning for fallback session for outbound. If at all that is

Quoted 8 lines

planned, this scheme will fail to co-ordinate sequence number between original and fallback sessions.

Right now we don't do outbound fallback sessions.
Again, similar scheme would work for TX with lookaside-none and inline-crypto, but not for inline/lookaside-proto.
Of course few extra changes would be needed - move fragmentation before ipsec processing part.

[Anoob] Understood.

Quoted 41 lines
Quoted 16 lines
Quoted 16 lines
Quoted 7 lines

To address this properly for inline protocol, we will have to come up with some logic to share session private data b/w "eligible" PMDs. This would

involve library changes to rte_security, etc.

Again, totally agree.
As I remember we already discussed it about a year ago, but didn't come up with any concrete proposal.

Quoted 3 lines

Once that is proposed, there will be one kind of handling for inline protocol processing and another kind for inline crypto processing. Would you

Quoted 7 lines
Quoted 5 lines

be fine with that?

For sure something needs to be changed for inline-proto to sync replay- window/ESN related data between HW/PMD and SW.
What it should be - new function, or something else - hard to tell right now.

[Anoob] No disagreement. My only concern is the incompleteness of this

solution.

Quoted 1 line

We will have to propose a totally new scheme for inline protocol.

Sure, looking forward for it.
In fact, I asked these questions a year ago but as I said before there was no progress on that.

Quoted 1 line

You do agree that this approach will not help inline protocol offloading, right?

Yes, see above.

Quoted 5 lines

If you are okay with having different solutions for inline crypto & inline protocol, I don't have any issue with this series.

Also, how do you plan to pass "state" info to lookaside protocol session? That will be required to handle ESN/anti-replay in lookaside protocol

capable PMD as well.

Quoted 11 lines

Obviously there is no such API for any *-proto devices, see above. Not sure why do you keep repeating it, I already agreed with you, see above :) Just to summarize:
1. Yes I think for lookaiside/iniline-proto devices there is a need for some extra API
to sync session state between HW and SW.
Right now, I don't have a clear idea how exactly it should look like.
2. Intel team doesn't plan to work on this API right now.
3. I am happy to review with what you guys will come-up with and provide my feedback.
Hope that makes things clear.

[Anoob] My apologies if the queries seemed repetitive. I guess all my concerns are answered. Please do update the logs (and description) to state limitations regarding protocol offloads. I would suggest using "inline crypto processing" instead of "inline processing" wherever applicable. Also, if lookaside protocol is mentioned, better state that the "protocol state" will have to be maintained by application (or lib ipsec in case of lookaside ipsec offload).

Quoted 66 lines

Konstantin

Quoted 20 lines
Quoted 20 lines

Konstantin

Quoted 17 lines
Quoted 17 lines

Konstantin

Quoted 14 lines

Thanks,
Anoob

Quoted 10 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Wednesday, September 4, 2019 7:47 PM
To: [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] examples/ipsec-secgw: add fallback session

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is

dropped.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Introduce multiple sessions per SA allowing to configure a fallback lookaside session for packets that normally would be

dropped.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines

A fallback session type in the SA configuration by adding 'fallback' with 'lookaside-none' or 'lookaside-protocol' parameter to determine type of session.

Fallback session feature is available only when using librte_ipsec.

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  17 +-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 358 insertions(+), 167 deletions(-)

create mode
100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_ defs .sh create mode 100644 examples/ipsec- secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.21.0.windows.1

#14 lore raw

v3 cover add fallback session

In reply to Marcin Smoczynski

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  20 ++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 361 insertions(+), 167 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#15 lore raw

PATCH v3 1/3 examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by on v3 1/3
#16 lore raw

Re: [dpdk-dev] [PATCH v3 1/3] examples/ipsec-secgw: ipsec_sa structure cleanup

Quoted 18 lines

-----Original Message-----
From: Smoczynski, MarcinX
Sent: Monday, September 23, 2019 12:44 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [PATCH v3 1/3] examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Quoted 5 lines

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---

Quoted 1 line

2.17.1

#17 lore raw

PATCH v3 2/3 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Fallback session feature is not available in the legacy mode.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  20 ++++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +--
 examples/ipsec-secgw/ipsec.h             |  40 +++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 ++++++++++++------
 examples/ipsec-secgw/sa.c                | 110 +++++++++++++++++++----
 7 files changed, 221 insertions(+), 64 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +19 -1
index ad2d79e75..6a39c56ce 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,24 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *lookaside-crypto-offload*
+   and fallback session is *lookaside-none*.
+
+ * Optional: Yes.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol hardware offload
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +94 -16

235 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by on v3 2/3
#18 lore raw

Re: [dpdk-dev] [PATCH v3 2/3] examples/ipsec-secgw: add fallback session feature

Quoted 19 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Quoted 4 lines

Fallback session feature is not available in the legacy mode.

---

Quoted 1 line

2.17.1

#19 lore raw

PATCH v3 3/3 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.17.1
Acked-by on v3 3/3
#20 lore raw

Re: [dpdk-dev] [PATCH v3 3/3] examples/ipsec-secgw: add offload fallback tests

Quoted 11 lines

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---

Quoted 1 line

2.17.1

#21 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

In reply to Marcin Smoczynski

Joseph, is this patchset ok with you after changes? I've changed second patch description and sample application documentation regarding this feature.

Quoted 48 lines

-----Original Message-----
From: Smoczynski, MarcinX
Sent: Monday, September 23, 2019 1:44 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [PATCH v3 0/3] add fallback session

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  20 ++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 361 insertions(+), 167 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#22 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

In reply to Marcin Smoczynski

Hi Marcin, Konstantin,

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation. Also, since the fallback feature is entirely done in the application, it begs the question why the same feature is omitted for legacy use case.

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed something,

       a. Application receives a bunch of packets (let's say 6 packets), in which few are fragmented (P3 & P4) and the rest can be inline processed.
       b. Application receives P1->P2->P3->P4->P5->P6 (in this, P1, P2, P5, P6 are inline processed successfully) and P4 & P5 are the fragments
       c. Application groups packets. P1->P2->P5->P6 becomes one group and P3->P4 becomes another and goes for fallback processing.

Now how is ordering maintained? I couldn't figure out how that is done in this case.

Thanks,
Anoob

Quoted 48 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Monday, September 23, 2019 5:14 PM
To: Anoob Joseph <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v3 0/3] add fallback session

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  20 ++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 361 insertions(+), 167 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#23 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,
Answers/comments inline.
Marcin, please correct me, if I missed something.
Konstantin

Quoted 11 lines

Hi Marcin, Konstantin,

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like that:

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6 packets. For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;

}

So from my perspective, no additional lookup where introduced. Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

Quoted 3 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API.
It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper manner.
Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 1 line

Also, since the fallback feature is entirely done in the application, it begs the question why the same feature is omitted for legacy use case.

Because legacy mode doesn't support multi-seg packets at first place.
Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code-path. As a first step we propose to make library code-path a default one:
http://patches.dpdk.org/cover/58247/

Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed something,
a. Application receives a bunch of packets (let's say 6 packets), in which few are fragmented (P3 & P4) and the rest can be inline
processed.

       b. Application receives P1->P2->P3->P4->P5->P6 (in this, P1, P2, P5, P6 are inline processed successfully) and P4 & P5 are the fragments
       c. Application groups packets. P1->P2->P5->P6 becomes one group and P3->P4 becomes another and goes for fallback processing.

Now how is ordering maintained? I couldn't figure out how that is done in this case.

You right, fallback session can introduce packet reordering.
At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://static.sched.com/hosted_files/dpdkbordeaux2019/8f/DPDK-IPSECu9.pdf
Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might cause, etc.

Quoted 52 lines

Thanks,
Anoob

Quoted 48 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Monday, September 23, 2019 5:14 PM
To: Anoob Joseph <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v3 0/3] add fallback session

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  20 ++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 361 insertions(+), 167 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#24 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Konstantin,

Please see inline.

Thanks,
Anoob

Quoted 47 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, September 26, 2019 6:08 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,
Answers/comments inline.
Marcin, please correct me, if I missed something.
Konstantin

Quoted 7 lines

Hi Marcin, Konstantin,

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 4 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like that:

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6 packets. For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

Quoted 6 lines
if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security processing to be done on the packet. "rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can be used.

Quoted 4 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible hardware SA lookup. I don't think what ipsec-secgw does matters here.

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 18 lines
Quoted 4 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API.
It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly).
ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper manner. Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 1 line

Also, since the fallback feature is entirely done in the application, it begs the

Quoted 8 lines

question why the same feature is omitted for legacy use case.

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
http://patches.dpdk.org/cover/58247/

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the fallback packet. In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses the correct session, which I believe should be moved to ipsec library.

Quoted 15 lines
Quoted 4 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 2 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 1 line
       b. Application receives P1->P2->P3->P4->P5->P6 (in this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 3 lines
       c. Application groups packets. P1->P2->P5->P6 becomes one group and P3-

P4 becomes another and goes for fallback processing.
Now how is ordering maintained? I couldn't figure out how that is done in this

case.

Quoted 10 lines

You right, fallback session can introduce packet reordering.
At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://static.sched.com/hosted_files/dpdkbordeaux2019/8f/DPDK-IPSECu9.pdf
Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might cause, etc.

[Anoob] This is something I had noticed while going through the code flow. The ordering info is lost because of the approach. As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the future.

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of rte_ipsec library.

Quoted 54 lines
Quoted 54 lines

Thanks,
Anoob

Quoted 49 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Monday, September 23, 2019 5:14 PM
To: Anoob Joseph <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Marcin Smoczynski <[email protected]>
Subject: [dpdk-dev] [PATCH v3 0/3] add fallback session

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (3):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  20 ++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  16 +-
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 361 insertions(+), 167 deletions(-)  create mode
100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#25 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 33 lines
Quoted 33 lines
Quoted 4 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 4 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like that:

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6 packets. For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }
Quoted 5 lines
Quoted 1 line

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security processing to be done on the packet. "rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can be used.

Right now it is not the case with ipsec-secgw:
for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above).
So, I still not see any additional lookups introduced with the patch.

Quoted 8 lines
Quoted 5 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible hardware SA lookup. I don't think what ipsec-secgw does matters here.

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above. Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux *before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones. Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure. In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before that. So I still believe we are ok here.

Quoted 32 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 18 lines
Quoted 4 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API.
It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly).
ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper manner. Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 1 line

Also, since the fallback feature is entirely done in the application, it begs the

Quoted 8 lines

question why the same feature is omitted for legacy use case.

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
http://patches.dpdk.org/cover/58247/

Quoted 2 lines

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the fallback packet.

I think there is some sort of misunderstanding here.
With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral)
rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 2 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage model. I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC for it.

Quoted 27 lines
Quoted 16 lines
Quoted 5 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 2 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 1 line
       b. Application receives P1->P2->P3->P4->P5->P6 (in this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 3 lines
       c. Application groups packets. P1->P2->P5->P6 becomes one group and P3-

P4 becomes another and goes for fallback processing.
Now how is ordering maintained? I couldn't figure out how that is done in this

case.

Quoted 10 lines

You right, fallback session can introduce packet reordering.
At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://static.sched.com/hosted_files/dpdkbordeaux2019/8f/DPDK-IPSECu9.pdf
Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might cause, etc.

Quoted 1 line

[Anoob] This is something I had noticed while going through the code flow. The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :) It was outlined here:
https://static.sched.com/hosted_files/dpdkbordeaux2019/8f/DPDK-IPSECu9.pdf
And in the latest patch version Marcin clearly stated it inside the AG session:
http://patches.dpdk.org/patch/60039/
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or not.
If/when we'll have CPU_CRYPTO processing mode:
http://patches.dpdk.org/cover/58862/
we'll add ability for the user to avoid this reordering problem

Quoted 2 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such kind of problems.

Quoted 3 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of rte_ipsec library.

#26 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Konstantin,

Please see inline.

Thanks,
Anoob

Quoted 51 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Monday, September 30, 2019 7:01 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

Quoted 8 lines
Quoted 8 lines

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like that:

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 17 lines
Quoted 16 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }

So from my perspective, no additional lookup where introduced.

Quoted 7 lines
Quoted 1 line

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 2 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow with ACTION type as SECURITY is being used to setup h/w lookups.

Quoted 3 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above).
So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about h/w lookups and pass it on to the upper layers, isn't that the better approach?

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux *before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before that.
So I still believe we are ok here.

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be required to do the lookup.

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on the packet. There can be applications which relies on h/w lookup data to figure out the processing done.

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.
Does this approach prevent an application from introducing such a BYPASS? Yes.

Quoted 66 lines
Quoted 5 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 23 lines
Quoted 23 lines
Quoted 6 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper manner. Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 7 lines
Quoted 7 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.dpdk.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 4 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here.
With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 2 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

Quoted 7 lines

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage model. I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC for it.

[Anoob] If you are okay with application defining how it implements ipsec, then probably there is no use case for lib ipsec?

Quoted 41 lines
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in this,

P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6 becomes one

group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

Quoted 7 lines
Quoted 7 lines

case.

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.sched.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 9 lines
Quoted 8 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might cause, etc.

Quoted 4 lines
Quoted 1 line

[Anoob] This is something I had noticed while going through the code flow.

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

My suggestion, if these limitations and the plans to address it were mentioned in the cover letter, we could've saved few cycles here. But my reply would still be the same 😊

Quoted 18 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK- 2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG session:
https://urldefense.proofpoint.com/v2/url?u=http-
3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf Q&r=jPfB8rwwviRSxyLWs2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P- K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ cY&e=
If you think even further clarification within the doc is needed, please let us know.

Quoted 5 lines

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or not.
If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

Also, the ordering is lost because application is not considering that. Why can't we use re-ordering library? Or an event-dev?

Quoted 8 lines

https://urldefense.proofpoint.com/v2/url?u=http-
3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf Q&r=jPfB8rwwviRSxyLWs2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P- K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6 eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 8 lines
Quoted 2 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such kind of problems.

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other possibilities. If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering, assumptions on ESP etc). However, if the patch is introduced directly into ipsec-secgw, it needs to be more comprehensive and robust. I also expect performance impact due to these changes and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

Quoted 6 lines
Quoted 4 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of rte_ipsec library.

#27 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 40 lines
Quoted 40 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

Quoted 8 lines
Quoted 8 lines

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like that:

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 15 lines
Quoted 15 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }
Quoted 3 lines
Quoted 1 line

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet *always* does SW lookup. No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not.
Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
http://lxr.dpdk.org/dpdk/latest/ident/prepare_one_packet
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet.
If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Then it goes into process_pkts_inbound()
http://lxr.dpdk.org/dpdk/latest/ident/process_pkts_inbound
and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
http://lxr.dpdk.org/dpdk/latest/ident/single_inbound_lookup

Quoted 7 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above).
So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about h/w lookups and pass it on to the upper layers, isn't that the better approach?

Please let's keep our conversation in a constructive way.
We are not discussing what could be done in theory, but a particular patch for ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet
(no matter what HW offload does) and this patch doesn't introduce
any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine - feel free to submit RFC/patch to fix that, or start a discussion in a new thread. I just don't see why we have to discuss it in context of this patch.

Quoted 37 lines
Quoted 12 lines
Quoted 10 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux *before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before that.
So I still believe we are ok here.

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be required to do the lookup.

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 6 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on the packet. There can be applications which relies on h/w lookup data to figure out the processing done.

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose BYPASS for such packets. Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes. Correct?
If, so then I said before, I don't think that concern is valid.
Most obvious variant where to add such code is inisde
inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);

- if (iph4->next_proto_id == IPPROTO_ESP)
+ if (iph4->next_proto_id == IPPROTO_ESP) {
+ if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+ /* extract extra info, make decision based on that */
+ } else

			t->ipsec.pkts[(t->ipsec.num)++] = pkt;		

+ }

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(),
either before or straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection code.

Quoted 3 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a BYPASS? Yes.

That's not correct, I believe, see above.

Quoted 69 lines
Quoted 69 lines
Quoted 6 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 23 lines
Quoted 23 lines
Quoted 6 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper manner. Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 7 lines
Quoted 7 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.dpdk.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 4 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here.
With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 2 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

the correct session, which I believe should be moved to ipsec library.

Quoted 7 lines
Quoted 5 lines

From my side it is a good thing to let application define its own usage model. I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC for it.

[Anoob] If you are okay with application defining how it implements ipsec, then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios. As an example: snpritnf() provides user with ability to format strings,
application decides what exactly format to use and for which string.
Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 43 lines
Quoted 43 lines
Quoted 21 lines
Quoted 21 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in this,

P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6 becomes one

group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

Quoted 7 lines
Quoted 7 lines

case.

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.sched.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 10 lines
Quoted 8 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might cause, etc.

[Anoob] This is something I had noticed while going through the code flow.

Quoted 8 lines
Quoted 3 lines

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

My suggestion, if these limitations and the plans to address it were mentioned in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 20 lines

But my reply would still be the same 😊

Quoted 18 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK- 2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG session:
https://urldefense.proofpoint.com/v2/url?u=http-
3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf Q&r=jPfB8rwwviRSxyLWs2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P- K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ cY&e=
If you think even further clarification within the doc is needed, please let us know.

Quoted 7 lines
Quoted 5 lines

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or not.
If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations). In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 2 lines

Also, the ordering is lost because application is not considering that. Why can't we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another.
We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 13 lines
Quoted 13 lines

https://urldefense.proofpoint.com/v2/url?u=http-
3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf Q&r=jPfB8rwwviRSxyLWs2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P- K5XfH8wG- 7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6 eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 2 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

future.

Quoted 7 lines
Quoted 4 lines

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such kind of problems.

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other possibilities.

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 6 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering, assumptions on ESP etc). However, if the patch is introduced directly into ipsec-secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible.
sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation. I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of rte_ipsec library.

#28 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Konstantin,

Following are the main issues I had identified,

1. Doesn't work for inline protocol offload (the plan itself won't scale for that case)
2. Ignores the data from the h/w lookup
3. The fallback support is actually supported in ipsec-secgw (application) instead of librte_ipsec.
4. Reordering issue.
5. Introduces checks in existing data path even when the feature is not properly implemented/is not suitable for other PMDs.

For Issue #1, I get that Intel doesn't have plans to support the feature and won't be submitting anything in that direction. But adding code that further exacerbates the situation is probably not desired.

For Issue #2, since ipsec-secgw is not utilizing the h/w lookup data, the solution here follows suit and is preventing other usage models of the hardware which are allowed by the library.

For Issue #3, librte_ipsec is still experimental and is just 2-3 releases old. It has scope for improvement and all these features would've added value to its utility. No strong feelings here.

For Issue #4, glad that you documented that issue.

For Issue #5, in your reply you had mentioned that there is no additional check done. I see atleast few checks in the datapath. Since the feature itself is experimental, it would be less contentious if it was introduced as a new data path.

Also, to quote from the reply,

Quoted 10 lines
Quoted 1 line

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

If your suggestion is to stick to above guidelines, I don't think there is any point in pushing any further. I leave this to maintainers to decide. I would assume the same rules would apply to every feature that is being attempted.

Thanks,
Anoob

Quoted 516 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 3, 2019 8:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like

that:

Quoted 27 lines
Quoted 27 lines
Quoted 3 lines
Quoted 3 lines

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 15 lines
Quoted 15 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }
Quoted 4 lines
Quoted 1 line

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 3 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

Quoted 6 lines
Quoted 3 lines

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow

with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet *always* does SW lookup.
No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not.
Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_prepare-5Fone- 5Fpacket&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI oSO1i-M&s=opbGGHUqfxy8p_4NvwCG6od6VdV0qN8XafaPiubfO1A&e=
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet.
If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Then it goes into process_pkts_inbound()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_process-5Fpkts- 5Finbound&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Y bgKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0S IoSO1i-M&s=2OxMXug7jtUQPcYiDN4nW9WbrMtRfTJx5k-N7ikOeME&e= and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_single-5Finbound- 5Flookup&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI oSO1i-M&s=D2ZPZPLbcQSbaluG8KH0F3uUDHfQWNYxw4MOc0fSkI8&e=

Quoted 7 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above). So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about

h/w lookups and pass it on to the upper layers, isn't that the better approach?

Please let's keep our conversation in a constructive way.
We are not discussing what could be done in theory, but a particular patch for ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet (no matter what HW offload does) and this patch doesn't introduce any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine - feel free to submit RFC/patch to fix that, or start a discussion in a new thread. I just don't see why we have to discuss it in context of this patch.

Quoted 28 lines
Quoted 13 lines
Quoted 11 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux *before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before that. So I still believe we are ok here.

Quoted 4 lines

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some

issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be required to do the lookup.

Quoted 5 lines

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding

support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 3 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on the packet.

There can be applications which relies on h/w lookup data to figure out the processing done.

Quoted 4 lines

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your

approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose BYPASS for such packets.
Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes.
Correct?
If, so then I said before, I don't think that concern is valid.
Most obvious variant where to add such code is inisde inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);
(quoted diff) +4 -1
-                if (iph4->next_proto_id == IPPROTO_ESP)
+                if (iph4->next_proto_id == IPPROTO_ESP) {
+		if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+			/* extract extra info, make decision based on that */
+		} else
			t->ipsec.pkts[(t->ipsec.num)++] = pkt;
(quoted diff) +1 -0
+	   }

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(), either before or
straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection code.

Quoted 3 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a BYPASS?

Yes.

That's not correct, I believe, see above.

Quoted 15 lines
Quoted 15 lines
Quoted 7 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper

manner.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.dpdk
.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 31 lines
Quoted 31 lines

Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 5 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here. With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines
particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 3 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

Quoted 7 lines
Quoted 7 lines

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage model. I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC

for it.

Quoted 2 lines

[Anoob] If you are okay with application defining how it implements ipsec,

then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios.
As an example: snpritnf() provides user with ability to format strings, application decides what exactly format to use and for which string.
Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
Quoted 21 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in

this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6 becomes

one group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

Quoted 8 lines
Quoted 8 lines

case.

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.sche
d.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might

cause, etc.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

[Anoob] This is something I had noticed while going through the code flow.

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases

were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

Quoted 2 lines

My suggestion, if these limitations and the plans to address it were mentioned

in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 7 lines

But my reply would still be the same 😊

Quoted 5 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 2 lines
Quoted 2 lines

Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E

Quoted 4 lines
Quoted 4 lines

Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG session:
https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ

Quoted 8 lines
Quoted 8 lines

cY&e=
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or

not.

Quoted 3 lines
Quoted 1 line

If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 2 lines

Also, the ordering is lost because application is not considering that. Why can't

we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another.
We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 3 lines
Quoted 3 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6

Quoted 6 lines
Quoted 6 lines

eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 3 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

Quoted 6 lines
Quoted 6 lines

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such

kind of problems.

Quoted 3 lines

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other possibilities.

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 3 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be

the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

Quoted 3 lines

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering,

assumptions on ESP etc). However, if the patch is introduced directly into ipsec- secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible. sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation.
I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of

rte_ipsec library.

Quoted 2 lines
Quoted 2 lines
#29 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 11 lines

Following are the main issues I had identified,

1. Doesn't work for inline protocol offload (the plan itself won't scale for that case)
2. Ignores the data from the h/w lookup
3. The fallback support is actually supported in ipsec-secgw (application) instead of librte_ipsec.
4. Reordering issue.
5. Introduces checks in existing data path even when the feature is not properly implemented/is not suitable for other PMDs.

For Issue #1, I get that Intel doesn't have plans to support the feature and won't be submitting anything in that direction. But adding code that further exacerbates the situation is probably not desired.

We already discussed why that feature can't be fully supported right now by inline-proto/lookaside-proto devices:
There is no API defined to sync session state between HW and SW
http://mails.dpdk.org/archives/dev/2019-September/143881.html

I already outlined that gap nearly a year ago:
http://mails.dpdk.org/archives/dev/2018-September/113600.html
Though so far I didn't see any attempt to resolve this problem by Marvell (or NXP) engineers. Which makes me think that either you guys don't consider it as a problem at all, or have no desire to work on it.
I never insisted, as I don't think it is my call by obvious reasons:
1) right now Intel doesn't have HW that provides inline-proto/lksd-proto capabilities.
2) Intel DPDK team doesn't have access to such HW.
3) There is no PMD inside dpdk.org that implements inline-proto anyway.

Now, one year later we are in a situation where:
1) there still no PMD at dpdk.org that supports inline-proto.
2) API to sync session state between HW and SW still not defined/implemented.
3) you trying to accuse me and other Intel DPDK team for lack of interest to work on that problem for you and threat our patches because of that.

That just doesn't look fair to me.
You shouldn't expect other people patches to provide 'complete' solution for inline-proto, if (in a year time) you failed to define/implement an API for that.

Quoted 2 lines

For Issue #2, since ipsec-secgw is not utilizing the h/w lookup data, the solution here follows suit and is preventing other usage models of the hardware which are allowed by the library.

Same as above, right now there is no PMD that supports inline-proto and no API to extract that extra H/W lookup data. Though I replied to you and explained *twice*how I think such functionality could be added if
in hypothetical future there would be a PMD that will support these features.
But you simply ignored my replies and kept threating our patches.
Obviously, I don't think it is a proper attitude for open-source community.
At least I would expect to provide some clear explanation,
why do you think approach I outlined is not good enough.
Even better would be to:
1) submit an RFC/patch with API you envision and PMD implementation for it.
2) submit an RFC/patch with changes in ipsec-secgw to enable these new features.
Without that in place there is not much to discuss.

Quoted 7 lines

For Issue #3, librte_ipsec is still experimental and is just 2-3 releases old. It has scope for improvement and all these features would've added value to its utility. No strong feelings here.

For Issue #4, glad that you documented that issue.

For Issue #5, in your reply you had mentioned that there is no additional check done. I see atleast few checks in the datapath. Since the feature itself is experimental, it would be less contentious if it was introduced as a new data path.

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

Quoted 14 lines

Also, to quote from the reply,

Quoted 10 lines
Quoted 1 line

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 1 line

If your suggestion is to stick to above guidelines,

It is not my suggestion, that's how things work within DPDK right now. Nearly every dpdk library, driver and sample app was developed based on that principle. Even ipsec-secgw itself, just look at the git log for it.

Quoted 2 lines

I don't think there is any point in pushing any further. I leave this to maintainers to decide. I would assume the same rules would apply to every feature that is being attempted.

I believe that for #1, #2, #5 your comments are biased, and doesn't provide real picture. So my suggestion to maintainers would be to ignore them as not valuable.

Konstantin

Quoted 520 lines

Thanks,
Anoob

Quoted 516 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 3, 2019 8:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security processed.

Not sure I understood your whole statement above.
AFAIK, right now (with dpdk master) for unprotected iface it works like

that:

Quoted 27 lines
Quoted 27 lines
Quoted 3 lines
Quoted 3 lines

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 15 lines
Quoted 15 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found SA

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it (by some reason)? If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }
Quoted 4 lines
Quoted 1 line

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 3 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

Quoted 6 lines
Quoted 3 lines

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow

with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet *always* does SW lookup.
No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not.
Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_prepare-5Fone- 5Fpacket&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI oSO1i-M&s=opbGGHUqfxy8p_4NvwCG6od6VdV0qN8XafaPiubfO1A&e=
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet.
If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Then it goes into process_pkts_inbound()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_process-5Fpkts- 5Finbound&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Y bgKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0S IoSO1i-M&s=2OxMXug7jtUQPcYiDN4nW9WbrMtRfTJx5k-N7ikOeME&e= and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_single-5Finbound- 5Flookup&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI oSO1i-M&s=D2ZPZPLbcQSbaluG8KH0F3uUDHfQWNYxw4MOc0fSkI8&e=

Quoted 7 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above). So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about

h/w lookups and pass it on to the upper layers, isn't that the better approach?

Please let's keep our conversation in a constructive way.
We are not discussing what could be done in theory, but a particular patch for ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet (no matter what HW offload does) and this patch doesn't introduce any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine - feel free to submit RFC/patch to fix that, or start a discussion in a new thread. I just don't see why we have to discuss it in context of this patch.

Quoted 28 lines
Quoted 13 lines
Quoted 11 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux *before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before that. So I still believe we are ok here.

Quoted 4 lines

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some

issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be required to do the lookup.

Quoted 5 lines

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding

support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 3 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on the packet.

There can be applications which relies on h/w lookup data to figure out the processing done.

Quoted 4 lines

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your

approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose BYPASS for such packets.
Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes.
Correct?
If, so then I said before, I don't think that concern is valid.
Most obvious variant where to add such code is inisde inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);
(quoted diff) +4 -1
-                if (iph4->next_proto_id == IPPROTO_ESP)
+                if (iph4->next_proto_id == IPPROTO_ESP) {
+		if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+			/* extract extra info, make decision based on that */
+		} else
			t->ipsec.pkts[(t->ipsec.num)++] = pkt;
(quoted diff) +1 -0
+	   }

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(), either before or
straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection code.

Quoted 3 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a BYPASS?

Yes.

That's not correct, I believe, see above.

Quoted 15 lines
Quoted 15 lines
Quoted 7 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of fragmentation.

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper

manner.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.dpdk
.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 31 lines
Quoted 31 lines

Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 5 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here. With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines
particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 3 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

Quoted 7 lines
Quoted 7 lines

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage model. I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC

for it.

Quoted 2 lines

[Anoob] If you are okay with application defining how it implements ipsec,

then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios.
As an example: snpritnf() provides user with ability to format strings, application decides what exactly format to use and for which string.
Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 34 lines
Quoted 34 lines
Quoted 21 lines
Quoted 21 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's say 6
packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in

this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6 becomes

one group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

Quoted 8 lines
Quoted 8 lines

case.

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.sche
d.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might

cause, etc.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

[Anoob] This is something I had noticed while going through the code flow.

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases

were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

Quoted 2 lines

My suggestion, if these limitations and the plans to address it were mentioned

in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 7 lines

But my reply would still be the same 😊

Quoted 5 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 2 lines
Quoted 2 lines

Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E

Quoted 4 lines
Quoted 4 lines

Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG session:
https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ

Quoted 8 lines
Quoted 8 lines

cY&e=
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or

not.

Quoted 3 lines
Quoted 1 line

If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 2 lines

Also, the ordering is lost because application is not considering that. Why can't

we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another.
We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 3 lines
Quoted 3 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6

Quoted 6 lines
Quoted 6 lines

eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 3 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

Quoted 6 lines
Quoted 6 lines

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such

kind of problems.

Quoted 3 lines

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other possibilities.

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 3 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be

the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

Quoted 3 lines

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering,

assumptions on ESP etc). However, if the patch is introduced directly into ipsec- secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible. sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation.
I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of

rte_ipsec library.

Quoted 2 lines
Quoted 2 lines
#30 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Konstantin,

Thanks for clarifying your stand on review comments.

From the comments we(Marvell/Cavium) have received on multiple features, my impression is that the feature need to be correct/fully done/acceptable to the overall community. Features are usually agreed upon if there is solid plan on how it will work in the long run.

Discussions with Radu on what eventually became get_userdata()
http://mails.dpdk.org/archives/dev/2017-November/082039.html

From the mail:

"> Having something like "get_pkt_metadata" should be fine for inline

Quoted 2 lines

protocol usage. But we will still need a "get cookie" call to get the cookie, as the application would need something it can interpret.

Why can't you have a get_pkt_metadata that returns the "cookie" - which I would call it userdata or similar? What I'm trying to say is that we should try to keep it as generic as possible. For example, I wouldn't assume that the cookie is stored in pkt->udata64 in the application."

Marvell prefers using pkt->udata64 instead of get_userdata() as it avoids an extra cache line access while trying to get hold of the SA which processed the packet. We agreed to Radu's suggestion even though Intel/Radu didn't have access to an inline protocol enabled h/w and it wasn't affecting any data path that Intel/Radu would be interested in.

Discussions with Mattias on eventmode helper
http://mails.dpdk.org/archives/dev/2019-June/134900.html

"Or even worse, the
application's developers are forced to do a big-bang switch over to using the event and ethernet device APIs directly, in case they can't patch DPDK to work around the eventmode-assumption-that-didn't-hold-for-them.

You could always add flexibility to the framework (as you encounter a need for it), but then it will grow in complexity as well."

Here Mattias resisted the idea of eventmode helper for three reasons,

1. It's purely software, ie, no backing PMD required (which is the same case for librte_ipsec as well).
2. It "could" break for a new feature that "could" get added in eventdev.
3. He "thought" it would grow in complexity.

Marvell/Cavium has respected his opinion and did rework the entire approach which exponentially increased the effort required from our end (one code base integrated into 3 different apps vs 3 different code bases for 3 apps). Please do note that this entire "l2fwd-event" had to be redone 3 times while trying to get a consensus on the approach. I believe you had okeyed the first approach, so you cannot say we had to redo the patches because the patches were done poorly or the feature was incorrect.

I see that there is a shift in the review process these days and the vendors are encouraged to commend only on the features they are interested in. In that case, Marvell will no longer bother with patches which doesn't come in modes which doesn't matter to us. I would expect the same courtesy returned back as well.

FYI, eventmode ipsec-secgw is submitted as an RFC. In line with the comment redressal here, I've documented all the limitations.

Quoted 3 lines

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

I saw atleast the ones below. It would be frivolous to assume that the feature is added without any data path checks.

+ if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {

+ if (pg->id.val & IPSEC_SA_OFFLOAD_FALLBACK_FLAG) {

@maintainers, Marvell is not blocking this feature anymore assuming that the same yardstick will be used while reviewing patches submitted by us.

Thanks,
Anoob

Quoted 707 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, October 10, 2019 4:25 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 6 lines

Following are the main issues I had identified,

1. Doesn't work for inline protocol offload (the plan itself won't scale for that case) 2. Ignores the data from the h/w lookup 3. The fallback support is actually supported in ipsec-secgw (application) instead of

librte_ipsec.

Quoted 2 lines

4. Reordering issue.
5. Introduces checks in existing data path even when the feature is not

properly implemented/is not suitable for other PMDs.

Quoted 2 lines

For Issue #1, I get that Intel doesn't have plans to support the feature and

won't be submitting anything in that direction.

Quoted 1 line

But adding code that further exacerbates the situation is probably not desired.

We already discussed why that feature can't be fully supported right now by inline-proto/lookaside-proto devices:
There is no API defined to sync session state between HW and SW
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2019- 2DSeptember_143881.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=ObkJK9pyzOZuwoeulr6mrr6iKQF1NgXu3p2v7XwkYEs&e=

I already outlined that gap nearly a year ago:
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2018- 2DSeptember_113600.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=0x8pmfsS7nT7Xn-a_RvhI-DxtHMdk0zr4jiapi22tVE&e=
Though so far I didn't see any attempt to resolve this problem by Marvell (or NXP) engineers.
Which makes me think that either you guys don't consider it as a problem at all, or have no desire to work on it.
I never insisted, as I don't think it is my call by obvious reasons:
1) right now Intel doesn't have HW that provides inline-proto/lksd-proto capabilities.
2) Intel DPDK team doesn't have access to such HW.
3) There is no PMD inside dpdk.org that implements inline-proto anyway.

Now, one year later we are in a situation where:
1) there still no PMD at dpdk.org that supports inline-proto.
2) API to sync session state between HW and SW still not defined/implemented.
3) you trying to accuse me and other Intel DPDK team for lack of interest to work on that problem for you
and threat our patches because of that.

That just doesn't look fair to me.
You shouldn't expect other people patches to provide 'complete' solution for inline-proto, if (in a year time) you failed to define/implement an API for that.

Quoted 2 lines

For Issue #2, since ipsec-secgw is not utilizing the h/w lookup data, the solution here follows suit and is preventing other usage models of the

hardware which are allowed by the library.

Same as above, right now there is no PMD that supports inline-proto and no API to extract that extra H/W lookup data.
Though I replied to you and explained *twice*how I think such functionality could be added if in hypothetical future there would be a PMD that will support these features.
But you simply ignored my replies and kept threating our patches. Obviously, I don't think it is a proper attitude for open-source community. At least I would expect to provide some clear explanation, why do you think approach I outlined is not good enough.
Even better would be to:
1) submit an RFC/patch with API you envision and PMD implementation for it.
2) submit an RFC/patch with changes in ipsec-secgw to enable these new features.
Without that in place there is not much to discuss.

Quoted 2 lines

For Issue #3, librte_ipsec is still experimental and is just 2-3 releases old. It has scope for improvement and all these features would've

added value to its utility. No strong feelings here.

Quoted 5 lines

For Issue #4, glad that you documented that issue.

For Issue #5, in your reply you had mentioned that there is no additional check done. I see atleast few checks in the datapath. Since the

feature itself is experimental, it would be less contentious if it was introduced as a new data path.

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

Quoted 15 lines

Also, to quote from the reply,

Quoted 11 lines
Quoted 1 line

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 1 line

If your suggestion is to stick to above guidelines,

It is not my suggestion, that's how things work within DPDK right now. Nearly every dpdk library, driver and sample app was developed based on that principle.
Even ipsec-secgw itself, just look at the git log for it.

Quoted 2 lines

I don't think there is any point in pushing any further. I leave this to maintainers to decide. I would assume the same rules would apply to every

feature that is being attempted.

I believe that for #1, #2, #5 your comments are biased, and doesn't provide real picture.
So my suggestion to maintainers would be to ignore them as not valuable.

Konstantin

Quoted 31 lines

Thanks,
Anoob

Quoted 27 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 3, 2019 8:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security

processed.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Not sure I understood your whole statement above. AFAIK, right now (with dpdk master) for unprotected iface it works like

that:

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 6 lines
Quoted 6 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found
SA

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it

(by some reason)?

Quoted 32 lines
Quoted 32 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 3 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

Quoted 7 lines
Quoted 3 lines

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow

with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet
*always* does SW lookup.
No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not. Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

Quoted 7 lines
Quoted 7 lines

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_prepare-5Fone-

5Fpacket&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 10 lines
Quoted 10 lines

oSO1i-M&s=opbGGHUqfxy8p_4NvwCG6od6VdV0qN8XafaPiubfO1A&e=
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet. If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Quoted 4 lines
Quoted 4 lines

Then it goes into process_pkts_inbound()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_process-5Fpkts-

5Finbound&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Y

Quoted 1 line
Quoted 1 line

bgKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0S

Quoted 7 lines
Quoted 7 lines

IoSO1i-M&s=2OxMXug7jtUQPcYiDN4nW9WbrMtRfTJx5k-N7ikOeME&e= and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

Quoted 5 lines
Quoted 5 lines

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_single-5Finbound-

5Flookup&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 11 lines
Quoted 11 lines

oSO1i-M&s=D2ZPZPLbcQSbaluG8KH0F3uUDHfQWNYxw4MOc0fSkI8&e=

Quoted 8 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above). So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about

h/w lookups and pass it on to the upper layers, isn't that the better

approach?

Quoted 11 lines
Quoted 11 lines

Please let's keep our conversation in a constructive way. We are not discussing what could be done in theory, but a particular patch for
ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet (no matter what HW offload does) and this patch doesn't introduce any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine
- feel free to submit RFC/patch to fix that, or start a discussion in a new

thread.

Quoted 15 lines
Quoted 15 lines

I just don't see why we have to discuss it in context of this patch.

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

*before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before

that.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 1 line

So I still believe we are ok here.

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some

issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be

required to do the lookup.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding

Quoted 7 lines
Quoted 7 lines

support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 3 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on

the packet.

Quoted 7 lines
Quoted 7 lines

There can be applications which relies on h/w lookup data to figure out the processing done.

Quoted 5 lines

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your

Quoted 8 lines
Quoted 8 lines

approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose

BYPASS for such packets.

Quoted 24 lines
Quoted 24 lines

Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes.
Correct?
If, so then I said before, I don't think that concern is valid. Most obvious variant where to add such code is inisde inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);
(quoted diff) +4 -1
-                if (iph4->next_proto_id == IPPROTO_ESP)
+                if (iph4->next_proto_id == IPPROTO_ESP) {
+		if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+			/* extract extra info, make decision based on that */
+		} else
			t->ipsec.pkts[(t->ipsec.num)++] = pkt;
(quoted diff) +1 -0
+	   }
Quoted 5 lines
Quoted 5 lines

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(), either
before or straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection

code.

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a

BYPASS?

Quoted 16 lines
Quoted 16 lines

Yes.

That's not correct, I believe, see above.

Quoted 12 lines
Quoted 12 lines
Quoted 7 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of

fragmentation.

Quoted 17 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper

manner.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and
library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.
dpdk
.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 5 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here. With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines
particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage

model.

Quoted 65 lines
Quoted 65 lines
Quoted 5 lines
Quoted 5 lines

I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC

for it.

Quoted 3 lines

[Anoob] If you are okay with application defining how it implements ipsec,

then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios. As an example: snpritnf() provides user with ability to format strings, application decides what exactly format to use and for which string. Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 44 lines
Quoted 44 lines
Quoted 23 lines
Quoted 23 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's
say 6 packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in

this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6

becomes one group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

case.

Quoted 7 lines
Quoted 7 lines

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.
sche
d.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 9 lines
Quoted 9 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might

Quoted 3 lines
Quoted 3 lines

cause, etc.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[Anoob] This is something I had noticed while going through the code

flow.

Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
Quoted 4 lines

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases

were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

Quoted 3 lines

My suggestion, if these limitations and the plans to address it were mentioned

in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

But my reply would still be the same 😊

Quoted 5 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG

session:

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ

Quoted 36 lines
Quoted 36 lines
Quoted 9 lines
Quoted 9 lines

cY&e=
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or

not.

Quoted 3 lines
Quoted 1 line

If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 3 lines

Also, the ordering is lost because application is not considering that. Why can't

we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another. We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 3 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such

Quoted 4 lines
Quoted 4 lines

kind of problems.

Quoted 3 lines

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other

possibilities.

Quoted 50 lines
Quoted 50 lines

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 4 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be

the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

Quoted 4 lines

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering,

assumptions on ESP etc). However, if the patch is introduced directly into ipsec- secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible. sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation.
I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of

rte_ipsec library.

Quoted 2 lines
Quoted 2 lines
#31 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Review

Quoted 8 lines
Quoted 4 lines

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

I saw atleast the ones below. It would be frivolous to assume that the feature is added without any data path checks.

(quoted diff) +1 -0
+	if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {

Ok here we have extra 2 comparsions for data (pkt->ol_flags and sa->fallback_sessions), that already would be in the cache and .
For common path both will be evaluated to 0, we didn't observe any perf difference because of that. I would expect the same for other archs.
If you would see something on your boxes - let us know.
We could think what we can do here...
Probably at least swap the comparisons or so...
But honestly, I don't expect any observable slowdown.

Quoted 719 lines
(quoted diff) +1 -0
+			if (pg->id.val & IPSEC_SA_OFFLOAD_FALLBACK_FLAG) {

@maintainers, Marvell is not blocking this feature anymore assuming that the same yardstick will be used while reviewing patches submitted by us.

Thanks,
Anoob

Quoted 707 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, October 10, 2019 4:25 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 6 lines

Following are the main issues I had identified,

1. Doesn't work for inline protocol offload (the plan itself won't scale for that case) 2. Ignores the data from the h/w lookup 3. The fallback support is actually supported in ipsec-secgw (application) instead of

librte_ipsec.

Quoted 2 lines

4. Reordering issue.
5. Introduces checks in existing data path even when the feature is not

properly implemented/is not suitable for other PMDs.

Quoted 2 lines

For Issue #1, I get that Intel doesn't have plans to support the feature and

won't be submitting anything in that direction.

Quoted 1 line

But adding code that further exacerbates the situation is probably not desired.

We already discussed why that feature can't be fully supported right now by inline-proto/lookaside-proto devices:
There is no API defined to sync session state between HW and SW
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2019- 2DSeptember_143881.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=ObkJK9pyzOZuwoeulr6mrr6iKQF1NgXu3p2v7XwkYEs&e=

I already outlined that gap nearly a year ago:
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2018- 2DSeptember_113600.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=0x8pmfsS7nT7Xn-a_RvhI-DxtHMdk0zr4jiapi22tVE&e=
Though so far I didn't see any attempt to resolve this problem by Marvell (or NXP) engineers.
Which makes me think that either you guys don't consider it as a problem at all, or have no desire to work on it.
I never insisted, as I don't think it is my call by obvious reasons:
1) right now Intel doesn't have HW that provides inline-proto/lksd-proto capabilities.
2) Intel DPDK team doesn't have access to such HW.
3) There is no PMD inside dpdk.org that implements inline-proto anyway.

Now, one year later we are in a situation where:
1) there still no PMD at dpdk.org that supports inline-proto.
2) API to sync session state between HW and SW still not defined/implemented.
3) you trying to accuse me and other Intel DPDK team for lack of interest to work on that problem for you
and threat our patches because of that.

That just doesn't look fair to me.
You shouldn't expect other people patches to provide 'complete' solution for inline-proto, if (in a year time) you failed to define/implement an API for that.

Quoted 2 lines

For Issue #2, since ipsec-secgw is not utilizing the h/w lookup data, the solution here follows suit and is preventing other usage models of the

hardware which are allowed by the library.

Same as above, right now there is no PMD that supports inline-proto and no API to extract that extra H/W lookup data.
Though I replied to you and explained *twice*how I think such functionality could be added if in hypothetical future there would be a PMD that will support these features.
But you simply ignored my replies and kept threating our patches. Obviously, I don't think it is a proper attitude for open-source community. At least I would expect to provide some clear explanation, why do you think approach I outlined is not good enough.
Even better would be to:
1) submit an RFC/patch with API you envision and PMD implementation for it.
2) submit an RFC/patch with changes in ipsec-secgw to enable these new features.
Without that in place there is not much to discuss.

Quoted 2 lines

For Issue #3, librte_ipsec is still experimental and is just 2-3 releases old. It has scope for improvement and all these features would've

added value to its utility. No strong feelings here.

Quoted 5 lines

For Issue #4, glad that you documented that issue.

For Issue #5, in your reply you had mentioned that there is no additional check done. I see atleast few checks in the datapath. Since the

feature itself is experimental, it would be less contentious if it was introduced as a new data path.

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

Quoted 15 lines

Also, to quote from the reply,

Quoted 11 lines
Quoted 1 line

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 1 line

If your suggestion is to stick to above guidelines,

It is not my suggestion, that's how things work within DPDK right now. Nearly every dpdk library, driver and sample app was developed based on that principle.
Even ipsec-secgw itself, just look at the git log for it.

Quoted 2 lines

I don't think there is any point in pushing any further. I leave this to maintainers to decide. I would assume the same rules would apply to every

feature that is being attempted.

I believe that for #1, #2, #5 your comments are biased, and doesn't provide real picture.
So my suggestion to maintainers would be to ignore them as not valuable.

Konstantin

Quoted 31 lines

Thanks,
Anoob

Quoted 27 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 3, 2019 8:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security

processed.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Not sure I understood your whole statement above. AFAIK, right now (with dpdk master) for unprotected iface it works like

that:

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 6 lines
Quoted 6 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found
SA

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it

(by some reason)?

Quoted 32 lines
Quoted 32 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 3 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

Quoted 7 lines
Quoted 3 lines

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow

with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet
*always* does SW lookup.
No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not. Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

Quoted 7 lines
Quoted 7 lines

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_prepare-5Fone-

5Fpacket&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 10 lines
Quoted 10 lines

oSO1i-M&s=opbGGHUqfxy8p_4NvwCG6od6VdV0qN8XafaPiubfO1A&e=
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet. If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Quoted 4 lines
Quoted 4 lines

Then it goes into process_pkts_inbound()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_process-5Fpkts-

5Finbound&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Y

Quoted 1 line
Quoted 1 line

bgKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0S

Quoted 7 lines
Quoted 7 lines

IoSO1i-M&s=2OxMXug7jtUQPcYiDN4nW9WbrMtRfTJx5k-N7ikOeME&e= and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

Quoted 5 lines
Quoted 5 lines

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_single-5Finbound-

5Flookup&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 11 lines
Quoted 11 lines

oSO1i-M&s=D2ZPZPLbcQSbaluG8KH0F3uUDHfQWNYxw4MOc0fSkI8&e=

Quoted 8 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above). So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about

h/w lookups and pass it on to the upper layers, isn't that the better

approach?

Quoted 11 lines
Quoted 11 lines

Please let's keep our conversation in a constructive way. We are not discussing what could be done in theory, but a particular patch for
ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet (no matter what HW offload does) and this patch doesn't introduce any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine
- feel free to submit RFC/patch to fix that, or start a discussion in a new

thread.

Quoted 15 lines
Quoted 15 lines

I just don't see why we have to discuss it in context of this patch.

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

*before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before

that.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 1 line

So I still believe we are ok here.

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some

issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be

required to do the lookup.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding

Quoted 7 lines
Quoted 7 lines

support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 3 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on

the packet.

Quoted 7 lines
Quoted 7 lines

There can be applications which relies on h/w lookup data to figure out the processing done.

Quoted 5 lines

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your

Quoted 8 lines
Quoted 8 lines

approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose

BYPASS for such packets.

Quoted 24 lines
Quoted 24 lines

Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes.
Correct?
If, so then I said before, I don't think that concern is valid. Most obvious variant where to add such code is inisde inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);
(quoted diff) +4 -1
-                if (iph4->next_proto_id == IPPROTO_ESP)
+                if (iph4->next_proto_id == IPPROTO_ESP) {
+		if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+			/* extract extra info, make decision based on that */
+		} else
			t->ipsec.pkts[(t->ipsec.num)++] = pkt;
(quoted diff) +1 -0
+	   }
Quoted 5 lines
Quoted 5 lines

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(), either
before or straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection

code.

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a

BYPASS?

Quoted 16 lines
Quoted 16 lines

Yes.

That's not correct, I believe, see above.

Quoted 12 lines
Quoted 12 lines
Quoted 7 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of

fragmentation.

Quoted 17 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper

manner.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and
library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.
dpdk
.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 5 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here. With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines
particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage

model.

Quoted 65 lines
Quoted 65 lines
Quoted 5 lines
Quoted 5 lines

I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC

for it.

Quoted 3 lines

[Anoob] If you are okay with application defining how it implements ipsec,

then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios. As an example: snpritnf() provides user with ability to format strings, application decides what exactly format to use and for which string. Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 44 lines
Quoted 44 lines
Quoted 23 lines
Quoted 23 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's
say 6 packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in

this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6

becomes one group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

case.

Quoted 7 lines
Quoted 7 lines

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.
sche
d.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 9 lines
Quoted 9 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might

Quoted 3 lines
Quoted 3 lines

cause, etc.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[Anoob] This is something I had noticed while going through the code

flow.

Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
Quoted 4 lines

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases

were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

Quoted 3 lines

My suggestion, if these limitations and the plans to address it were mentioned

in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

But my reply would still be the same 😊

Quoted 5 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG

session:

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ

Quoted 36 lines
Quoted 36 lines
Quoted 9 lines
Quoted 9 lines

cY&e=
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or

not.

Quoted 3 lines
Quoted 1 line

If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 3 lines

Also, the ordering is lost because application is not considering that. Why can't

we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another. We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 3 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such

Quoted 4 lines
Quoted 4 lines

kind of problems.

Quoted 3 lines

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other

possibilities.

Quoted 50 lines
Quoted 50 lines

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 4 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be

the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

Quoted 4 lines

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering,

assumptions on ESP etc). However, if the patch is introduced directly into ipsec- secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible. sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation.
I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of

rte_ipsec library.

Quoted 2 lines
Quoted 2 lines
#32 lore raw

Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

In reply to Anoob Joseph
Quoted 36 lines

Hi Konstantin,

Thanks for clarifying your stand on review comments.

From the comments we(Marvell/Cavium) have received on multiple features, my impression is that the feature need to be correct/fully done/acceptable to the overall community. Features are usually agreed upon if there is solid plan on how it will work in the long run.

Discussions with Radu on what eventually became get_userdata()
http://mails.dpdk.org/archives/dev/2017-November/082039.html

From the mail:

"> Having something like "get_pkt_metadata" should be fine for inline

Quoted 2 lines

protocol usage. But we will still need a "get cookie" call to get the cookie, as the application would need something it can interpret.

Why can't you have a get_pkt_metadata that returns the "cookie" - which I would call it userdata or similar? What I'm trying to say is that we should try to keep it as generic as possible. For example, I wouldn't assume that the cookie is stored in pkt->udata64 in the application."

Marvell prefers using pkt->udata64 instead of get_userdata() as it avoids an extra cache line access while trying to get hold of the SA which processed the packet. We agreed to Radu's suggestion even though Intel/Radu didn't have access to an inline protocol enabled h/w and it wasn't affecting any data path that Intel/Radu would be interested in.

Discussions with Mattias on eventmode helper
http://mails.dpdk.org/archives/dev/2019-June/134900.html

"Or even worse, the
application's developers are forced to do a big-bang switch over to using the event and ethernet device APIs directly, in case they can't patch DPDK to work around the eventmode-assumption-that-didn't-hold-for-them.

Quoted 8 lines

You could always add flexibility to the framework (as you encounter a need for it), but then it will grow in complexity as well."

Here Mattias resisted the idea of eventmode helper for three reasons,

1. It's purely software, ie, no backing PMD required (which is the same case for librte_ipsec as well).
2. It "could" break for a new feature that "could" get added in eventdev.
3. He "thought" it would grow in complexity.

Sorry, but why we have to discuss other people comments on your previous patches here? How does it relate to the patch under discussion?
From my perspective, it doesn't at all.

Quoted 4 lines

Marvell/Cavium has respected his opinion and did rework the entire approach which exponentially increased the effort required from our end (one code base integrated into 3 different apps vs 3 different code bases for 3 apps). Please do note that this entire "l2fwd-event" had to be redone 3 times while trying to get a consensus on the approach. I believe you had okeyed the first approach, so you cannot say we had to redo the patches because the patches were done poorly or the feature was incorrect.

Once again, if you felt that these comments were inappropriate and caused extra unnecessary work, why do you complain about it here?
Why didn't you flag that at original patch review time?

Quoted 3 lines

I see that there is a shift in the review process these days and the vendors are encouraged to commend only on the features they are interested in. In that case, Marvell will no longer bother with patches which doesn't come in modes which doesn't matter to us. I would expect the same courtesy returned back as well.

I personally not aware about such shift.
I still think that as community member you are free to review any patches you'd like. Moreover as a good citizen of the community you are encouraged to review other people patches. Though I think, these reviews need to be relevant, concentrate on patch subject, and take into account real picture.

Let say about your comment that current fall-back session doesn't work for inline-proto:
True, it doesn't.
Though the reason for that - required for that API is not defined and not implemented. As API is not in place (and no signs that it would be anytime soon),
we'll have to go ahead and submit our code without inline-proto/lookaside-proto support. Though, if such API would be defined and implemented -
for sure we will have to respect and support it, as we did in other places for inline-proto devices. And yes, I expect Marvell team to lead/start that API work, because right now you are the only ones within DPDK world who claimed to have inline-proto devices.
Other teams simply don't have enough knowledge (and need) for that.

Quoted 726 lines

FYI, eventmode ipsec-secgw is submitted as an RFC. In line with the comment redressal here, I've documented all the limitations.

Quoted 3 lines

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

I saw atleast the ones below. It would be frivolous to assume that the feature is added without any data path checks.

(quoted diff) +2 -0
+	if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
 
+			if (pg->id.val & IPSEC_SA_OFFLOAD_FALLBACK_FLAG) {

@maintainers, Marvell is not blocking this feature anymore assuming that the same yardstick will be used while reviewing patches submitted by us.

Thanks,
Anoob

Quoted 707 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, October 10, 2019 4:25 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 6 lines

Following are the main issues I had identified,

1. Doesn't work for inline protocol offload (the plan itself won't scale for that case) 2. Ignores the data from the h/w lookup 3. The fallback support is actually supported in ipsec-secgw (application) instead of

librte_ipsec.

Quoted 2 lines

4. Reordering issue.
5. Introduces checks in existing data path even when the feature is not

properly implemented/is not suitable for other PMDs.

Quoted 2 lines

For Issue #1, I get that Intel doesn't have plans to support the feature and

won't be submitting anything in that direction.

Quoted 1 line

But adding code that further exacerbates the situation is probably not desired.

We already discussed why that feature can't be fully supported right now by inline-proto/lookaside-proto devices:
There is no API defined to sync session state between HW and SW
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2019- 2DSeptember_143881.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=ObkJK9pyzOZuwoeulr6mrr6iKQF1NgXu3p2v7XwkYEs&e=

I already outlined that gap nearly a year ago:
https://urldefense.proofpoint.com/v2/url?u=http-
3A__mails.dpdk.org_archives_dev_2018- 2DSeptember_113600.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8 rwwviRSxyLWs2n6B- WYLn1v9SyTMrT5EQqh2TU&m=UGz2FemapWdsohgNRq2UX5ArFEL_pLGYEVrwe IzaUX4&s=0x8pmfsS7nT7Xn-a_RvhI-DxtHMdk0zr4jiapi22tVE&e=
Though so far I didn't see any attempt to resolve this problem by Marvell (or NXP) engineers.
Which makes me think that either you guys don't consider it as a problem at all, or have no desire to work on it.
I never insisted, as I don't think it is my call by obvious reasons:
1) right now Intel doesn't have HW that provides inline-proto/lksd-proto capabilities.
2) Intel DPDK team doesn't have access to such HW.
3) There is no PMD inside dpdk.org that implements inline-proto anyway.

Now, one year later we are in a situation where:
1) there still no PMD at dpdk.org that supports inline-proto.
2) API to sync session state between HW and SW still not defined/implemented.
3) you trying to accuse me and other Intel DPDK team for lack of interest to work on that problem for you
and threat our patches because of that.

That just doesn't look fair to me.
You shouldn't expect other people patches to provide 'complete' solution for inline-proto, if (in a year time) you failed to define/implement an API for that.

Quoted 2 lines

For Issue #2, since ipsec-secgw is not utilizing the h/w lookup data, the solution here follows suit and is preventing other usage models of the

hardware which are allowed by the library.

Same as above, right now there is no PMD that supports inline-proto and no API to extract that extra H/W lookup data.
Though I replied to you and explained *twice*how I think such functionality could be added if in hypothetical future there would be a PMD that will support these features.
But you simply ignored my replies and kept threating our patches. Obviously, I don't think it is a proper attitude for open-source community. At least I would expect to provide some clear explanation, why do you think approach I outlined is not good enough.
Even better would be to:
1) submit an RFC/patch with API you envision and PMD implementation for it.
2) submit an RFC/patch with changes in ipsec-secgw to enable these new features.
Without that in place there is not much to discuss.

Quoted 2 lines

For Issue #3, librte_ipsec is still experimental and is just 2-3 releases old. It has scope for improvement and all these features would've

added value to its utility. No strong feelings here.

Quoted 5 lines

For Issue #4, glad that you documented that issue.

For Issue #5, in your reply you had mentioned that there is no additional check done. I see atleast few checks in the datapath. Since the

feature itself is experimental, it would be less contentious if it was introduced as a new data path.

Once again - you keep making statements without any evidence. Provide something more concrete here - description of packet and code flow (function names, exact lines of code) that you think will cause a problem.

Quoted 15 lines

Also, to quote from the reply,

Quoted 11 lines
Quoted 1 line

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 1 line

If your suggestion is to stick to above guidelines,

It is not my suggestion, that's how things work within DPDK right now. Nearly every dpdk library, driver and sample app was developed based on that principle.
Even ipsec-secgw itself, just look at the git log for it.

Quoted 2 lines

I don't think there is any point in pushing any further. I leave this to maintainers to decide. I would assume the same rules would apply to every

feature that is being attempted.

I believe that for #1, #2, #5 your comments are biased, and doesn't provide real picture.
So my suggestion to maintainers would be to ignore them as not valuable.

Konstantin

Quoted 31 lines

Thanks,
Anoob

Quoted 27 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 3, 2019 8:16 PM
To: Anoob Joseph <[email protected]>; Smoczynski, MarcinX <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Archana Muniganti <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/3] add fallback session

Hi Anoob,

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

I've few more observations regarding the proposed feature.

1. From what I understood, if an ESP packet ends up on an unprotected interface and doesn't have 'PKT_RX_SEC_OFFLOAD' bit set, then the packet

would be looked up to see the associated SA and then fallback session is figured out and then further processing is done.

Quoted 5 lines

Can you confirm if I understood the sequence correctly? If yes, then aren't we doing an extra lookup in the s/w? The packet may be looked by the h/w using rte_flow and that information could be used to determine the

SA. Also, if the ESP packet is expected to be forwarded, then the above logic will add an unnecessary lookup even after your h/w has detected that the packet need not be security

processed.

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Not sure I understood your whole statement above. AFAIK, right now (with dpdk master) for unprotected iface it works like

that:

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

1. slit incoming traffic into 3 groups: ESP packets, IPv4 packets, IPv6

packets.

Quoted 6 lines
Quoted 6 lines

For ESP packets:
2. perform SAD lookup
a. if it fails (non SA found for that SPI), then drop the packet. b. otherwise (SA found) process the packet using found
SA

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

What fall-back patch adds:
Before step 2.b check:
does that SA has its primary session with type INLINE-CRYPTO and does HW fail to do IPsec realted processing for it

(by some reason)?

Quoted 32 lines
Quoted 32 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

If yes, then mark this packet to be processed by fall-back session.

if (MBUF_NO_SEC_OFFLOAD(pkt) && sa->fallback_sessions > 0) {
                uintptr_t intsa = (uintptr_t)sa;
                intsa |= IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
                result_sa = (void *)intsa;  }

So from my perspective, no additional lookup where introduced.

[Anoob] For inline processing, h/w does a lookup and figures out the security

processing to be done on the packet.

Quoted 3 lines

"rte_security_get_userdata()" allows s/w to further segregate that info. In this approach, I believe we don't consider how such info from h/w can

Quoted 7 lines
Quoted 3 lines

be used.

Right now it is not the case with ipsec-secgw:

[Anoob] Are you saying there is no h/w lookup involved when doing inline crypto processing? Then I'm confused. My understanding is that rte_flow

with ACTION type as SECURITY is being used to setup h/w lookups.

I am saying that current ipsec-secgw code for each inbound ESP packet
*always* does SW lookup.
No matter did HW lookup take place already and does information about that lookup is available via mbuf in some way or not. Just look at the ipsec-secgw code yourself:

nb_rx = rte_eth_rx_burst(portid, queueid, pkts, MAX_PKT_BURST);

Quoted 7 lines
Quoted 7 lines

if (nb_rx > 0)

	process_pkts(qconf, pkts, nb_rx, portid);

Inside process_pkts()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_prepare-5Fone-

5Fpacket&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 10 lines
Quoted 10 lines

oSO1i-M&s=opbGGHUqfxy8p_4NvwCG6od6VdV0qN8XafaPiubfO1A&e=
it first calls prepare_traffic() which does sort of de-muxing:
put packet in one of 3 arrays:
1) ESP packets
2) non ESP IPv4 packets
3) non ESP IPv6 packets
Also it checks is PKT_RX_SEC_OFFLOAD set for that packet. If yes, it retrieves associated security user-data and stores it inside private mbuf area.

Quoted 4 lines
Quoted 4 lines

Then it goes into process_pkts_inbound()
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_process-5Fpkts-

5Finbound&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Y

Quoted 1 line
Quoted 1 line

bgKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0S

Quoted 7 lines
Quoted 7 lines

IoSO1i-M&s=2OxMXug7jtUQPcYiDN4nW9WbrMtRfTJx5k-N7ikOeME&e= and here for all ESP packets:
legacy code path:
ipsec_inbound()->inbound_sa_lookup()->single_inbound_lookup() for librte_ipsec code path:
inbound_sa_lookup()->single_inbound_lookup()

Quoted 5 lines
Quoted 5 lines

single_inbound_lookup() is the one that does actual SW lookup for each input packet.
https://urldefense.proofpoint.com/v2/url?u=http-
3A__lxr.dpdk.org_dpdk_latest_ident_single-5Finbound-

5Flookup&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=BPcGOOudUMrTDQ9Yb

Quoted 1 line
Quoted 1 line

gKcOkO5ChYiUPPlPNIEvTOhjNE&m=KVBgvXYlUGyMmu260erISKr73Qt6PBLux0SI

Quoted 11 lines
Quoted 11 lines

oSO1i-M&s=D2ZPZPLbcQSbaluG8KH0F3uUDHfQWNYxw4MOc0fSkI8&e=

Quoted 8 lines
Quoted 4 lines

for each inbound ESP packet it *always* does a lookup in SW based SADB, and if lookup fails - drops the packet (see 2.a above). So, I still not see any additional lookups introduced with the patch.

[Anoob] In case of inline crypto, you could do that. No disagreement. But that doesn't mean that is the only way. If PMDs can retrieve info about

h/w lookups and pass it on to the upper layers, isn't that the better

approach?

Quoted 11 lines
Quoted 11 lines

Please let's keep our conversation in a constructive way. We are not discussing what could be done in theory, but a particular patch for
ipsec-secgw:
Right now ipsec-secgw does a SW lookup for each inbound ESP packet (no matter what HW offload does) and this patch doesn't introduce any extra SW lookups.

If you are not happy with current ipsec-secgw approach, that's fine
- feel free to submit RFC/patch to fix that, or start a discussion in a new

thread.

Quoted 15 lines
Quoted 15 lines

I just don't see why we have to discuss it in context of this patch.

Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 7 lines

Also AFAIK, right now there is no possibility to configure ipsec-secgw to BYPASS some ESP traffic.
Should we do it (to conform to ipsec RFC) - that's probably subject of another discussion.

[Anoob] The approach (choice of flags) forces a software-based SA lookup for packets that need to be bypassed instead of leveraging possible

hardware SA lookup. I don't think what ipsec-secgw does matters here.

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I do not agree with that statement.
First of all - current patch doesn't introduce any additional SW lookups, see above.
Second, if someone would like to add BYPASS for ESP packets into ipsec-secgw, I think he would have to insert new code that do de-mux

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

*before* any ESP related processing starts.
Most obvious variant: at prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
Second variant - at early stage of single_inbound_lookup(), straight after actual SAD lookup failure.
In both cases, I don't see how session selection (primary or faillback) would affect us here, actual decision do we want to PROCESS or BYPASS particular ESP packet needs to take place before

that.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 1 line

So I still believe we are ok here.

[Anoob] I don't think you understood what I'm trying to highlight here. You could have a situation when h/w can detect that the packet has to be "PROTECT"ed using an "inline crypto" session. But then it might detect that it cannot proceed with inline processing because of some

issue (fragmentation, h/w queue overflow etc). Now the h/w has already figured out the action to be done to the packet. If PMDs allow this to be communicated to the application, the application won't be

required to do the lookup.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In inline crypto, application can ignore the h/w lookup data and do a s/w lookup with the protocol headers as they are not stripped off. It was done this way, because API and the associated means to get this info from PMD was not introduced when inline crypto and corresponding

Quoted 7 lines
Quoted 7 lines

support in Intel's PMD was added. But inline protocol cannot do the lookup in the application and so the concept of userdata etc was introduced. The same can be applied to inline crypto also. Advantage? It could remove the extra lookup done in s/w.

Quoted 3 lines

To summarize, we cannot assume that every inline crypto packet need to looked up in the application to figure out the processing done on

the packet.

Quoted 7 lines
Quoted 7 lines

There can be applications which relies on h/w lookup data to figure out the processing done.

Quoted 5 lines

Example: Using rte_flow, I can create a rule for ESP packets to be MARKed. There is no security session created for the flow and the application intends to forward this flow packets to a different port. With your

Quoted 8 lines
Quoted 8 lines

approach, even these packets would be looked up. The packet will have info from the h/w lookup which doesn't get used, because the approach fails to introduce the required concepts.

I think I understood your point.
Basically you saying that in future your PMD for unprocessed ESP packets might provide some additional information (via rte_security_get_userdata) that might be used by SW - let say to choose

BYPASS for such packets.

Quoted 24 lines
Quoted 24 lines

Current ipsec-secgw doesn't support such ability.
Your concern is that this patch will somehow prevent (or will make it harder) for you to make your future changes.
Correct?
If, so then I said before, I don't think that concern is valid. Most obvious variant where to add such code is inisde inside prepare_one_packet() when we split our incoming traffic to IPsec and non-IPsec ones.
To be more specific something like that

if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {

                iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
                        RTE_ETHER_HDR_LEN);
                adjust_ipv4_pktlen(pkt, iph4, 0);
(quoted diff) +4 -1
-                if (iph4->next_proto_id == IPPROTO_ESP)
+                if (iph4->next_proto_id == IPPROTO_ESP) {
+		if (pkt->ol_flags & PKT_RX_SEC_OFFLOAD) {
+			/* extract extra info, make decision based on that */
+		} else
			t->ipsec.pkts[(t->ipsec.num)++] = pkt;
(quoted diff) +1 -0
+	   }
Quoted 5 lines
Quoted 5 lines

Of course some code reordering might be needed to avoid performance drop, but I suppose the main idea is clear enough.
Second variant - at early stage of single_inbound_lookup(), either
before or straight after actual SAD SW lookup failure.
In both cases, this new code will be executed *before* session selection

code.

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

Does the above sound like BYPASS? Yes.
Does ipsec-secgw do it this way? No.

Correct, it doesn't.
You have to submit patches if you'd like to support such ability.

Quoted 1 line

Does this approach prevent an application from introducing such a

BYPASS?

Quoted 16 lines
Quoted 16 lines

Yes.

That's not correct, I believe, see above.

Quoted 12 lines
Quoted 12 lines
Quoted 7 lines

For example, ESN was not supported by ipsec-secgw (before library mode was introduced), but every single library change and application change was added keeping in mind that ESN is a valid feature for ipsec. So it is

one thing to say ipsec-secgw doesn't support ESP bypass and saying the solution doesn't consider a possibility of ESP bypass.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2. The solution proposed here seems like adding the handling in ipsec-secgw instead of ipsec library. In other words, this feature is not getting

added in ipsec library, which was supposed to simplify the whole ipsec usage in DPDK, but fails to handle the case of

fragmentation.

Quoted 17 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

What we have right now with ipsec library is SA (low) level API. It can handle multi-segment packets properly, but expects someone else to do other steps (fragmentation/reassembly). ipsec-secgw demonstrates how librte_ip_frag and librte_ipsec can be used together to deal with fragmented IPsec traffic in a proper

manner.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Probably in future we'll consider adding some high-level API that will be able to do whole processing under hood (SPD/SAD lookup, fragment/reassembly, actual IPsec packet processing, matching inbound selectors, etc.), but right now it is not the case.

Quoted 2 lines

Also, since the fallback feature is entirely done in the application, it begs the

question why the same feature is omitted for legacy use case.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

Because legacy mode doesn't support multi-seg packets at first place. Also it is an extra overhead to support 2 code-paths (legacy and
library) for the same app, so we'd like in future to deprecate and later remove legacy code- path.
As a first step we propose to make library code-path a default one:
https://urldefense.proofpoint.com/v2/url?u=http-3A__patches.
dpdk
.org

_cover_58247_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

Ws2

Quoted 1 line
Quoted 1 line

n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbf

Quoted 5 lines
Quoted 1 line

DvA&s=vz7ioUzJOuzoJdmV7QO0QLPKYn1ytFsj_0eYatbSCrg&e=

[Anoob] Even if we need the application to do the reassembly, it would look simple if application uses the same "rte_ipsec_session" to process the

fallback packet.

I think there is some sort of misunderstanding here. With current librte_ipsec design:
rte_ipsec_sa - opaque SW representation of the SA (HW neutral) rte_ipsec_session associates SA (rte_ipsec_sa)with particular HW device (session).
Same SA can be referred by multiple sessions.

From rte_ipsec.h:
/**
* rte_ipsec_session is an aggregate structure that defines
particular
* IPsec Security Association IPsec (SA) on given security/crypto device:
* - pointer to the SA object
* - security session action type
* - pointer to security/crypto session, plus other related data
* - session/device specific functions to prepare/process IPsec packets. */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

In that case, the processing required to handle the other packet will be hidden from the application. Here application has to make sure it chooses

the correct session, which I believe should be moved to ipsec library.

From my side it is a good thing to let application define its own usage

model.

Quoted 65 lines
Quoted 65 lines
Quoted 5 lines
Quoted 5 lines

I.E. librte_ipsec supports multiple-sessions per SA, upper-layer (app) decides how it will use that feature.
Though if you strongly feel that some higher-level API is needed here, and have some good ideas about it - please go ahead and submit RFC

for it.

Quoted 3 lines

[Anoob] If you are okay with application defining how it implements ipsec,

then probably there is no use case for lib ipsec?

:)
Once again - library provides an implementation.
Application defines the way to use it, i.e. how it will apply functionality library provides for different use-case scenarios. As an example: snpritnf() provides user with ability to format strings, application decides what exactly format to use and for which string. Same for librte_ipsec, library provides functionality to perform processing for ESP packets.
Application defines which packets to process and what session to use.

Quoted 44 lines
Quoted 44 lines
Quoted 23 lines
Quoted 23 lines
Quoted 8 lines

3. It seems like ordering won't be maintained once this processing is done. Again, this is the sequence I understood. Please correct me if I missed

something,

Quoted 3 lines

a. Application receives a bunch of packets (let's
say 6 packets), in which few are fragmented (P3 & P4) and the rest can be inline

processed.

Quoted 2 lines
       b. Application receives P1->P2->P3->P4->P5->P6 (in

this, P1, P2, P5, P6 are

inline processed successfully) and P4 & P5 are the fragments

Quoted 5 lines
       c. Application groups packets. P1->P2->P5->P6

becomes one group and P3-
P4 becomes another and goes for fallback processing. Now how is ordering maintained? I couldn't figure out how that is done in this

case.

Quoted 7 lines
Quoted 7 lines

You right, fallback session can introduce packet reordering. At least till we'll have ability to process packets in sync mode too. See our presentation at dpdk userspace (slides 17, 18):
https://urldefense.proofpoint.com/v2/url?u=https-3A__static.
sche
d.co
m_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=n

Quoted 1 line
Quoted 1 line

KjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&

Quoted 1 line
Quoted 1 line

m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuR

Quoted 9 lines
Quoted 9 lines

YHc5uDxaAod0Yl7f06EQr1M&e= Right now the only way to deal with it - have replay window big enough to sustain reordering and async processing latency.
That's actually another reason why we add this feature into ipsec-secgw sample
app:
so people can evaluate it on their platforms, determine what replay window size would be needed, what issues/slowdowns it might

Quoted 3 lines
Quoted 3 lines

cause, etc.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[Anoob] This is something I had noticed while going through the code

flow.

Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
Quoted 4 lines

The ordering info is lost because of the approach.

Once again, it is a known limitation and we are not trying to hide it from you :)

[Anoob] Never said it was hidden. Initially I had okayed the approach even though it wasn't a solution suitable for inline protocol. But as more cases

were considered, few shortcomings were observed, and I was skeptical about how any of that would be solved in the long run.

Quoted 3 lines

My suggestion, if these limitations and the plans to address it were mentioned

in the cover letter, we could've saved few cycles here.

Point taken.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

But my reply would still be the same 😊

Quoted 5 lines

It
was outlined here:
https://urldefense.proofpoint.com/v2/url?u=https-
3A__static.sched.com_hosted-5Ffiles_dpdkbordeaux2019_8f_DPDK-

2DIPSECu9.pdf&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=jPfB8rwwviRSxyL

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Ws2n6B-WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=MLRnnYcykjnsqXrHGUuRYHc5uDxaAod0Yl7f06E

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Qr1M&e=
And in the latest patch version Marcin clearly stated it inside the AG

session:

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_patch_60039_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=zrn91Vjf_ZElAlDf7IeZGmGevcA6RMwpPTLUCGlgZ

Quoted 36 lines
Quoted 36 lines
Quoted 9 lines
Quoted 9 lines

cY&e=
If you think even further clarification within the doc is needed, please let us know.

About the actual packet re-oridering:
AFAIK, for some use-cases it might be acceptable, for others not.
Though it is an optional feature, that wouldn't be enabled by default, so user can always choose is it does he needs/wants this feature or

not.

Quoted 3 lines
Quoted 1 line

If/when we'll have CPU_CRYPTO processing mode:

[Anoob] Shouldn't we get that accepted first then?

I don't think so.
Current implementation does provide expected functionality (with known limitations).
In future, we can try to improve it and/or remove existing limitations. That's a common iteration development approach that is used though whole
DPDK:
- provide initial solution with basic functionality first
- improve/extend with future releases/patches

Quoted 3 lines

Also, the ordering is lost because application is not considering that. Why can't

we use re-ordering library? Or an event-dev?

No-one saying it can't be improved in one way or another. We don't plan to introduce such code right now due to its complexity. Might be something in future.
Though you are welcome to go ahead and submit your own patches to improve that solution.

Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

https://urldefense.proofpoint.com/v2/url?u=http-

3A__patches.dpdk.org_cover_58862_&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtf

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

Q&r=jPfB8rwwviRSxyLWs2n6B-

WYLn1v9SyTMrT5EQqh2TU&m=b3E429fuo8P-

Quoted 2 lines
Quoted 2 lines

K5XfH8wG-

7hwr1d8oM4uJGErAkbfDvA&s=k1zef_1uqELXblKN3_qjX04WXNFGAUEFIIJrvKPr6

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

eA&e=
we'll add ability for the user to avoid this reordering problem

Quoted 3 lines

As we dig deeper, the feature looks hardly complete. The concerning part is the approach doesn't seem conducive to fixing any of these issues in the

future.

Again, don't agree with that statement.
From my perspective: while current implementation has its limitations (packet reordering, inline-proto/lksd-proto), it is totally functional and provides users with a reference how to deal with such

Quoted 4 lines
Quoted 4 lines

kind of problems.

Quoted 3 lines

[Anoob] Well, that is exactly my problem. It gives a skewed reference on how to deal with the problem, without considering other

possibilities.

Quoted 50 lines
Quoted 50 lines

Once again, please feel free and come-up with your own patches, that will address this problem in a smarter way.

Quoted 4 lines

If every application starts adopting this method and starts doing lookup for every ESP packet, h/w based lookups (and the associated h/w) would be rendered useless. I really think this series, which happens to be

the first step in solving a complex problem, will be very useful if all these issues are addressed properly.

Quoted 4 lines

If you can introduce the inline+lookaside via librte_ipsec, its perhaps ok for the patch to have some limitations(like lack of ordering,

assumptions on ESP etc). However, if the patch is introduced directly into ipsec- secgw, it needs to be more comprehensive and robust.

I think common DPDK policy is exactly opposite:
library/driver has to be as robust and comprehensive as possible. sample app code allowed to have some limitations (as long as they are documented, etc.).

Quoted 1 line

I also expect performance impact due to these changes

Could you be more specific here?
What performance impact do you expect and why?
Can you point to the exact piece of patch code that you believe would cause a degradation.
I don't expect any and performance tests on our platforms didn't show any regression so far.

Quoted 2 lines

and so I prefer if the inline+lookaside can be made separate datapath rather than overloading the existing one.

I don't see any good reason for that.
This feature is optional.
User have to enable it manually for each session (via config file). for all other sessions there is no impact.
What we probably can do - add extra check inside sa.c to allow fallback sessions only for inline-crypto-offload type of sessions.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Also, if the new ipsec related features are introduced via ipsec-secgw than via rte_ipsec, then it raises doubts over the utility of

rte_ipsec library.

Quoted 2 lines
Quoted 2 lines
#33 lore raw

v4 cover add fallback session

In reply to Marcin Smoczynski

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

v3 to v4 changes:
- add info about packet reordering to the documentation regarding fallback session
- add patch with --frag-ttl command line option which allows to change fragment lifetime

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (4):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add frag TTL cmdline option examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  31 +++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  56 ++++--
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 402 insertions(+), 177 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
Signature · 1 line
2.17.1
#34 lore raw

PATCH v4 1/4 examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
#35 lore raw

PATCH v4 2/4 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Fallback session feature is not available in the legacy mode.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  24 ++++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +--
 examples/ipsec-secgw/ipsec.h             |  40 +++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 ++++++++++++------
 examples/ipsec-secgw/sa.c                | 110 +++++++++++++++++++----
 7 files changed, 225 insertions(+), 64 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +23 -1
index ad2d79e75..21b4b4418 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,28 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *lookaside-crypto-offload*
+   and fallback session is *lookaside-none*.
+
+   If used in conjunction with IPsec window, its width needs be increased
+   due to different processing times of inline and lookaside modes which
+   results in packet reordering.
+
+ * Optional: Yes.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol hardware offload
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +94 -16

235 lines not on this page · raw message

Signature · 1 line
2.17.1
#36 lore raw

PATCH v4 3/4 examples/ipsec-secgw: add frag TTL cmdline option

In reply to Marcin Smoczynski

Due to fragment loss on highly saturated links and long fragment lifetime, ipsec-secgw application quickly runs out of free reassembly buckets. As a result new fragments are being dropped.

Introduce --frag-ttl option which allow user to lower default fragment lifitime which solves problem of saturated reassembly buckets with high bandwidth fragmented traffic.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  7 +++++
 examples/ipsec-secgw/ipsec-secgw.c       | 40 ++++++++++++++++++------
 2 files changed, 37 insertions(+), 10 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +7 -0
index 21b4b4418..55b65d7bc 100644
@@ -154,6 +154,13 @@ Where:
     Incoming packets with length bigger then MTU will be discarded.
     Default value: 1500.
 
+*   ``--frag-ttl FRAG_TTL_NS``: fragment lifetime (in nanoseconds).
+    If packet is not reassembled within this time, received fragments
+    will be discarded. Fragment lifetime should be decreased when
+    there is a high fragmented traffic loss in high bandwidth networks.
+    Should be lower for for low number of reassembly buckets.
+    Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
+
 *   ``--reassemble NUM``: max number of entries in reassemble fragment table.
     Zero value disables reassembly functionality.
     Default value: 0.
examples/ipsec-secgw/ipsec-secgw.c +30 -10
index 641ed3767..7b246cc60 100644
@@ -112,7 +112,7 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 		0, 0)
 
 #define	FRAG_TBL_BUCKET_ENTRIES	4
-#define	FRAG_TTL_MS		(10 * MS_PER_S)
+#define	MAX_FRAG_TTL_NS		(10LL * NS_PER_S)
 
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
@@ -135,6 +135,7 @@ struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 #define CMD_LINE_OPT_TX_OFFLOAD		"txoffload"
 #define CMD_LINE_OPT_REASSEMBLE		"reassemble"
 #define CMD_LINE_OPT_MTU		"mtu"
+#define CMD_LINE_OPT_FRAG_TTL		"frag-ttl"
 
 enum {
 	/* long options mapped to a short option */
@@ -150,6 +151,7 @@ enum {
 	CMD_LINE_OPT_TX_OFFLOAD_NUM,
 	CMD_LINE_OPT_REASSEMBLE_NUM,
 	CMD_LINE_OPT_MTU_NUM,
+	CMD_LINE_OPT_FRAG_TTL_NUM,
 };
 
 static const struct option lgopts[] = {
@@ -160,6 +162,7 @@ static const struct option lgopts[] = {
 	{CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM},
 	{CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM},
 	{CMD_LINE_OPT_MTU, 1, 0, CMD_LINE_OPT_MTU_NUM},
+	{CMD_LINE_OPT_FRAG_TTL, 1, 0, CMD_LINE_OPT_FRAG_TTL_NUM},
 	{NULL, 0, 0, 0}
 };
 
@@ -186,6 +189,7 @@ static uint64_t dev_tx_offload = UINT64_MAX;
 static uint32_t frag_tbl_sz;
 static uint32_t frame_buf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
 static uint32_t mtu_size = RTE_ETHER_MTU;
+static uint64_t frag_ttl_ns = MAX_FRAG_TTL_NS;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
@@ -1302,6 +1306,9 @@ print_usage(const char *prgname)
 		": MTU value on all ports (default value: 1500)\n"
 		"    outgoing packets with bigger size will be fragmented\n"
 		"    incoming packets with bigger size will be discarded\n"
+		"  --" CMD_LINE_OPT_FRAG_TTL " FRAG_TTL_NS"
+		": fragments lifetime in nanoseconds, default\n"
+		"    and maximum value is 10.000.000.000 ns (10 s)\n"
 		"\n",
 		prgname);
 }
@@ -1338,14 +1345,15 @@ parse_portmask(const char *portmask)
 	return pm;
 }
 
-static int32_t
+static int64_t
 parse_decimal(const char *str)
 {
 	char *end = NULL;
-	unsigned long num;
+	unsigned long long num;
 
-	num = strtoul(str, &end, 10);
-	if ((str[0] == '\0') || (end == NULL) || (*end != '\0'))
+	num = strtoull(str, &end, 10);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0')
+		|| num > INT64_MAX || num < 0)
 		return -1;
 
 	return num;
@@ -1419,12 +1427,14 @@ print_app_sa_prm(const struct app_sa_prm *prm)
 	printf("replay window size: %u\n", prm->window_size);
 	printf("ESN: %s\n", (prm->enable_esn == 0) ? "disabled" : "enabled");
 	printf("SA flags: %#" PRIx64 "\n", prm->flags);
+	printf("Frag TTL: %lu ns\n", frag_ttl_ns);
 }
 
 static int32_t
 parse_args(int32_t argc, char **argv)
 {
-	int32_t opt, ret;
+	int opt;
+	int64_t ret;
 	char **argvopt;
 	int32_t option_index;
 	char *prgname = argv[0];
@@ -1503,7 +1513,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_SINGLE_SA_NUM:
 			ret = parse_decimal(optarg);
-			if (ret == -1) {
+			if (ret == -1 || ret > UINT32_MAX) {
 				printf("Invalid argument[sa_idx]\n");
 				print_usage(prgname);
 				return -1;
@@ -1546,7 +1556,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_REASSEMBLE_NUM:
 			ret = parse_decimal(optarg);
-			if (ret < 0) {
+			if (ret < 0 || ret > UINT32_MAX) {
 				printf("Invalid argument for \'%s\': %s\n",
 					CMD_LINE_OPT_REASSEMBLE, optarg);
 				print_usage(prgname);
@@ -1564,6 +1574,16 @@ parse_args(int32_t argc, char **argv)
 			}
 			mtu_size = ret;
 			break;
+		case CMD_LINE_OPT_FRAG_TTL_NUM:
+			ret = parse_decimal(optarg);
+			if (ret < 0 || ret > MAX_FRAG_TTL_NS) {
+				printf("Invalid argument for \'%s\': %s\n",
+					CMD_LINE_OPT_MTU, optarg);
+				print_usage(prgname);
+				return -1;
+			}
+			frag_ttl_ns = ret;
+			break;
 		default:
 			print_usage(prgname);
 			return -1;
@@ -2324,8 +2344,8 @@ reassemble_lcore_init(struct lcore_conf *lc, uint32_t cid)
 
 	/* create fragment table */
 	sid = rte_lcore_to_socket_id(cid);
-	frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) /
-		MS_PER_S * FRAG_TTL_MS;
+	frag_cycles = (rte_get_tsc_hz() + NS_PER_S - 1) /
+		NS_PER_S * frag_ttl_ns;
 
 	lc->frag.tbl = rte_ip_frag_table_create(frag_tbl_sz,
 		FRAG_TBL_BUCKET_ENTRIES, frag_tbl_sz, frag_cycles, sid);
Signature · 1 line
2.17.1
#37 lore raw

PATCH v4 4/4 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.17.1
#38 lore raw

v5 cover add fallback session

In reply to Marcin Smoczynski

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

v4 to v5 changes:
- fix build errors related to frag TTL command line option and parse_decimal method

v3 to v4 changes:
- add info about packet reordering to the documentation regarding fallback session
- add patch with --frag-ttl command line option which allows to change fragment lifetime

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (4):
examples/ipsec-secgw: ipsec_sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add frag TTL cmdline option examples/ipsec-secgw: add offload fallback tests

 doc/guides/sample_app_ug/ipsec_secgw.rst      |  31 +++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  56 ++++--
 examples/ipsec-secgw/ipsec.c                  |  99 ++++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 164 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 11 files changed, 402 insertions(+), 177 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
Signature · 1 line
2.17.1
#39 lore raw

PATCH v5 1/4 examples/ipsec-secgw: ipsec_sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by on v5 1/4
#40 lore raw

Re: [dpdk-dev] [PATCH v5 1/4] examples/ipsec-secgw: ipsec_sa structure cleanup

Quoted 9 lines · Marcin Smoczynski

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Quoted 6 lines

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---

Tested-by on v5 1/4
#41 lore raw

Re: [dpdk-dev] [PATCH v5 1/4] examples/ipsec-secgw: ipsec_sa structure cleanup

In reply to Marcin Smoczynski

Hi Marcin,

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marcin Smoczynski
Sent: Friday, September 27, 2019 4:55 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [dpdk-dev] [PATCH v5 1/4] examples/ipsec-secgw: ipsec_sa structure cleanup

Minor nit.

./devtools/check-git-log.sh -1
Wrong headline format:
examples/ipsec-secgw: ipsec_sa structure cleanup

Quoted 9 lines

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Quoted 5 lines

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

#42 lore raw

PATCH v5 2/4 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Fallback session feature is not available in the legacy mode.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  24 ++++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +--
 examples/ipsec-secgw/ipsec.h             |  40 +++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 ++++++++++++------
 examples/ipsec-secgw/sa.c                | 110 +++++++++++++++++++----
 7 files changed, 225 insertions(+), 64 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +23 -1
index ad2d79e75..21b4b4418 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,28 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *lookaside-crypto-offload*
+   and fallback session is *lookaside-none*.
+
+   If used in conjunction with IPsec window, its width needs be increased
+   due to different processing times of inline and lookaside modes which
+   results in packet reordering.
+
+ * Optional: Yes.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol hardware offload
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +94 -16

235 lines not on this page · raw message

Signature · 1 line
2.17.1
#43 lore raw

Re: [dpdk-dev] [PATCH v5 2/4] examples/ipsec-secgw: add fallback session feature

Hi Marcin,

Quoted 15 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +1 -1
index ad2d79e75..21b4b4418 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 

doc/guides/sample_app_ug/ipsec_secgw.rst where each options means: · line 580

Quoted 8 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
@@ -573,6 +573,28 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *lookaside-crypto-offload*

You probably meant here 'inline-crypto-offload'?

Quoted 1 line
doc/guides/sample_app_ug/ipsec_secgw.rst +1 -0
+   and fallback session is *lookaside-none*.
#44 lore raw

Re: [dpdk-dev] [PATCH v5 2/4] examples/ipsec-secgw: add fallback session feature

Quoted 32 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Sunday, September 29, 2019 7:04 PM
To: Smoczynski, MarcinX <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v5 2/4] examples/ipsec-secgw: add fallback session feature

Hi Marcin,

Review

Quoted 2 lines
(quoted diff) +0 -0

b/doc/guides/sample_app_ug/ipsec_secgw.rst

Quoted 16 lines

index ad2d79e75..21b4b4418 100644

doc/guides/sample_app_ug/ipsec_secgw.rst +1 -1
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,28 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
Quoted 10 lines

doc/guides/sample_app_ug/ipsec_secgw.rst where each options means:

Quoted 5 lines
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *lookaside-crypto-

offload*

You probably meant here 'inline-crypto-offload'?

Quoted 1 line
doc/guides/sample_app_ug/ipsec_secgw.rst +1 -0
+   and fallback session is *lookaside-none*.

Yes, thanks.
Marcin.

Tested-by on v5 2/4
#45 lore raw

Re: [dpdk-dev] [PATCH v5 2/4] examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski
Quoted 25 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marcin Smoczynski
Sent: Friday, September 27, 2019 4:55 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [dpdk-dev] [PATCH v5 2/4] examples/ipsec-secgw: add fallback session feature

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol'
because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Quoted 4 lines

Fallback session feature is not available in the legacy mode.

#46 lore raw

PATCH v5 3/4 examples/ipsec-secgw: add frag TTL cmdline option

In reply to Marcin Smoczynski

Due to fragment loss on highly saturated links and long fragment lifetime, ipsec-secgw application quickly runs out of free reassembly buckets. As a result new fragments are being dropped.

Introduce --frag-ttl option which allow user to lower default fragment lifitime which solves problem of saturated reassembly buckets with high bandwidth fragmented traffic.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  7 +++++
 examples/ipsec-secgw/ipsec-secgw.c       | 40 ++++++++++++++++++------
 2 files changed, 37 insertions(+), 10 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +7 -0
index 21b4b4418..55b65d7bc 100644
@@ -154,6 +154,13 @@ Where:
     Incoming packets with length bigger then MTU will be discarded.
     Default value: 1500.
 
+*   ``--frag-ttl FRAG_TTL_NS``: fragment lifetime (in nanoseconds).
+    If packet is not reassembled within this time, received fragments
+    will be discarded. Fragment lifetime should be decreased when
+    there is a high fragmented traffic loss in high bandwidth networks.
+    Should be lower for for low number of reassembly buckets.
+    Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
+
 *   ``--reassemble NUM``: max number of entries in reassemble fragment table.
     Zero value disables reassembly functionality.
     Default value: 0.
examples/ipsec-secgw/ipsec-secgw.c +30 -10
index 641ed3767..1d415ace8 100644
@@ -112,7 +112,7 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 		0, 0)
 
 #define	FRAG_TBL_BUCKET_ENTRIES	4
-#define	FRAG_TTL_MS		(10 * MS_PER_S)
+#define	MAX_FRAG_TTL_NS		(10LL * NS_PER_S)
 
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
@@ -135,6 +135,7 @@ struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 #define CMD_LINE_OPT_TX_OFFLOAD		"txoffload"
 #define CMD_LINE_OPT_REASSEMBLE		"reassemble"
 #define CMD_LINE_OPT_MTU		"mtu"
+#define CMD_LINE_OPT_FRAG_TTL		"frag-ttl"
 
 enum {
 	/* long options mapped to a short option */
@@ -150,6 +151,7 @@ enum {
 	CMD_LINE_OPT_TX_OFFLOAD_NUM,
 	CMD_LINE_OPT_REASSEMBLE_NUM,
 	CMD_LINE_OPT_MTU_NUM,
+	CMD_LINE_OPT_FRAG_TTL_NUM,
 };
 
 static const struct option lgopts[] = {
@@ -160,6 +162,7 @@ static const struct option lgopts[] = {
 	{CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM},
 	{CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM},
 	{CMD_LINE_OPT_MTU, 1, 0, CMD_LINE_OPT_MTU_NUM},
+	{CMD_LINE_OPT_FRAG_TTL, 1, 0, CMD_LINE_OPT_FRAG_TTL_NUM},
 	{NULL, 0, 0, 0}
 };
 
@@ -186,6 +189,7 @@ static uint64_t dev_tx_offload = UINT64_MAX;
 static uint32_t frag_tbl_sz;
 static uint32_t frame_buf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
 static uint32_t mtu_size = RTE_ETHER_MTU;
+static uint64_t frag_ttl_ns = MAX_FRAG_TTL_NS;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
@@ -1302,6 +1306,9 @@ print_usage(const char *prgname)
 		": MTU value on all ports (default value: 1500)\n"
 		"    outgoing packets with bigger size will be fragmented\n"
 		"    incoming packets with bigger size will be discarded\n"
+		"  --" CMD_LINE_OPT_FRAG_TTL " FRAG_TTL_NS"
+		": fragments lifetime in nanoseconds, default\n"
+		"    and maximum value is 10.000.000.000 ns (10 s)\n"
 		"\n",
 		prgname);
 }
@@ -1338,14 +1345,15 @@ parse_portmask(const char *portmask)
 	return pm;
 }
 
-static int32_t
+static int64_t
 parse_decimal(const char *str)
 {
 	char *end = NULL;
-	unsigned long num;
+	uint64_t num;
 
-	num = strtoul(str, &end, 10);
-	if ((str[0] == '\0') || (end == NULL) || (*end != '\0'))
+	num = strtoull(str, &end, 10);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0')
+		|| num > INT64_MAX)
 		return -1;
 
 	return num;
@@ -1419,12 +1427,14 @@ print_app_sa_prm(const struct app_sa_prm *prm)
 	printf("replay window size: %u\n", prm->window_size);
 	printf("ESN: %s\n", (prm->enable_esn == 0) ? "disabled" : "enabled");
 	printf("SA flags: %#" PRIx64 "\n", prm->flags);
+	printf("Frag TTL: %" PRIu64 " ns\n", frag_ttl_ns);
 }
 
 static int32_t
 parse_args(int32_t argc, char **argv)
 {
-	int32_t opt, ret;
+	int opt;
+	int64_t ret;
 	char **argvopt;
 	int32_t option_index;
 	char *prgname = argv[0];
@@ -1503,7 +1513,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_SINGLE_SA_NUM:
 			ret = parse_decimal(optarg);
-			if (ret == -1) {
+			if (ret == -1 || ret > UINT32_MAX) {
 				printf("Invalid argument[sa_idx]\n");
 				print_usage(prgname);
 				return -1;
@@ -1546,7 +1556,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_REASSEMBLE_NUM:
 			ret = parse_decimal(optarg);
-			if (ret < 0) {
+			if (ret < 0 || ret > UINT32_MAX) {
 				printf("Invalid argument for \'%s\': %s\n",
 					CMD_LINE_OPT_REASSEMBLE, optarg);
 				print_usage(prgname);
@@ -1564,6 +1574,16 @@ parse_args(int32_t argc, char **argv)
 			}
 			mtu_size = ret;
 			break;
+		case CMD_LINE_OPT_FRAG_TTL_NUM:
+			ret = parse_decimal(optarg);
+			if (ret < 0 || ret > MAX_FRAG_TTL_NS) {
+				printf("Invalid argument for \'%s\': %s\n",
+					CMD_LINE_OPT_MTU, optarg);
+				print_usage(prgname);
+				return -1;
+			}
+			frag_ttl_ns = ret;
+			break;
 		default:
 			print_usage(prgname);
 			return -1;
@@ -2324,8 +2344,8 @@ reassemble_lcore_init(struct lcore_conf *lc, uint32_t cid)
 
 	/* create fragment table */
 	sid = rte_lcore_to_socket_id(cid);
-	frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) /
-		MS_PER_S * FRAG_TTL_MS;
+	frag_cycles = (rte_get_tsc_hz() + NS_PER_S - 1) /
+		NS_PER_S * frag_ttl_ns;
 
 	lc->frag.tbl = rte_ip_frag_table_create(frag_tbl_sz,
 		FRAG_TBL_BUCKET_ENTRIES, frag_tbl_sz, frag_cycles, sid);
Signature · 1 line
2.17.1
Acked-by Tested-by on v5 3/4
#47 lore raw

Re: [dpdk-dev] [PATCH v5 3/4] examples/ipsec-secgw: add frag TTL cmdline option

Quoted 7 lines

Due to fragment loss on highly saturated links and long fragment lifetime, ipsec-secgw application quickly runs out of free reassembly buckets. As a result new fragments are being dropped.

Quoted 6 lines

Introduce --frag-ttl option which allow user to lower default fragment lifitime which solves problem of saturated reassembly buckets with high bandwidth fragmented traffic.

---

Quoted 1 line

2.17.1

#48 lore raw

PATCH v5 4/4 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.17.1
Tested-by on v5 4/4
#49 lore raw

Re: [dpdk-dev] [PATCH v5 4/4] examples/ipsec-secgw: add offload fallback tests

Hi Marcin,

Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marcin Smoczynski
Sent: Friday, September 27, 2019 4:55 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [dpdk-dev] [PATCH v5 4/4] examples/ipsec-secgw: add offload fallback tests

Quoted 6 lines

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

The environment variable MULTI_SEG_TEST should be documented in the ipsec-secgw guide, section 49.6 Test directory, along side the other environment variables.

Quoted 2 lines
Quoted 82 lines
---
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)  create mode 100644
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +0 -0
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport

0:65535 #SA in rules sa in 7 aead_algo aes-128-gcm \ aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \ -mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}

sa in 9 aead_algo aes-128-gcm \
aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \ -
mode transport ${SGW_CFG_XPRM}

examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +1 -0
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
(quoted diff) +0 -0

secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh b/examples/ipsec- secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
new file mode 100644
index 000000000..875a7457d

examples/ipsec- new file +0 -0

secgw/test/trs_aesgcm_inline_crypto_fallback_defs.s +++ h

examples/ipsec- new file +5 -0
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback

lookaside-none'

examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +0 -0
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport

0:65535 #SA in rules sa in 7 aead_algo aes-128-gcm \ aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \ -mode ipv4- tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} +mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}

sa in 9 aead_algo aes-128-gcm \
aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \ -
mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}

#SA out rules
sa out 7 aead_algo aes-128-gcm \

(quoted diff) +0 -0

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh b/examples/ipsec- secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
new file mode 100644
index 000000000..696848432

examples/ipsec- new file +0 -0

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.s +++ h

examples/ipsec- new file +5 -0
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback
Quoted 3 lines

lookaside-none'
--
2.17.1

Regards,

Bernard.

#50 lore raw

v6 cover add fallback session

In reply to Marcin Smoczynski

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

v5 to v6 changes:
- add sanity check: fail to parse SA configuration if fallback session is configured but primary session is not inline crypto
- update documentation for ipsec-secgw tests (MULTI_SEG_TESTS var described)
- add release notes
- minor commit log changes

v4 to v5 changes:
- fix build errors related to frag TTL command line option and parse_decimal method

v3 to v4 changes:
- add info about packet reordering to the documentation regarding fallback session
- add patch with --frag-ttl command line option which allows to change fragment lifetime

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (4):
examples/ipsec-secgw: sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add frag TTL cmdline option examples/ipsec-secgw: add offload fallback tests

 doc/guides/rel_notes/release_19_11.rst        |   8 +
 doc/guides/sample_app_ug/ipsec_secgw.rst      |  36 +++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  56 ++++--
 examples/ipsec-secgw/ipsec.c                  |  99 +++++-----
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 +++++++-----
 examples/ipsec-secgw/sa.c                     | 170 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 12 files changed, 421 insertions(+), 177 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#51 lore raw

PATCH v6 1/4 examples/ipsec-secgw: sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 91 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 ++++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 137 insertions(+), 112 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +49 -42

261 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
#52 lore raw

PATCH v6 2/4 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Fallback session feature is not available in the legacy mode.

---
 doc/guides/rel_notes/release_19_11.rst   |   8 ++
 doc/guides/sample_app_ug/ipsec_secgw.rst |  24 ++++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +-
 examples/ipsec-secgw/ipsec.h             |  40 ++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 +++++++++++------
 examples/ipsec-secgw/sa.c                | 116 +++++++++++++++++++----
 8 files changed, 239 insertions(+), 64 deletions(-)
doc/guides/rel_notes/release_19_11.rst +8 -0
index 27cfbd9e3..f2ed040e9 100644
@@ -56,6 +56,14 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the IPSec library and IPsec Security Gateway application.**
+
+  Added the following features to ``librte_ipsec`` and the ``ipsec-secgw``
+  sample application:
+
+  * Support fragmented packets in inline crypto processing mode with fallback
+    lookaside session.
+
 
 Removed Items
 -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +23 -1
index ad2d79e75..45478e2a5 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,28 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. IPsec anti-replay window and ESN is supported with fallback
+   processing session only when primary session is *inline-crypto-offload*
+   and fallback session is *lookaside-none*.
+
+   If used in conjunction with IPsec window, its width needs be increased
+   due to different processing times of inline and lookaside modes which
+   results in packet reordering.
+
+ * Optional: Yes.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+   * *lookaside-protocol*: lookaside protocol hardware offload
+
+ * Syntax:
+
+   * *fallback lookaside-none*
+   * *fallback lookaside-protocol*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index 0d1fd6af6..641ed3767 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1462,12 +1463,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2398,6 +2394,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 8c60bd84b..8b0441028 100644
@@ -404,7 +404,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -423,9 +423,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -586,7 +586,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -606,7 +606,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +100 -16

241 lines not on this page · raw message

Signature · 1 line
2.17.1
#53 lore raw

Re: [dpdk-dev] [PATCH v6 2/4] examples/ipsec-secgw: add fallback session feature

Hi All,

Quoted 10 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Quoted 9 lines

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Fallback session feature is not available in the legacy mode.

I started looking this patch, but some initial thoughts looking at the patch description.

When you say a fallback session will be a lookaside none or lookaside protocol, the packet will be processed asynchronously and might as well reorder.

The best possible solution for this would be the synchronous API which are in talks
in another patchset or use a SW PMD(eg. Openssl etc.) session and wait till you get the packet dequeued. So effectively async APIs will be used to behave synchronously.
You can not use hardware PMD session as it will perform very badly for fallback packets Because you have to wait till the packet is not getting dequeued back.

Having said that, you won't find a device or a scenario where you can use Inline crypto as primary and lookaside proto as fallback.
It can only be like inline crypto as primary and lookaside none as fallback.

BTW, I am ok with Patch 1/4 and 3/4. If no objections from the community, I can pick those.

-Akhil

Quoted 4 lines

---

#54 lore raw

Re: [dpdk-dev] [PATCH v6 2/4] examples/ipsec-secgw: add fallback session feature

Hi Akhil,

Quoted 17 lines
Quoted 17 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Quoted 6 lines
Quoted 2 lines

Fallback session feature is not available in the legacy mode.

I started looking this patch, but some initial thoughts looking at the patch description.

When you say a fallback session will be a lookaside none or lookaside protocol, the packet will be processed asynchronously and might as well reorder.

Yes, we documented it as one of limitations.
Though as I already mentioned for some use-cases some reordering it is acceptable.

Quoted 1 line

The best possible solution for this would be the synchronous API which are in talks

Agree, that would be a way to avoid reordering, but it is not there yet.

Quoted 4 lines

in another patchset or use a SW PMD(eg. Openssl etc.) session and wait till you get the packet dequeued. So effectively async APIs will be used to behave synchronously.
You can not use hardware PMD session as it will perform very badly for fallback packets Because you have to wait till the packet is not getting dequeued back.

We don't plan to support that model because of great performance penalty you mentioned.

Quoted 4 lines

Having said that, you won't find a device or a scenario where you can use Inline crypto as primary and lookaside proto as fallback.
It can only be like inline crypto as primary and lookaside none as fallback.

Yes, correct.
I thought that we already removed lookaside-proto from supported types. If we didn't - will certainly do that.

Quoted 2 lines

BTW, I am ok with Patch 1/4 and 3/4. If no objections from the community, I can pick those.

Great to hear.
What obstacles do you see with others two?
Konstantin

Quoted 7 lines

-Akhil

Quoted 4 lines

---

#55 lore raw

Re: [dpdk-dev] [PATCH v6 2/4] examples/ipsec-secgw: add fallback session feature

Hi Konstantin,

Quoted 23 lines

Hi Akhil,

Quoted 17 lines
Quoted 17 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Quoted 3 lines
Quoted 2 lines

Fallback session feature is not available in the legacy mode.

I started looking this patch, but some initial thoughts looking at the patch

Quoted 8 lines

description.

Quoted 3 lines

When you say a fallback session will be a lookaside none or lookaside protocol, the packet will be processed asynchronously and might as well reorder.

Yes, we documented it as one of limitations.
Though as I already mentioned for some use-cases some reordering it is acceptable.

Which usecases allow reordering. I think most stacks have replay window of less than 256/128 frames.

Quoted 7 lines
Quoted 2 lines

The best possible solution for this would be the synchronous API which are in

talks

Agree, that would be a way to avoid reordering, but it is not there yet.

Quoted 1 line

in another patchset or use a SW PMD(eg. Openssl etc.) session and wait till you

Quoted 8 lines

get the packet dequeued.

Quoted 2 lines

So effectively async APIs will be used to behave synchronously. You can not use hardware PMD session as it will perform very badly for

fallback packets

Quoted 1 line

Because you have to wait till the packet is not getting dequeued back.

We don't plan to support that model because of great performance penalty you mentioned.

So what is currently supported with this patchset.
- cpu crypto is not there yet.
- SW PMD you are not supporting that model.

Quoted 11 lines
Quoted 5 lines

Having said that, you won't find a device or a scenario where you can use Inline crypto as primary and lookaside proto as fallback.
It can only be like inline crypto as primary and lookaside none as fallback.

Yes, correct.
I thought that we already removed lookaside-proto from supported types. If we didn't - will certainly do that.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

BTW, I am ok with Patch 1/4 and 3/4. If no objections from the community, I

can pick those.

Great to hear.
What obstacles do you see with others two?

I believe there are some discussion going on between you and Anoob.

Quoted 9 lines

Konstantin

Quoted 7 lines

-Akhil

Quoted 4 lines

---

#56 lore raw

Re: [dpdk-dev] [PATCH v6 2/4] examples/ipsec-secgw: add fallback session feature

Quoted 23 lines
Quoted 23 lines
Quoted 18 lines
Quoted 18 lines

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline processing allowing processing packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' or 'lookaside-protocol' parameter to an SA configuration.

Using IPsec anti-replay window or ESN feature with fallback session is not yet supported when primary session is of type 'inline-protocol-offload' or fallback session is 'lookaside-protocol' because SA sequence number is not synchronized between software and hardware sessions. Fallback sessions are also limited to ingress IPsec traffic.

Quoted 3 lines
Quoted 2 lines

Fallback session feature is not available in the legacy mode.

I started looking this patch, but some initial thoughts looking at the patch

description.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

When you say a fallback session will be a lookaside none or lookaside protocol, the packet will be processed asynchronously and might as well reorder.

Yes, we documented it as one of limitations.
Though as I already mentioned for some use-cases some reordering it is acceptable.

Which usecases allow reordering.

AFAIK, VoIP, video-streaming, netflow/ipfix, some P2P protocols - all of them tolerate packet reordering. Actually modern TCP implementations are also quite robust to packet reorderings
(till some extent of course).

Quoted 1 line

I think most stacks have replay window of less than 256/128 frames.

From our measurements, on IA boxes, ~256 seems good enough for many cases.

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

The best possible solution for this would be the synchronous API which are in

talks

Agree, that would be a way to avoid reordering, but it is not there yet.

Quoted 1 line

in another patchset or use a SW PMD(eg. Openssl etc.) session and wait till you

get the packet dequeued.

Quoted 2 lines

So effectively async APIs will be used to behave synchronously. You can not use hardware PMD session as it will perform very badly for

fallback packets

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Because you have to wait till the packet is not getting dequeued back.

We don't plan to support that model because of great performance penalty you mentioned.

So what is currently supported with this patchset.
- cpu crypto is not there yet.
- SW PMD you are not supporting that model.

ixbge(inline-crypto)+qat(lksd-crypto)

Quoted 12 lines
Quoted 12 lines
Quoted 6 lines

Having said that, you won't find a device or a scenario where you can use Inline crypto as primary and lookaside proto as fallback.
It can only be like inline crypto as primary and lookaside none as fallback.

Yes, correct.
I thought that we already removed lookaside-proto from supported types. If we didn't - will certainly do that.

Quoted 1 line
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

BTW, I am ok with Patch 1/4 and 3/4. If no objections from the community, I

can pick those.

Great to hear.
What obstacles do you see with others two?

I believe there are some discussion going on between you and Anoob.

Seems too vague...
Anything concrete?
Konstantin

#57 lore raw

PATCH v6 3/4 examples/ipsec-secgw: add frag TTL cmdline option

In reply to Marcin Smoczynski

Due to fragment loss on highly saturated links and long fragment lifetime, ipsec-secgw application quickly runs out of free reassembly buckets. As a result new fragments are being dropped.

Introduce --frag-ttl option which allow user to lower default fragment lifitime which solves problem of saturated reassembly buckets with high bandwidth fragmented traffic.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  7 +++++
 examples/ipsec-secgw/ipsec-secgw.c       | 40 ++++++++++++++++++------
 2 files changed, 37 insertions(+), 10 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +7 -0
index 45478e2a5..279ad4126 100644
@@ -154,6 +154,13 @@ Where:
     Incoming packets with length bigger then MTU will be discarded.
     Default value: 1500.
 
+*   ``--frag-ttl FRAG_TTL_NS``: fragment lifetime (in nanoseconds).
+    If packet is not reassembled within this time, received fragments
+    will be discarded. Fragment lifetime should be decreased when
+    there is a high fragmented traffic loss in high bandwidth networks.
+    Should be lower for for low number of reassembly buckets.
+    Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
+
 *   ``--reassemble NUM``: max number of entries in reassemble fragment table.
     Zero value disables reassembly functionality.
     Default value: 0.
examples/ipsec-secgw/ipsec-secgw.c +30 -10
index 641ed3767..1d415ace8 100644
@@ -112,7 +112,7 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 		0, 0)
 
 #define	FRAG_TBL_BUCKET_ENTRIES	4
-#define	FRAG_TTL_MS		(10 * MS_PER_S)
+#define	MAX_FRAG_TTL_NS		(10LL * NS_PER_S)
 
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
@@ -135,6 +135,7 @@ struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 #define CMD_LINE_OPT_TX_OFFLOAD		"txoffload"
 #define CMD_LINE_OPT_REASSEMBLE		"reassemble"
 #define CMD_LINE_OPT_MTU		"mtu"
+#define CMD_LINE_OPT_FRAG_TTL		"frag-ttl"
 
 enum {
 	/* long options mapped to a short option */
@@ -150,6 +151,7 @@ enum {
 	CMD_LINE_OPT_TX_OFFLOAD_NUM,
 	CMD_LINE_OPT_REASSEMBLE_NUM,
 	CMD_LINE_OPT_MTU_NUM,
+	CMD_LINE_OPT_FRAG_TTL_NUM,
 };
 
 static const struct option lgopts[] = {
@@ -160,6 +162,7 @@ static const struct option lgopts[] = {
 	{CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM},
 	{CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM},
 	{CMD_LINE_OPT_MTU, 1, 0, CMD_LINE_OPT_MTU_NUM},
+	{CMD_LINE_OPT_FRAG_TTL, 1, 0, CMD_LINE_OPT_FRAG_TTL_NUM},
 	{NULL, 0, 0, 0}
 };
 
@@ -186,6 +189,7 @@ static uint64_t dev_tx_offload = UINT64_MAX;
 static uint32_t frag_tbl_sz;
 static uint32_t frame_buf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
 static uint32_t mtu_size = RTE_ETHER_MTU;
+static uint64_t frag_ttl_ns = MAX_FRAG_TTL_NS;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
@@ -1302,6 +1306,9 @@ print_usage(const char *prgname)
 		": MTU value on all ports (default value: 1500)\n"
 		"    outgoing packets with bigger size will be fragmented\n"
 		"    incoming packets with bigger size will be discarded\n"
+		"  --" CMD_LINE_OPT_FRAG_TTL " FRAG_TTL_NS"
+		": fragments lifetime in nanoseconds, default\n"
+		"    and maximum value is 10.000.000.000 ns (10 s)\n"
 		"\n",
 		prgname);
 }
@@ -1338,14 +1345,15 @@ parse_portmask(const char *portmask)
 	return pm;
 }
 
-static int32_t
+static int64_t
 parse_decimal(const char *str)
 {
 	char *end = NULL;
-	unsigned long num;
+	uint64_t num;
 
-	num = strtoul(str, &end, 10);
-	if ((str[0] == '\0') || (end == NULL) || (*end != '\0'))
+	num = strtoull(str, &end, 10);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0')
+		|| num > INT64_MAX)
 		return -1;
 
 	return num;
@@ -1419,12 +1427,14 @@ print_app_sa_prm(const struct app_sa_prm *prm)
 	printf("replay window size: %u\n", prm->window_size);
 	printf("ESN: %s\n", (prm->enable_esn == 0) ? "disabled" : "enabled");
 	printf("SA flags: %#" PRIx64 "\n", prm->flags);
+	printf("Frag TTL: %" PRIu64 " ns\n", frag_ttl_ns);
 }
 
 static int32_t
 parse_args(int32_t argc, char **argv)
 {
-	int32_t opt, ret;
+	int opt;
+	int64_t ret;
 	char **argvopt;
 	int32_t option_index;
 	char *prgname = argv[0];
@@ -1503,7 +1513,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_SINGLE_SA_NUM:
 			ret = parse_decimal(optarg);
-			if (ret == -1) {
+			if (ret == -1 || ret > UINT32_MAX) {
 				printf("Invalid argument[sa_idx]\n");
 				print_usage(prgname);
 				return -1;
@@ -1546,7 +1556,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_REASSEMBLE_NUM:
 			ret = parse_decimal(optarg);
-			if (ret < 0) {
+			if (ret < 0 || ret > UINT32_MAX) {
 				printf("Invalid argument for \'%s\': %s\n",
 					CMD_LINE_OPT_REASSEMBLE, optarg);
 				print_usage(prgname);
@@ -1564,6 +1574,16 @@ parse_args(int32_t argc, char **argv)
 			}
 			mtu_size = ret;
 			break;
+		case CMD_LINE_OPT_FRAG_TTL_NUM:
+			ret = parse_decimal(optarg);
+			if (ret < 0 || ret > MAX_FRAG_TTL_NS) {
+				printf("Invalid argument for \'%s\': %s\n",
+					CMD_LINE_OPT_MTU, optarg);
+				print_usage(prgname);
+				return -1;
+			}
+			frag_ttl_ns = ret;
+			break;
 		default:
 			print_usage(prgname);
 			return -1;
@@ -2324,8 +2344,8 @@ reassemble_lcore_init(struct lcore_conf *lc, uint32_t cid)
 
 	/* create fragment table */
 	sid = rte_lcore_to_socket_id(cid);
-	frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) /
-		MS_PER_S * FRAG_TTL_MS;
+	frag_cycles = (rte_get_tsc_hz() + NS_PER_S - 1) /
+		NS_PER_S * frag_ttl_ns;
 
 	lc->frag.tbl = rte_ip_frag_table_create(frag_tbl_sz,
 		FRAG_TBL_BUCKET_ENTRIES, frag_tbl_sz, frag_cycles, sid);
Signature · 1 line
2.17.1
#58 lore raw

PATCH v6 4/4 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 doc/guides/sample_app_ug/ipsec_secgw.rst                    | 5 +++++
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 5 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
index 279ad4126..0dc81fbb4 100644
@@ -755,6 +755,11 @@ Also the user can optionally setup:
 *   ``CRYPTO_DEV``: crypto device to be used ('-w <pci-id>'). If none specified
     appropriate vdevs will be created by the script
 
+*   ``MULTI_SEG_TEST``: ipsec-secgw option to enable reassembly support and
+    specify size of reassembly table (e.g.
+    ``MULTI_SEG_TEST='--reassemble 128'``). This option must be set for
+    fallback session tests.
+
 Note that most of the tests require the appropriate crypto PMD/device to be
 available.
 
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.17.1
#59 lore raw

v7 cover add fallback session

In reply to Marcin Smoczynski

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

v6 to v7 changes:
- remove partial support for "*-protocol" fall-back session types
- rebase on master (31b798a)

v5 to v6 changes:
- add sanity check: fail to parse SA configuration if fallback session is configured but primary session is not inline crypto
- update documentation for ipsec-secgw tests (MULTI_SEG_TESTS var described)
- add release notes
- minor commit log changes

v4 to v5 changes:
- fix build errors related to frag TTL command line option and parse_decimal method

v3 to v4 changes:
- add info about packet reordering to the documentation regarding fallback session
- add patch with --frag-ttl command line option which allows to change fragment lifetime

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (4):
examples/ipsec-secgw: sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add frag TTL cmdline option examples/ipsec-secgw: add offload fallback tests

 doc/guides/rel_notes/release_19_11.rst        |   8 +
 doc/guides/sample_app_ug/ipsec_secgw.rst      |  34 +++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  56 ++++--
 examples/ipsec-secgw/ipsec.c                  | 101 +++++------
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 ++++++++-----
 examples/ipsec-secgw/sa.c                     | 159 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 12 files changed, 409 insertions(+), 178 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

#60 lore raw

PATCH v7 1/4 examples/ipsec-secgw: sa structure cleanup

Cleanup ipsec_sa structure by removing every field that is already in the rte_ipsec_session structure:
* cryptodev/security session union
* action type
* offload flags
* security context
References to abovementioned fields are changed to direct references to matching fields of rte_ipsec_session structure.

Such refactoring is needed to introduce many sessions per SA feature, e.g. fallback session for inline offload processing.

---
 examples/ipsec-secgw/esp.c           | 35 +++++++----
 examples/ipsec-secgw/ipsec.c         | 93 +++++++++++++++-------------
 examples/ipsec-secgw/ipsec.h         | 27 +++++---
 examples/ipsec-secgw/ipsec_process.c | 30 ++++-----
 examples/ipsec-secgw/sa.c            | 66 ++++++++++----------
 5 files changed, 138 insertions(+), 113 deletions(-)
examples/ipsec-secgw/esp.c +23 -12
index d6d7b1256..c1b49da1e 100644
@@ -30,7 +30,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	int32_t payload_len, ip_hdr_len;
 
 	RTE_ASSERT(sa != NULL);
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
+	if (ipsec_get_action_type(sa) ==
+			RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)
 		return 0;
 
 	RTE_ASSERT(m != NULL);
@@ -148,13 +149,16 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	uint8_t *nexthdr, *pad_len;
 	uint8_t *padding;
 	uint16_t i;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	ips = ipsec_get_session(sa);
+
+	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		if (m->ol_flags & PKT_RX_SEC_OFFLOAD) {
 			if (m->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED)
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -169,8 +173,8 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -1;
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	    sa->ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		ips->security.ol_flags & RTE_SECURITY_RX_HW_TRAILER_OFFLOAD) {
 		nexthdr = &m->inner_esp_next_proto;
 	} else {
 		nexthdr = rte_pktmbuf_mtod_offset(m, uint8_t*,
@@ -225,10 +229,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	struct rte_crypto_sym_op *sym_cop;
 	int32_t i;
 	uint16_t pad_payload_len, pad_len, ip_hdr_len;
+	struct rte_ipsec_session *ips;
 
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
+	ips = ipsec_get_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
@@ -277,9 +283,10 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	}
 
 	/* Add trailer padding if it is not constructed by HW */
-	if (sa->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-	    (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
-	     !(sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
+	if (ips->type != RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+		(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO &&
+		 !(ips->security.ol_flags &
+			 RTE_SECURITY_TX_HW_TRAILER_OFFLOAD))) {
 		padding = (uint8_t *)rte_pktmbuf_append(m, pad_len +
 							sa->digest_len);
 		if (unlikely(padding == NULL)) {
@@ -344,8 +351,9 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		}
 	}
 
-	if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
-		if (sa->ol_flags & RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
+	if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO) {
+		if (ips->security.ol_flags &
+				RTE_SECURITY_TX_HW_TRAILER_OFFLOAD) {
 			/* Set the inner esp next protocol for HW trailer */
 			m->inner_esp_next_proto = nlp;
 			m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
@@ -448,11 +456,14 @@ esp_outbound_post(struct rte_mbuf *m,
 		  struct ipsec_sa *sa,
 		  struct rte_crypto_op *cop)
 {
+	enum rte_security_session_action_type type;
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	if ((sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
-			(sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
+	type = ipsec_get_action_type(sa);
+
+	if ((type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
+			(type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
 		m->ol_flags |= PKT_TX_SEC_OFFLOAD;
 	} else {
 		RTE_ASSERT(cop != NULL);
examples/ipsec-secgw/ipsec.c +50 -43

268 lines not on this page · raw message

examples/ipsec-secgw/ipsec.h +18 -9
index 1efa6e488..a4ad81b0e 100644
@@ -87,10 +87,6 @@ struct ipsec_sa {
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
-	union {
-		struct rte_cryptodev_sym_session *crypto_session;
-		struct rte_security_session *sec_session;
-	};
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -114,11 +110,8 @@ struct ipsec_sa {
 		struct rte_crypto_sym_xform *xforms;
 		struct rte_security_ipsec_xform *sec_xform;
 	};
-	enum rte_security_session_action_type type;
 	enum rte_security_ipsec_sa_direction direction;
 	uint16_t portid;
-	struct rte_security_ctx *security_ctx;
-	uint32_t ol_flags;
 
 #define MAX_RTE_FLOW_PATTERN (4)
 #define MAX_RTE_FLOW_ACTIONS (3)
@@ -284,6 +277,20 @@ get_sym_cop(struct rte_crypto_op *cop)
 	return (cop + 1);
 }
 
+static inline struct rte_ipsec_session *
+ipsec_get_session(struct ipsec_sa *sa)
+{
+	return &sa->ips;
+}
+
+static inline enum rte_security_session_action_type
+ipsec_get_action_type(struct ipsec_sa *sa)
+{
+	struct rte_ipsec_session *ips;
+	ips = ipsec_get_session(sa);
+	return ips->type;
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
@@ -338,9 +345,11 @@ void
 enqueue_cop_burst(struct cdev_qp *cqp);
 
 int
-create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa);
+create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 int
-create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa);
+create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
+		struct rte_ipsec_session *ips);
 
 #endif /* __IPSEC_H__ */
examples/ipsec-secgw/ipsec_process.c +12 -18
index 868f1a28d..239d81ef6 100644
@@ -94,22 +94,16 @@ fill_ipsec_session(struct rte_ipsec_session *ss, struct ipsec_ctx *ctx,
 
 	/* setup crypto section */
 	if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) {
-		if (sa->crypto_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->crypto.ses = sa->crypto_session;
+		RTE_ASSERT(ss->crypto.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	/* setup session action type */
-	} else if (sa->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
-		if (sa->sec_session == NULL) {
-			rc = create_lookaside_session(ctx, sa);
-			if (rc != 0)
-				return rc;
-		}
-		ss->security.ses = sa->sec_session;
-		ss->security.ctx = sa->security_ctx;
-		ss->security.ol_flags = sa->ol_flags;
+	} else if (ss->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+		RTE_ASSERT(ss->security.ses == NULL);
+		rc = create_lookaside_session(ctx, sa, ss);
+		if (rc != 0)
+			return rc;
 	} else
 		RTE_ASSERT(0);
 
@@ -218,7 +212,7 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 		pg = grp + i;
 		sa = pg->id.ptr;
 
-		ips = &sa->ips;
+		ips = ipsec_get_session(sa);
 
 		/* no valid HW session for that SA, try to create one */
 		if (sa == NULL || (ips->crypto.ses == NULL &&
@@ -226,8 +220,8 @@ ipsec_process(struct ipsec_ctx *ctx, struct ipsec_traffic *trf)
 			k = 0;
 
 		/* process packets inline */
-		else if (sa->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-				sa->type ==
+		else if (ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
+				ips->type ==
 				RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) {
 
 			satp = rte_ipsec_sa_type(ips->sa);
examples/ipsec-secgw/sa.c +35 -31

187 lines not on this page · raw message

Signature · 1 line
2.17.1
#61 lore raw

PATCH v7 2/4 examples/ipsec-secgw: add fallback session feature

In reply to Marcin Smoczynski

Inline processing is limited to a specified subset of traffic. It is often unable to handle more complicated situations, such as fragmented traffic. When using inline processing such traffic is dropped.

Introduce fallback session for inline crypto processing allowing handling packets that normally would be dropped. A fallback session is configured by adding 'fallback' keyword with 'lookaside-none' parameter to an SA configuration. Only 'inline-crypto-offload" as a primary session and 'lookaside-none' as a fall-back session combination is supported by this patch.

Fallback session feature is not available in the legacy mode.

---
 doc/guides/rel_notes/release_19_11.rst   |   8 ++
 doc/guides/sample_app_ug/ipsec_secgw.rst |  22 ++++-
 examples/ipsec-secgw/esp.c               |   4 +-
 examples/ipsec-secgw/ipsec-secgw.c       |  16 ++--
 examples/ipsec-secgw/ipsec.c             |  10 +--
 examples/ipsec-secgw/ipsec.h             |  40 +++++++--
 examples/ipsec-secgw/ipsec_process.c     |  85 ++++++++++++------
 examples/ipsec-secgw/sa.c                | 105 +++++++++++++++++++----
 8 files changed, 226 insertions(+), 64 deletions(-)
doc/guides/rel_notes/release_19_11.rst +8 -0
index 85953b962..7e1205be7 100644
@@ -115,6 +115,14 @@ New Features
   Added eBPF JIT support for arm64 architecture to improve the eBPF program
   performance.
 
+* **Updated the IPSec library and IPsec Security Gateway application.**
+
+  Added the following features to ``librte_ipsec`` and the ``ipsec-secgw``
+  sample application:
+
+  * Support fragmented packets in inline crypto processing mode with fallback
+    ``lookaside-none`` session.
+
 
 Removed Items
 -------------
doc/guides/sample_app_ug/ipsec_secgw.rst +21 -1
index ad2d79e75..cb6fadb35 100644
@@ -401,7 +401,7 @@ The SA rule syntax is shown as follows:
 .. code-block:: console
 
     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
-    <mode> <src_ip> <dst_ip> <action_type> <port_id>
+    <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
 
 where each options means:
 
@@ -573,6 +573,26 @@ where each options means:
 
    * *port_id X* X is a valid device number in decimal
 
+ ``<fallback>``
+
+ * Action type for ingress IPsec packets that inline processor failed to
+   process. Only a combination of *inline-crypto-offload* as a primary
+   session and *lookaside-none* as a fall-back session is supported at the
+   moment.
+
+   If used in conjunction with IPsec window, its width needs be increased
+   due to different processing times of inline and lookaside modes which
+   results in packet reordering.
+
+ * Optional: Yes.
+
+ * Available options:
+
+   * *lookaside-none*: use automatically chosen cryptodev to process packets
+
+ * Syntax:
+
+   * *fallback lookaside-none*
 
 Example SA rules:
 
examples/ipsec-secgw/esp.c +2 -2
index c1b49da1e..bfa7ff721 100644
@@ -155,7 +155,7 @@ esp_inbound_post(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(sa != NULL);
 	RTE_ASSERT(cop != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 
 	if ((ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL) ||
 			(ips->type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO)) {
@@ -234,7 +234,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	RTE_ASSERT(m != NULL);
 	RTE_ASSERT(sa != NULL);
 
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	ip_hdr_len = 0;
 
 	ip4 = rte_pktmbuf_mtod(m, struct ip *);
examples/ipsec-secgw/ipsec-secgw.c +10 -6
index f52ca5297..904ee65d9 100644
@@ -189,6 +189,7 @@ static uint32_t mtu_size = RTE_ETHER_MTU;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
+static const char *cfgfile;
 
 struct lcore_rx_queue {
 	uint16_t port_id;
@@ -1465,12 +1466,7 @@ parse_args(int32_t argc, char **argv)
 				print_usage(prgname);
 				return -1;
 			}
-			if (parse_cfg_file(optarg) < 0) {
-				printf("parsing file \"%s\" failed\n",
-					optarg);
-				print_usage(prgname);
-				return -1;
-			}
+			cfgfile = optarg;
 			f_present = 1;
 			break;
 		case 'j':
@@ -2418,6 +2414,14 @@ main(int32_t argc, char **argv)
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Invalid parameters\n");
 
+	/* parse configuration file */
+	if (parse_cfg_file(cfgfile) < 0) {
+		printf("parsing file \"%s\" failed\n",
+			optarg);
+		print_usage(argv[0]);
+		return -1;
+	}
+
 	if ((unprotected_port_mask & enabled_port_mask) !=
 			unprotected_port_mask)
 		rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
examples/ipsec-secgw/ipsec.c +5 -5
index 5b63a13fd..d7761e966 100644
@@ -430,7 +430,7 @@ enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 
 static inline void
 ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
-		struct rte_mbuf *pkts[], struct ipsec_sa *sas[],
+		struct rte_mbuf *pkts[], void *sas[],
 		uint16_t nb_pkts)
 {
 	int32_t ret = 0, i;
@@ -449,9 +449,9 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		rte_prefetch0(pkts[i]);
 
 		priv = get_priv(pkts[i]);
-		sa = sas[i];
+		sa = ipsec_mask_saptr(sas[i]);
 		priv->sa = sa;
-		ips = ipsec_get_session(sa);
+		ips = ipsec_get_primary_session(sa);
 
 		switch (ips->type) {
 		case RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
@@ -618,7 +618,7 @@ uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
 
@@ -638,7 +638,7 @@ uint16_t
 ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint32_t sa_idx[], uint16_t nb_pkts, uint16_t len)
 {
-	struct ipsec_sa *sas[nb_pkts];
+	void *sas[nb_pkts];
 
 	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +33 -7
index a4ad81b0e..8e075216c 100644
@@ -81,12 +81,32 @@ struct app_sa_prm {
 
 extern struct app_sa_prm app_sa_prm;
 
+enum {
+	IPSEC_SESSION_PRIMARY = 0,
+	IPSEC_SESSION_FALLBACK = 1,
+	IPSEC_SESSION_MAX
+};
+
+#define IPSEC_SA_OFFLOAD_FALLBACK_FLAG (1)
+
+static inline struct ipsec_sa *
+ipsec_mask_saptr(void *ptr)
+{
+	uintptr_t i = (uintptr_t)ptr;
+	static const uintptr_t mask = IPSEC_SA_OFFLOAD_FALLBACK_FLAG;
+
+	i &= ~mask;
+
+	return (struct ipsec_sa *)i;
+}
+
 struct ipsec_sa {
-	struct rte_ipsec_session ips; /* one session per sa for now */
+	struct rte_ipsec_session sessions[IPSEC_SESSION_MAX];
 	uint32_t spi;
 	uint32_t cdev_id_qp;
 	uint64_t seq;
 	uint32_t salt;
+	uint32_t fallback_sessions;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	enum rte_crypto_aead_algorithm aead_algo;
@@ -210,7 +230,7 @@ struct cnt_blk {
 struct traffic_type {
 	const uint8_t *data[MAX_PKT_BURST * 2];
 	struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-	struct ipsec_sa *saptr[MAX_PKT_BURST * 2];
+	void *saptr[MAX_PKT_BURST * 2];
 	uint32_t res[MAX_PKT_BURST * 2];
 	uint32_t num;
 };
@@ -278,16 +298,22 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 static inline struct rte_ipsec_session *
-ipsec_get_session(struct ipsec_sa *sa)
+ipsec_get_primary_session(struct ipsec_sa *sa)
+{
+	return &sa->sessions[IPSEC_SESSION_PRIMARY];
+}
+
+static inline struct rte_ipsec_session *
+ipsec_get_fallback_session(struct ipsec_sa *sa)
 {
-	return &sa->ips;
+	return &sa->sessions[IPSEC_SESSION_FALLBACK];
 }
 
 static inline enum rte_security_session_action_type
 ipsec_get_action_type(struct ipsec_sa *sa)
 {
 	struct rte_ipsec_session *ips;
-	ips = ipsec_get_session(sa);
+	ips = ipsec_get_primary_session(sa);
 	return ips->type;
 }
 
@@ -296,11 +322,11 @@ inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
 void
 inbound_sa_lookup(struct sa_ctx *sa_ctx, struct rte_mbuf *pkts[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 outbound_sa_lookup(struct sa_ctx *sa_ctx, uint32_t sa_idx[],
-		struct ipsec_sa *sa[], uint16_t nb_pkts);
+		void *sa[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/ipsec_process.c +58 -27

132 lines not on this page · raw message

examples/ipsec-secgw/sa.c +89 -16

230 lines not on this page · raw message

Signature · 1 line
2.17.1
#62 lore raw

PATCH v7 3/4 examples/ipsec-secgw: add frag TTL cmdline option

In reply to Marcin Smoczynski

Due to fragment loss on highly saturated links and long fragment lifetime, ipsec-secgw application quickly runs out of free reassembly buckets. As a result new fragments are being dropped.

Introduce --frag-ttl option which allow user to lower default fragment lifitime which solves problem of saturated reassembly buckets with high bandwidth fragmented traffic.

---
 doc/guides/sample_app_ug/ipsec_secgw.rst |  7 +++++
 examples/ipsec-secgw/ipsec-secgw.c       | 40 ++++++++++++++++++------
 2 files changed, 37 insertions(+), 10 deletions(-)
doc/guides/sample_app_ug/ipsec_secgw.rst +7 -0
index cb6fadb35..c1e8a0bda 100644
@@ -154,6 +154,13 @@ Where:
     Incoming packets with length bigger then MTU will be discarded.
     Default value: 1500.
 
+*   ``--frag-ttl FRAG_TTL_NS``: fragment lifetime (in nanoseconds).
+    If packet is not reassembled within this time, received fragments
+    will be discarded. Fragment lifetime should be decreased when
+    there is a high fragmented traffic loss in high bandwidth networks.
+    Should be lower for for low number of reassembly buckets.
+    Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
+
 *   ``--reassemble NUM``: max number of entries in reassemble fragment table.
     Zero value disables reassembly functionality.
     Default value: 0.
examples/ipsec-secgw/ipsec-secgw.c +30 -10
index 904ee65d9..b12936470 100644
@@ -112,7 +112,7 @@ static uint16_t nb_txd = IPSEC_SECGW_TX_DESC_DEFAULT;
 		0, 0)
 
 #define	FRAG_TBL_BUCKET_ENTRIES	4
-#define	FRAG_TTL_MS		(10 * MS_PER_S)
+#define	MAX_FRAG_TTL_NS		(10LL * NS_PER_S)
 
 #define MTU_TO_FRAMELEN(x)	((x) + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)
 
@@ -135,6 +135,7 @@ struct ethaddr_info ethaddr_tbl[RTE_MAX_ETHPORTS] = {
 #define CMD_LINE_OPT_TX_OFFLOAD		"txoffload"
 #define CMD_LINE_OPT_REASSEMBLE		"reassemble"
 #define CMD_LINE_OPT_MTU		"mtu"
+#define CMD_LINE_OPT_FRAG_TTL		"frag-ttl"
 
 enum {
 	/* long options mapped to a short option */
@@ -150,6 +151,7 @@ enum {
 	CMD_LINE_OPT_TX_OFFLOAD_NUM,
 	CMD_LINE_OPT_REASSEMBLE_NUM,
 	CMD_LINE_OPT_MTU_NUM,
+	CMD_LINE_OPT_FRAG_TTL_NUM,
 };
 
 static const struct option lgopts[] = {
@@ -160,6 +162,7 @@ static const struct option lgopts[] = {
 	{CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM},
 	{CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM},
 	{CMD_LINE_OPT_MTU, 1, 0, CMD_LINE_OPT_MTU_NUM},
+	{CMD_LINE_OPT_FRAG_TTL, 1, 0, CMD_LINE_OPT_FRAG_TTL_NUM},
 	{NULL, 0, 0, 0}
 };
 
@@ -186,6 +189,7 @@ static uint64_t dev_tx_offload = UINT64_MAX;
 static uint32_t frag_tbl_sz;
 static uint32_t frame_buf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
 static uint32_t mtu_size = RTE_ETHER_MTU;
+static uint64_t frag_ttl_ns = MAX_FRAG_TTL_NS;
 
 /* application wide librte_ipsec/SA parameters */
 struct app_sa_prm app_sa_prm = {.enable = 0};
@@ -1305,6 +1309,9 @@ print_usage(const char *prgname)
 		": MTU value on all ports (default value: 1500)\n"
 		"    outgoing packets with bigger size will be fragmented\n"
 		"    incoming packets with bigger size will be discarded\n"
+		"  --" CMD_LINE_OPT_FRAG_TTL " FRAG_TTL_NS"
+		": fragments lifetime in nanoseconds, default\n"
+		"    and maximum value is 10.000.000.000 ns (10 s)\n"
 		"\n",
 		prgname);
 }
@@ -1341,14 +1348,15 @@ parse_portmask(const char *portmask)
 	return pm;
 }
 
-static int32_t
+static int64_t
 parse_decimal(const char *str)
 {
 	char *end = NULL;
-	unsigned long num;
+	uint64_t num;
 
-	num = strtoul(str, &end, 10);
-	if ((str[0] == '\0') || (end == NULL) || (*end != '\0'))
+	num = strtoull(str, &end, 10);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0')
+		|| num > INT64_MAX)
 		return -1;
 
 	return num;
@@ -1422,12 +1430,14 @@ print_app_sa_prm(const struct app_sa_prm *prm)
 	printf("replay window size: %u\n", prm->window_size);
 	printf("ESN: %s\n", (prm->enable_esn == 0) ? "disabled" : "enabled");
 	printf("SA flags: %#" PRIx64 "\n", prm->flags);
+	printf("Frag TTL: %" PRIu64 " ns\n", frag_ttl_ns);
 }
 
 static int32_t
 parse_args(int32_t argc, char **argv)
 {
-	int32_t opt, ret;
+	int opt;
+	int64_t ret;
 	char **argvopt;
 	int32_t option_index;
 	char *prgname = argv[0];
@@ -1506,7 +1516,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_SINGLE_SA_NUM:
 			ret = parse_decimal(optarg);
-			if (ret == -1) {
+			if (ret == -1 || ret > UINT32_MAX) {
 				printf("Invalid argument[sa_idx]\n");
 				print_usage(prgname);
 				return -1;
@@ -1549,7 +1559,7 @@ parse_args(int32_t argc, char **argv)
 			break;
 		case CMD_LINE_OPT_REASSEMBLE_NUM:
 			ret = parse_decimal(optarg);
-			if (ret < 0) {
+			if (ret < 0 || ret > UINT32_MAX) {
 				printf("Invalid argument for \'%s\': %s\n",
 					CMD_LINE_OPT_REASSEMBLE, optarg);
 				print_usage(prgname);
@@ -1567,6 +1577,16 @@ parse_args(int32_t argc, char **argv)
 			}
 			mtu_size = ret;
 			break;
+		case CMD_LINE_OPT_FRAG_TTL_NUM:
+			ret = parse_decimal(optarg);
+			if (ret < 0 || ret > MAX_FRAG_TTL_NS) {
+				printf("Invalid argument for \'%s\': %s\n",
+					CMD_LINE_OPT_MTU, optarg);
+				print_usage(prgname);
+				return -1;
+			}
+			frag_ttl_ns = ret;
+			break;
 		default:
 			print_usage(prgname);
 			return -1;
@@ -2344,8 +2364,8 @@ reassemble_lcore_init(struct lcore_conf *lc, uint32_t cid)
 
 	/* create fragment table */
 	sid = rte_lcore_to_socket_id(cid);
-	frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) /
-		MS_PER_S * FRAG_TTL_MS;
+	frag_cycles = (rte_get_tsc_hz() + NS_PER_S - 1) /
+		NS_PER_S * frag_ttl_ns;
 
 	lc->frag.tbl = rte_ip_frag_table_create(frag_tbl_sz,
 		FRAG_TBL_BUCKET_ENTRIES, frag_tbl_sz, frag_cycles, sid);
Signature · 1 line
2.17.1
#63 lore raw

PATCH v7 4/4 examples/ipsec-secgw: add offload fallback tests

In reply to Marcin Smoczynski

Add tests for offload fallback feature; add inbound config modificator SGW_CFG_XPRM_IN (offload fallback setting can be set only for inbound SAs). Tests are using cryptodev for outbound SA.

To test fragmentation with QAT set:
MULTI_SEG_TEST="--reassemble=4096 --cryptodev_mask=0x5555"

---
 doc/guides/sample_app_ug/ipsec_secgw.rst                    | 5 +++++
 examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh         | 4 ++--
 .../test/trs_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh         | 6 ++++--
 .../test/tun_aesgcm_inline_crypto_fallback_defs.sh          | 5 +++++
 5 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh
doc/guides/sample_app_ug/ipsec_secgw.rst +5 -0
index c1e8a0bda..ae8cce235 100644
@@ -753,6 +753,11 @@ Also the user can optionally setup:
 *   ``CRYPTO_DEV``: crypto device to be used ('-w <pci-id>'). If none specified
     appropriate vdevs will be created by the script
 
+*   ``MULTI_SEG_TEST``: ipsec-secgw option to enable reassembly support and
+    specify size of reassembly table (e.g.
+    ``MULTI_SEG_TEST='--reassemble 128'``). This option must be set for
+    fallback session tests.
+
 Note that most of the tests require the appropriate crypto PMD/device to be
 available.
 
examples/ipsec-secgw/test/trs_aesgcm_common_defs.sh +2 -2
index f6c5bf5a7..17f2f86d2 100644
@@ -29,11 +29,11 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode transport ${SGW_CFG_XPRM}
+mode transport ${SGW_CFG_XPRM} ${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..875a7457d
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/trs_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +4 -2
index 278377967..7490baded 100644
@@ -29,11 +29,13 @@ sp ipv6 out esp bypass pri 1 sport 0:65535 dport 0:65535
 #SA in rules
 sa in 7 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM}
+mode ipv4-tunnel src ${REMOTE_IPV4} dst ${LOCAL_IPV4} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 sa in 9 aead_algo aes-128-gcm \
 aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
-mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM}
+mode ipv6-tunnel src ${REMOTE_IPV6} dst ${LOCAL_IPV6} ${SGW_CFG_XPRM} \
+${SGW_CFG_XPRM_IN}
 
 #SA out rules
 sa out 7 aead_algo aes-128-gcm \
examples/ipsec-secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh new file +5 -0
new file mode 100644
index 000000000..696848432
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+. ${DIR}/tun_aesgcm_defs.sh
+
+SGW_CFG_XPRM_IN='port_id 0 type inline-crypto-offload fallback lookaside-none'
Signature · 1 line
2.17.1
#64 lore raw

Re: [dpdk-dev] [PATCH v7 0/4] add fallback session

In reply to Marcin Smoczynski
Quoted 24 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marcin Smoczynski
Sent: Monday, October 14, 2019 2:49 PM
To: [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Smoczynski, MarcinX <[email protected]>
Subject: [dpdk-dev] [PATCH v7 0/4] add fallback session

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti- replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

Quoted 3 lines

v6 to v7 changes:
- remove partial support for "*-protocol" fall-back session types
- rebase on master (31b798a)

Hi Akhil,

What is the current status of this patchset. Will it be merged for RC1?

John

#65 lore raw

Re: [dpdk-dev] [PATCH v7 0/4] add fallback session

Quoted 17 lines
Quoted 17 lines

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti- replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

Quoted 4 lines
Quoted 3 lines

v6 to v7 changes:
- remove partial support for "*-protocol" fall-back session types
- rebase on master (31b798a)

Hi John,

Quoted 4 lines

Hi Akhil,

What is the current status of this patchset. Will it be merged for RC1?

Anoob had some issues in the patchset and I have not done thorough review of this patchset. So will be pushing it for RC2.

-Akhil

Applied
#66 lore raw

Re: [dpdk-dev] [PATCH v7 0/4] add fallback session

In reply to Marcin Smoczynski
Quoted 66 lines

Add fallback session feature allowing to process packets that inline processor is unable to handle (e.g. fragmented traffic). Processing takes place in a secondary session defined for SA in a configuration file.

This feature is limited to ingress IPsec traffic only. IPsec anti-replay window and ESN are supported in conjunction with fallback session when following conditions are met:
* primary session is 'inline-crypto-offload,
* fallback sessions is 'lookaside-none'.
Due to different processing times of inline and lookaside modes, fallback session introduces some packet reordering, therefore when using with IPsec window, its value should be increased.

v6 to v7 changes:
- remove partial support for "*-protocol" fall-back session types
- rebase on master (31b798a)

v5 to v6 changes:
- add sanity check: fail to parse SA configuration if fallback session is configured but primary session is not inline crypto
- update documentation for ipsec-secgw tests (MULTI_SEG_TESTS var described)
- add release notes
- minor commit log changes

v4 to v5 changes:
- fix build errors related to frag TTL command line option and parse_decimal method

v3 to v4 changes:
- add info about packet reordering to the documentation regarding fallback session
- add patch with --frag-ttl command line option which allows to change fragment lifetime

v2 to v3 changes:
- doc and commit log update - explicitly state feature limitations

v1 to v2 changes:
- disable fallback offload for outbound SAs
- add test scripts

Marcin Smoczynski (4):
examples/ipsec-secgw: sa structure cleanup examples/ipsec-secgw: add fallback session feature examples/ipsec-secgw: add frag TTL cmdline option examples/ipsec-secgw: add offload fallback tests

 doc/guides/rel_notes/release_19_11.rst        |   8 +
 doc/guides/sample_app_ug/ipsec_secgw.rst      |  34 +++-
 examples/ipsec-secgw/esp.c                    |  35 ++--
 examples/ipsec-secgw/ipsec-secgw.c            |  56 ++++--
 examples/ipsec-secgw/ipsec.c                  | 101 +++++------
 examples/ipsec-secgw/ipsec.h                  |  61 +++++--
 examples/ipsec-secgw/ipsec_process.c          | 113 ++++++++-----
 examples/ipsec-secgw/sa.c                     | 159 +++++++++++++-----
 .../test/trs_aesgcm_common_defs.sh            |   4 +-
 .../trs_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 .../test/tun_aesgcm_common_defs.sh            |   6 +-
 .../tun_aesgcm_inline_crypto_fallback_defs.sh |   5 +
 12 files changed, 409 insertions(+), 178 deletions(-)
 create mode 100644 examples/ipsec-
secgw/test/trs_aesgcm_inline_crypto_fallback_defs.sh
 create mode 100644 examples/ipsec-
Quoted 4 lines

secgw/test/tun_aesgcm_inline_crypto_fallback_defs.sh

--
2.17.1

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto
Release notes update merged with previous entry of IPsec changes.

Thanks.