Skip to contentSkip to conversation

fix SAD selection logic

PATCH Superseded Mariusz Drost 4 participants 15 messages Sep 5, 2019 – Oct 16, 2019

lore
Share & tools
lore
#0 lore raw

cover fix SAD selection logic

Code fix for SAD selection logic by splitting SAD into IPv4 SAD and IPv6 SAD. Test scripts updated to reflect changes.

Mariusz Drost (2):
examples/ipsec-secgw: fix SAD selection logic
examples/ipsec-secgw: tests for split SAD

 examples/ipsec-secgw/ipsec-secgw.c            |  48 ++-
 examples/ipsec-secgw/ipsec.c                  |   5 +-
 examples/ipsec-secgw/ipsec.h                  |  21 +-
 examples/ipsec-secgw/sa.c                     | 396 ++++++++++++------
 examples/ipsec-secgw/test/common_defs.sh      |   7 +-
 examples/ipsec-secgw/test/linux_test4.sh      |  78 ----
 examples/ipsec-secgw/test/linux_test6.sh      |  79 ----
 examples/ipsec-secgw/test/run_test.sh         |  42 +-
 .../ipsec-secgw/test/trs_3descbc_sha1_defs.sh |   7 +-
 .../test/trs_3descbc_sha1_esn_defs.sh         |   7 +-
 .../ipsec-secgw/test/trs_aescbc_sha1_defs.sh  |   7 +-
 .../test/trs_aescbc_sha1_esn_defs.sh          |   7 +-
 .../ipsec-secgw/test/trs_aesctr_sha1_defs.sh  |   7 +-
 .../test/trs_aesctr_sha1_esn_defs.sh          |   7 +-
 examples/ipsec-secgw/test/trs_aesgcm_defs.sh  |   7 +-
 .../ipsec-secgw/test/trs_aesgcm_esn_defs.sh   |   7 +-
 .../test/tun_3descbc_sha1_common_defs.sh      |  68 +++
 .../ipsec-secgw/test/tun_3descbc_sha1_defs.sh |  77 +++-
 .../test/tun_3descbc_sha1_esn_defs.sh         |  77 +++-
 .../test/tun_aescbc_sha1_common_defs.sh       |  64 +++
 .../ipsec-secgw/test/tun_aescbc_sha1_defs.sh  |  77 +++-
 .../test/tun_aescbc_sha1_esn_defs.sh          |  77 +++-
 .../test/tun_aesctr_sha1_common_defs.sh       |  64 +++
 .../ipsec-secgw/test/tun_aesctr_sha1_defs.sh  |  77 +++-
 .../test/tun_aesctr_sha1_esn_defs.sh          |  77 +++-
 .../test/tun_aesgcm_common_defs.sh            |  56 +++
 examples/ipsec-secgw/test/tun_aesgcm_defs.sh  |  77 +++-
 .../ipsec-secgw/test/tun_aesgcm_esn_defs.sh   |  77 +++-
 28 files changed, 1222 insertions(+), 378 deletions(-)
 delete mode 100644 examples/ipsec-secgw/test/linux_test4.sh
 delete mode 100644 examples/ipsec-secgw/test/linux_test6.sh
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 examples/ipsec-secgw: fix SAD selection logic

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/ipsec-secgw.c |  48 ++--
 examples/ipsec-secgw/ipsec.c       |   5 +-
 examples/ipsec-secgw/ipsec.h       |  21 +-
 examples/ipsec-secgw/sa.c          | 396 ++++++++++++++++++++---------
 4 files changed, 312 insertions(+), 158 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +27 -21
index 0d1fd6af6..2b0b8226b 100644
@@ -562,11 +562,10 @@ send_single_packet(struct rte_mbuf *m, uint16_t port, uint8_t proto)
 }
 
 static inline void
-inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
-		uint16_t lim)
+inbound_sp_sa(struct sp_ctx *sp, struct traffic_type *ip, uint16_t lim)
 {
 	struct rte_mbuf *m;
-	uint32_t i, j, res, sa_idx;
+	uint32_t i, j, res;
 
 	if (ip->num == 0 || sp == NULL)
 		return;
@@ -593,8 +592,7 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
 			continue;
 		}
 
-		sa_idx = SPI2IDX(res);
-		if (!inbound_sa_check(sa, m, sa_idx)) {
+		if (!inbound_sa_check(m, res)) {
 			rte_pktmbuf_free(m);
 			continue;
 		}
@@ -652,15 +650,16 @@ process_pkts_inbound(struct ipsec_ctx *ipsec_ctx,
 				traffic->ipsec.num, MAX_PKT_BURST);
 		split46_traffic(traffic, traffic->ipsec.pkts, nb_pkts_in);
 	} else {
-		inbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.pkts,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		inbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.pkts, traffic->ipsec.saptr,
+			traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 
-	inbound_sp_sa(ipsec_ctx->sp4_ctx, ipsec_ctx->sa_ctx, &traffic->ip4,
+	inbound_sp_sa(ipsec_ctx->sp4_ctx, &traffic->ip4,
 			n_ip4);
 
-	inbound_sp_sa(ipsec_ctx->sp6_ctx, ipsec_ctx->sa_ctx, &traffic->ip6,
+	inbound_sp_sa(ipsec_ctx->sp6_ctx, &traffic->ip6,
 			n_ip6);
 }
 
@@ -728,8 +727,9 @@ process_pkts_outbound(struct ipsec_ctx *ipsec_ctx,
 			}
 		}
 	} else {
-		outbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.res,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		outbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.res, traffic->ipsec.saptr,
+			traffic->ipsec.pkts, traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -770,8 +770,9 @@ process_pkts_inbound_nosp(struct ipsec_ctx *ipsec_ctx,
 			}
 		}
 	} else {
-		inbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.pkts,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		inbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.pkts, traffic->ipsec.saptr,
+			traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -823,8 +824,9 @@ process_pkts_outbound_nosp(struct ipsec_ctx *ipsec_ctx,
 				traffic->ip6.pkts[i] = traffic->ipsec.pkts[i];
 		}
 	} else {
-		outbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.res,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		outbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.res, traffic->ipsec.saptr,
+			traffic->ipsec.pkts, traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -1042,13 +1044,13 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf,
 
 	/* process ipv4 packets */
 	if (trf.ip4.num != 0) {
-		inbound_sp_sa(ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4, 0);
+		inbound_sp_sa(ctx->sp4_ctx, &trf.ip4, 0);
 		route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);
 	}
 
 	/* process ipv6 packets */
 	if (trf.ip6.num != 0) {
-		inbound_sp_sa(ctx->sp6_ctx, ctx->sa_ctx, &trf.ip6, 0);
+		inbound_sp_sa(ctx->sp6_ctx, &trf.ip6, 0);
 		route6_pkts(qconf->rt6_ctx, trf.ip6.pkts, trf.ip6.num);
 	}
 }
@@ -1109,14 +1111,16 @@ main_loop(__attribute__((unused)) void *dummy)
 	qconf->rt6_ctx = socket_ctx[socket_id].rt_ip6;
 	qconf->inbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_in;
 	qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
-	qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
+	qconf->inbound.sa4_ctx = socket_ctx[socket_id].sa_ip4_in;
+	qconf->inbound.sa6_ctx = socket_ctx[socket_id].sa_ip6_in;
 	qconf->inbound.cdev_map = cdev_map_in;
 	qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->inbound.session_priv_pool =
 			socket_ctx[socket_id].session_priv_pool;
 	qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
-	qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
+	qconf->outbound.sa4_ctx = socket_ctx[socket_id].sa_ip4_out;
+	qconf->outbound.sa6_ctx = socket_ctx[socket_id].sa_ip6_out;
 	qconf->outbound.cdev_map = cdev_map_out;
 	qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->outbound.session_priv_pool =
@@ -2481,8 +2485,10 @@ main(int32_t argc, char **argv)
 	for (i = 0; i < NB_SOCKETS && i < rte_socket_count(); i++) {
 		socket_id = rte_socket_id_by_idx(i);
 		if ((socket_ctx[socket_id].mbuf_pool != NULL) &&
-			(socket_ctx[socket_id].sa_in == NULL) &&
-			(socket_ctx[socket_id].sa_out == NULL)) {
+			(socket_ctx[socket_id].sa_ip4_in == NULL) &&
+			(socket_ctx[socket_id].sa_ip6_in == NULL) &&
+			(socket_ctx[socket_id].sa_ip4_out == NULL) &&
+			(socket_ctx[socket_id].sa_ip6_out == NULL)) {
 			sa_init(&socket_ctx[socket_id], socket_id);
 			sp4_init(&socket_ctx[socket_id], socket_id);
 			sp6_init(&socket_ctx[socket_id], socket_id);
examples/ipsec-secgw/ipsec.c +3 -2
index dc85adfe5..1d4cb3167 100644
@@ -581,7 +581,7 @@ ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 {
 	struct ipsec_sa *sas[nb_pkts];
 
-	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
+	inbound_sa_lookup(ctx->sa4_ctx, ctx->sa6_ctx, pkts, sas, nb_pkts);
 
 	ipsec_enqueue(esp_inbound, ctx, pkts, sas, nb_pkts);
 
@@ -601,7 +601,8 @@ ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 {
 	struct ipsec_sa *sas[nb_pkts];
 
-	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
+	outbound_sa_lookup(ctx->sa4_ctx, ctx->sa6_ctx, sa_idx, sas, pkts,
+			nb_pkts);
 
 	ipsec_enqueue(esp_outbound, ctx, pkts, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +13 -8
index 1efa6e488..736dec33b 100644
@@ -174,7 +174,8 @@ struct ipsec_ctx {
 	struct rte_hash *cdev_map;
 	struct sp_ctx *sp4_ctx;
 	struct sp_ctx *sp6_ctx;
-	struct sa_ctx *sa_ctx;
+	struct sa_ctx *sa4_ctx;
+	struct sa_ctx *sa6_ctx;
 	uint16_t nb_qps;
 	uint16_t last_qp;
 	struct cdev_qp tbl[MAX_QP_PER_LCORE];
@@ -194,8 +195,10 @@ struct cdev_key {
 };
 
 struct socket_ctx {
-	struct sa_ctx *sa_in;
-	struct sa_ctx *sa_out;
+	struct sa_ctx *sa_ip4_in;
+	struct sa_ctx *sa_ip4_out;
+	struct sa_ctx *sa_ip6_in;
+	struct sa_ctx *sa_ip6_out;
 	struct sp_ctx *sp_ip4_in;
 	struct sp_ctx *sp_ip4_out;
 	struct sp_ctx *sp_ip6_in;
@@ -285,15 +288,17 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 int
-inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
+inbound_sa_check(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);
+inbound_sa_lookup(struct sa_ctx *sa4_ctx, struct sa_ctx *sa6_ctx,
+		struct rte_mbuf *pkts[], struct ipsec_sa *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);
+outbound_sa_lookup(struct sa_ctx *sa4_ctx, struct sa_ctx *sa6_ctx,
+		uint32_t sa_idx[], struct ipsec_sa *sa[],
+		struct rte_mbuf *pkts[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/sa.c +269 -127

617 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 examples/ipsec-secgw: tests for split SAD

In reply to Mariusz Drost

Test scripts updated to reflect change of SAD (split into IPv4 SAD and IPv6 SAD). New parameter added to run_test.sh for performing tests with mixed IP version, eg. IPv4 ipsec tunnel with IPv6 traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/test/common_defs.sh      |  7 +-
 examples/ipsec-secgw/test/linux_test4.sh      | 78 ------------------
 examples/ipsec-secgw/test/linux_test6.sh      | 79 -------------------
 examples/ipsec-secgw/test/run_test.sh         | 42 +++++++---
 .../ipsec-secgw/test/trs_3descbc_sha1_defs.sh |  7 +-
 .../test/trs_3descbc_sha1_esn_defs.sh         |  7 +-
 .../ipsec-secgw/test/trs_aescbc_sha1_defs.sh  |  7 +-
 .../test/trs_aescbc_sha1_esn_defs.sh          |  7 +-
 .../ipsec-secgw/test/trs_aesctr_sha1_defs.sh  |  7 +-
 .../test/trs_aesctr_sha1_esn_defs.sh          |  7 +-
 examples/ipsec-secgw/test/trs_aesgcm_defs.sh  |  7 +-
 .../ipsec-secgw/test/trs_aesgcm_esn_defs.sh   |  7 +-
 .../test/tun_3descbc_sha1_common_defs.sh      | 68 ++++++++++++++++
 .../ipsec-secgw/test/tun_3descbc_sha1_defs.sh | 77 +++++++++++++++++-
 .../test/tun_3descbc_sha1_esn_defs.sh         | 77 +++++++++++++++++-
 .../test/tun_aescbc_sha1_common_defs.sh       | 64 +++++++++++++++
 .../ipsec-secgw/test/tun_aescbc_sha1_defs.sh  | 77 +++++++++++++++++-
 .../test/tun_aescbc_sha1_esn_defs.sh          | 77 +++++++++++++++++-
 .../test/tun_aesctr_sha1_common_defs.sh       | 64 +++++++++++++++
 .../ipsec-secgw/test/tun_aesctr_sha1_defs.sh  | 77 +++++++++++++++++-
 .../test/tun_aesctr_sha1_esn_defs.sh          | 77 +++++++++++++++++-
 .../test/tun_aesgcm_common_defs.sh            | 56 +++++++++++++
 examples/ipsec-secgw/test/tun_aesgcm_defs.sh  | 77 +++++++++++++++++-
 .../ipsec-secgw/test/tun_aesgcm_esn_defs.sh   | 77 +++++++++++++++++-
 24 files changed, 910 insertions(+), 220 deletions(-)
 delete mode 100644 examples/ipsec-secgw/test/linux_test4.sh
 delete mode 100644 examples/ipsec-secgw/test/linux_test6.sh
examples/ipsec-secgw/test/common_defs.sh +2 -5
index 09689af78..911857a60 100644
@@ -80,11 +80,8 @@ config_remote_iface()
 
 	ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE}
 
-	# by some reason following ip neigh doesn't work for me here properly:
-	#ssh ${REMOTE_HOST} ip neigh add ${LOCAL_IPV4} \
-	#		dev ${REMOTE_IFACE} lladr ${LOCAL_MAC}
-	# so used arp instead.
-	ssh ${REMOTE_HOST} arp -i ${REMOTE_IFACE} -s ${LOCAL_IPV4} ${LOCAL_MAC}
+	ssh ${REMOTE_HOST} ip neigh add ${LOCAL_IPV4} \
+			dev ${REMOTE_IFACE} lladdr ${LOCAL_MAC}
 	ssh ${REMOTE_HOST} ip neigh show dev ${REMOTE_IFACE}
 
 	ssh ${REMOTE_HOST} iptables --flush
examples/ipsec-secgw/test/linux_test4.sh deleted +0 -78

78 lines not on this page · raw message

examples/ipsec-secgw/test/linux_test6.sh deleted +0 -79

79 lines not on this page · raw message

examples/ipsec-secgw/test/run_test.sh +32 -10

88 lines not on this page · raw message

examples/ipsec-secgw/test/trs_3descbc_sha1_defs.sh +4 -3
index 31f94492f..b124d7888 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "cbc\(des3_ede\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_3descbc_sha1_esn_defs.sh +4 -3
index e4283f3dd..255acbb32 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "cbc\(des3_ede\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aescbc_sha1_defs.sh +4 -3
index d68552fce..55f696cbc 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc aes 0xdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aescbc_sha1_esn_defs.sh +4 -3
index ce7c977a3..851b38d59 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc aes 0xdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesctr_sha1_defs.sh +4 -3
index 73642f881..50f778ae5 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "rfc3686\(ctr\(aes\)\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesctr_sha1_esn_defs.sh +4 -3
index e401a4bed..88e2eed08 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "rfc3686\(ctr\(aes\)\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesgcm_defs.sh +4 -3
index 8382d3d52..c47578a38 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ aead "rfc4106\(gcm\(aes\)\)" \
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesgcm_esn_defs.sh +4 -3
index 94958d199..182f05a34 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ aead "rfc4106\(gcm\(aes\)\)" \
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/tun_3descbc_sha1_common_defs.sh +68 -0

71 lines not on this page · raw message

examples/ipsec-secgw/test/tun_3descbc_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_3descbc_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_common_defs.sh +64 -0

67 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_common_defs.sh +64 -0

67 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +56 -0

59 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_esn_defs.sh +74 -3

90 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

v2 cover fix SAD selection logic

In reply to Mariusz Drost

Code fix for SAD selection logic by splitting SAD into IPv4 SAD and IPv6 SAD. Test scripts updated to reflect changes.

v2:
* Added linux_test.sh
* Modified ep0.cfg and ep1.cfg files to run with ipsec-secgw app

Mariusz Drost (2):
examples/ipsec-secgw: fix SAD selection logic
examples/ipsec-secgw: tests for split SAD

 examples/ipsec-secgw/ep0.cfg                  |  58 ++-
 examples/ipsec-secgw/ep1.cfg                  |  62 ++-
 examples/ipsec-secgw/ipsec-secgw.c            |  48 ++-
 examples/ipsec-secgw/ipsec.c                  |   5 +-
 examples/ipsec-secgw/ipsec.h                  |  21 +-
 examples/ipsec-secgw/sa.c                     | 396 ++++++++++++------
 examples/ipsec-secgw/test/common_defs.sh      |   7 +-
 .../test/{linux_test6.sh => linux_test.sh}    |  94 ++++-
 examples/ipsec-secgw/test/linux_test4.sh      |  78 ----
 examples/ipsec-secgw/test/run_test.sh         |  42 +-
 .../ipsec-secgw/test/trs_3descbc_sha1_defs.sh |   7 +-
 .../test/trs_3descbc_sha1_esn_defs.sh         |   7 +-
 .../ipsec-secgw/test/trs_aescbc_sha1_defs.sh  |   7 +-
 .../test/trs_aescbc_sha1_esn_defs.sh          |   7 +-
 .../ipsec-secgw/test/trs_aesctr_sha1_defs.sh  |   7 +-
 .../test/trs_aesctr_sha1_esn_defs.sh          |   7 +-
 examples/ipsec-secgw/test/trs_aesgcm_defs.sh  |   7 +-
 .../ipsec-secgw/test/trs_aesgcm_esn_defs.sh   |   7 +-
 .../test/tun_3descbc_sha1_common_defs.sh      |  68 +++
 .../ipsec-secgw/test/tun_3descbc_sha1_defs.sh |  77 +++-
 .../test/tun_3descbc_sha1_esn_defs.sh         |  77 +++-
 .../test/tun_aescbc_sha1_common_defs.sh       |  64 +++
 .../ipsec-secgw/test/tun_aescbc_sha1_defs.sh  |  77 +++-
 .../test/tun_aescbc_sha1_esn_defs.sh          |  77 +++-
 .../test/tun_aesctr_sha1_common_defs.sh       |  64 +++
 .../ipsec-secgw/test/tun_aesctr_sha1_defs.sh  |  77 +++-
 .../test/tun_aesctr_sha1_esn_defs.sh          |  77 +++-
 .../test/tun_aesgcm_common_defs.sh            |  56 +++
 examples/ipsec-secgw/test/tun_aesgcm_defs.sh  |  77 +++-
 .../ipsec-secgw/test/tun_aesgcm_esn_defs.sh   |  77 +++-
 30 files changed, 1397 insertions(+), 338 deletions(-)
 rename examples/ipsec-secgw/test/{linux_test6.sh => linux_test.sh} (50%)
 delete mode 100644 examples/ipsec-secgw/test/linux_test4.sh
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 1/2 examples/ipsec-secgw: fix SAD selection logic

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/ipsec-secgw.c |  48 ++--
 examples/ipsec-secgw/ipsec.c       |   5 +-
 examples/ipsec-secgw/ipsec.h       |  21 +-
 examples/ipsec-secgw/sa.c          | 396 ++++++++++++++++++++---------
 4 files changed, 312 insertions(+), 158 deletions(-)
examples/ipsec-secgw/ipsec-secgw.c +27 -21
index 0d1fd6af6..2b0b8226b 100644
@@ -562,11 +562,10 @@ send_single_packet(struct rte_mbuf *m, uint16_t port, uint8_t proto)
 }
 
 static inline void
-inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
-		uint16_t lim)
+inbound_sp_sa(struct sp_ctx *sp, struct traffic_type *ip, uint16_t lim)
 {
 	struct rte_mbuf *m;
-	uint32_t i, j, res, sa_idx;
+	uint32_t i, j, res;
 
 	if (ip->num == 0 || sp == NULL)
 		return;
@@ -593,8 +592,7 @@ inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
 			continue;
 		}
 
-		sa_idx = SPI2IDX(res);
-		if (!inbound_sa_check(sa, m, sa_idx)) {
+		if (!inbound_sa_check(m, res)) {
 			rte_pktmbuf_free(m);
 			continue;
 		}
@@ -652,15 +650,16 @@ process_pkts_inbound(struct ipsec_ctx *ipsec_ctx,
 				traffic->ipsec.num, MAX_PKT_BURST);
 		split46_traffic(traffic, traffic->ipsec.pkts, nb_pkts_in);
 	} else {
-		inbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.pkts,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		inbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.pkts, traffic->ipsec.saptr,
+			traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 
-	inbound_sp_sa(ipsec_ctx->sp4_ctx, ipsec_ctx->sa_ctx, &traffic->ip4,
+	inbound_sp_sa(ipsec_ctx->sp4_ctx, &traffic->ip4,
 			n_ip4);
 
-	inbound_sp_sa(ipsec_ctx->sp6_ctx, ipsec_ctx->sa_ctx, &traffic->ip6,
+	inbound_sp_sa(ipsec_ctx->sp6_ctx, &traffic->ip6,
 			n_ip6);
 }
 
@@ -728,8 +727,9 @@ process_pkts_outbound(struct ipsec_ctx *ipsec_ctx,
 			}
 		}
 	} else {
-		outbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.res,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		outbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.res, traffic->ipsec.saptr,
+			traffic->ipsec.pkts, traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -770,8 +770,9 @@ process_pkts_inbound_nosp(struct ipsec_ctx *ipsec_ctx,
 			}
 		}
 	} else {
-		inbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.pkts,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		inbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.pkts, traffic->ipsec.saptr,
+			traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -823,8 +824,9 @@ process_pkts_outbound_nosp(struct ipsec_ctx *ipsec_ctx,
 				traffic->ip6.pkts[i] = traffic->ipsec.pkts[i];
 		}
 	} else {
-		outbound_sa_lookup(ipsec_ctx->sa_ctx, traffic->ipsec.res,
-			traffic->ipsec.saptr, traffic->ipsec.num);
+		outbound_sa_lookup(ipsec_ctx->sa4_ctx, ipsec_ctx->sa6_ctx,
+			traffic->ipsec.res, traffic->ipsec.saptr,
+			traffic->ipsec.pkts, traffic->ipsec.num);
 		ipsec_process(ipsec_ctx, traffic);
 	}
 }
@@ -1042,13 +1044,13 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf,
 
 	/* process ipv4 packets */
 	if (trf.ip4.num != 0) {
-		inbound_sp_sa(ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4, 0);
+		inbound_sp_sa(ctx->sp4_ctx, &trf.ip4, 0);
 		route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);
 	}
 
 	/* process ipv6 packets */
 	if (trf.ip6.num != 0) {
-		inbound_sp_sa(ctx->sp6_ctx, ctx->sa_ctx, &trf.ip6, 0);
+		inbound_sp_sa(ctx->sp6_ctx, &trf.ip6, 0);
 		route6_pkts(qconf->rt6_ctx, trf.ip6.pkts, trf.ip6.num);
 	}
 }
@@ -1109,14 +1111,16 @@ main_loop(__attribute__((unused)) void *dummy)
 	qconf->rt6_ctx = socket_ctx[socket_id].rt_ip6;
 	qconf->inbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_in;
 	qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
-	qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
+	qconf->inbound.sa4_ctx = socket_ctx[socket_id].sa_ip4_in;
+	qconf->inbound.sa6_ctx = socket_ctx[socket_id].sa_ip6_in;
 	qconf->inbound.cdev_map = cdev_map_in;
 	qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->inbound.session_priv_pool =
 			socket_ctx[socket_id].session_priv_pool;
 	qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
 	qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
-	qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
+	qconf->outbound.sa4_ctx = socket_ctx[socket_id].sa_ip4_out;
+	qconf->outbound.sa6_ctx = socket_ctx[socket_id].sa_ip6_out;
 	qconf->outbound.cdev_map = cdev_map_out;
 	qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
 	qconf->outbound.session_priv_pool =
@@ -2481,8 +2485,10 @@ main(int32_t argc, char **argv)
 	for (i = 0; i < NB_SOCKETS && i < rte_socket_count(); i++) {
 		socket_id = rte_socket_id_by_idx(i);
 		if ((socket_ctx[socket_id].mbuf_pool != NULL) &&
-			(socket_ctx[socket_id].sa_in == NULL) &&
-			(socket_ctx[socket_id].sa_out == NULL)) {
+			(socket_ctx[socket_id].sa_ip4_in == NULL) &&
+			(socket_ctx[socket_id].sa_ip6_in == NULL) &&
+			(socket_ctx[socket_id].sa_ip4_out == NULL) &&
+			(socket_ctx[socket_id].sa_ip6_out == NULL)) {
 			sa_init(&socket_ctx[socket_id], socket_id);
 			sp4_init(&socket_ctx[socket_id], socket_id);
 			sp6_init(&socket_ctx[socket_id], socket_id);
examples/ipsec-secgw/ipsec.c +3 -2
index dc85adfe5..1d4cb3167 100644
@@ -581,7 +581,7 @@ ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 {
 	struct ipsec_sa *sas[nb_pkts];
 
-	inbound_sa_lookup(ctx->sa_ctx, pkts, sas, nb_pkts);
+	inbound_sa_lookup(ctx->sa4_ctx, ctx->sa6_ctx, pkts, sas, nb_pkts);
 
 	ipsec_enqueue(esp_inbound, ctx, pkts, sas, nb_pkts);
 
@@ -601,7 +601,8 @@ ipsec_outbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 {
 	struct ipsec_sa *sas[nb_pkts];
 
-	outbound_sa_lookup(ctx->sa_ctx, sa_idx, sas, nb_pkts);
+	outbound_sa_lookup(ctx->sa4_ctx, ctx->sa6_ctx, sa_idx, sas, pkts,
+			nb_pkts);
 
 	ipsec_enqueue(esp_outbound, ctx, pkts, sas, nb_pkts);
 
examples/ipsec-secgw/ipsec.h +13 -8
index 1efa6e488..736dec33b 100644
@@ -174,7 +174,8 @@ struct ipsec_ctx {
 	struct rte_hash *cdev_map;
 	struct sp_ctx *sp4_ctx;
 	struct sp_ctx *sp6_ctx;
-	struct sa_ctx *sa_ctx;
+	struct sa_ctx *sa4_ctx;
+	struct sa_ctx *sa6_ctx;
 	uint16_t nb_qps;
 	uint16_t last_qp;
 	struct cdev_qp tbl[MAX_QP_PER_LCORE];
@@ -194,8 +195,10 @@ struct cdev_key {
 };
 
 struct socket_ctx {
-	struct sa_ctx *sa_in;
-	struct sa_ctx *sa_out;
+	struct sa_ctx *sa_ip4_in;
+	struct sa_ctx *sa_ip4_out;
+	struct sa_ctx *sa_ip6_in;
+	struct sa_ctx *sa_ip6_out;
 	struct sp_ctx *sp_ip4_in;
 	struct sp_ctx *sp_ip4_out;
 	struct sp_ctx *sp_ip6_in;
@@ -285,15 +288,17 @@ get_sym_cop(struct rte_crypto_op *cop)
 }
 
 int
-inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
+inbound_sa_check(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);
+inbound_sa_lookup(struct sa_ctx *sa4_ctx, struct sa_ctx *sa6_ctx,
+		struct rte_mbuf *pkts[], struct ipsec_sa *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);
+outbound_sa_lookup(struct sa_ctx *sa4_ctx, struct sa_ctx *sa6_ctx,
+		uint32_t sa_idx[], struct ipsec_sa *sa[],
+		struct rte_mbuf *pkts[], uint16_t nb_pkts);
 
 void
 sp4_init(struct socket_ctx *ctx, int32_t socket_id);
examples/ipsec-secgw/sa.c +269 -127

617 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by Tested-by on v2 1/2
#5 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Quoted 22 lines

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Quoted 5 lines

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
Quoted 2 lines

--
2.17.1

Acked-by on v2 1/2
#6 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

In reply to Mariusz Drost
Quoted 21 lines · MariuszX

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Quoted 6 lines

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")

---

#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

In reply to Mariusz Drost

Hi Mariusz,

Quoted 17 lines

-----Original Message-----
From: Mariusz Drost <[email protected]>
Sent: Tuesday, September 24, 2019 4:06 PM
To: [email protected]; Akhil Goyal <[email protected]>; [email protected]
Cc: [email protected]; Mariusz Drost <[email protected]>; Lukasz Bartosik <[email protected]>
Subject: [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Quoted 4 lines

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Can we have 2 different SAs with same SPI value and with different IPv4 addresses?

Will the IPSec library be able to handle this case. With Setkey it is possible in linux. Now that we have IPSEC library we should be compatible with what linux can do.

So splitting the SADB with IPv4 and IPv6 will just avoid the issue for IPv4 and IPv6 but the Issue will still be there. I believe this should be fixed in library rather than application maintaining Two different databases. Library's intent is to reduce the application overhead for maintaining IPSec specific stuff.

Quoted 21 lines

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/ipsec-secgw.c |  48 ++--
 examples/ipsec-secgw/ipsec.c       |   5 +-
 examples/ipsec-secgw/ipsec.h       |  21 +-
 examples/ipsec-secgw/sa.c          | 396 ++++++++++++++++++++---------
 4 files changed, 312 insertions(+), 158 deletions(-)
#8 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Hi Akhil,

Quoted 13 lines
Quoted 8 lines

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Quoted 4 lines

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Quoted 4 lines

Can we have 2 different SAs with same SPI value and with different IPv4 addresses?

Will the IPSec library be able to handle this case. With Setkey it is possible in linux. Now that we have IPSEC library we should be compatible with what linux can do.

For sure, SADB implementation has to be inside librte_ipsec.
In fact Vladimir submitted patches for that:
http://patches.dpdk.org/cover/60910/
I think we already looked at them.
We also plan to integrate it into ipsec-secgw, it would be a separate patch. We aim for 19.11 right now but might slip to 20.02.

This patch is not about improve/change ipsec-secgw SAD implementation, see description below.

Quoted 6 lines

So splitting the SADB with IPv4 and IPv6 will just avoid the issue for IPv4 and IPv6 but the Issue will still be there.
I believe this should be fixed in library rather than application maintaining Two different databases. Library's intent is to reduce the application overhead for maintaining IPSec specific stuff.

Probably we didn't put enough effort to describe the patch goals and methods. Let me try again:
Right now there is an inconsistency in ipsec-secgw behavior.
In some cases it allows two different IPv4 and IPv6 SP rules to refer to the same SPI (SA), in other it doesn't.
So for same config-file ipsec-secgw can either fail or not depending on
- legacy/library mode
- selected security action type

As an example with config file:

sp ipv4 in esp protect 11 pri 2 src 192.168.0.0/16 dst 192.168.0.0/16 sport 0:65535 dport 0:65535
sp ipv6 in esp protect 11 pri 2 src fd12:3456:789a:0031:0000:0000:0000:0092/64 dst fd12:3456:789a:0031:0000:0000:0000:0014/64 sport 0:65535 dport 0:65535 sa out 11 cipher_algo null auth_algo null mode transport
sa in 11 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 port_id 0 type inline-crypto-offload

library mode would fail to start, legacy mode would start but wouldn't be able to work correctly.

That is the issue that Lukasz reported:
https://bugs.dpdk.org/show_bug.cgi?id=239

The reason for that: in some cases we do need to know SA IP type (and SIP/DIP values) at SA creation time. The way ipsec-secgw obtains that information - search for given SPI value across SPDs (IPv4 and IPv6). So when it finds entries in both IPv4 and IPv6 it is not clear which one to use and exits with an error. To avoid such situation that patch does the following:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that
would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6.
For each one a separate rte_security/crypto session will be created and programmed.

As side effect of that - we have to split ipsec-secgw SADB into two, as right now it is just a raw array indexed by (SPI%N) value.

Quoted 22 lines
Quoted 22 lines

Split of SA entries is done at initialization stage. Most of given SA entries are checked against SPD. If matching entry is in IPv4 SPD, SA rule is added to IPv4 SAD (respectively for IPv6). Different splitting method is used only when SA entry is for tunnel in inbound direction. In that case if IPv4 tunnel should be used, SA entry is added to IPv4 SAD (respectively for IPv6). Reasoning is that inner IP version can be different than outer IP version for tunneled traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/ipsec-secgw.c |  48 ++--
 examples/ipsec-secgw/ipsec.c       |   5 +-
 examples/ipsec-secgw/ipsec.h       |  21 +-
 examples/ipsec-secgw/sa.c          | 396 ++++++++++++++++++++---------
 4 files changed, 312 insertions(+), 158 deletions(-)
#9 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Hi Konstantin,

Quoted 85 lines

Hi Akhil,

Quoted 8 lines
Quoted 8 lines

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Quoted 6 lines
Quoted 4 lines

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Can we have 2 different SAs with same SPI value and with different IPv4

addresses?

Quoted 2 lines

Will the IPSec library be able to handle this case. With Setkey it is possible in

linux.

Quoted 1 line

Now that we have IPSEC library we should be compatible with what linux can

do.

For sure, SADB implementation has to be inside librte_ipsec.
In fact Vladimir submitted patches for that:
http://patches.dpdk.org/cover/60910/
I think we already looked at them.
We also plan to integrate it into ipsec-secgw, it would be a separate patch. We aim for 19.11 right now but might slip to 20.02.

This patch is not about improve/change ipsec-secgw SAD implementation, see description below.

Quoted 2 lines

So splitting the SADB with IPv4 and IPv6 will just avoid the issue for IPv4 and

IPv6 but the

Quoted 3 lines

Issue will still be there.
I believe this should be fixed in library rather than application maintaining Two different databases. Library's intent is to reduce the application overhead

for maintaining

Quoted 1 line

IPSec specific stuff.

Probably we didn't put enough effort to describe the patch goals and methods. Let me try again:
Right now there is an inconsistency in ipsec-secgw behavior.
In some cases it allows two different IPv4 and IPv6 SP rules to refer to the same SPI (SA),
in other it doesn't.
So for same config-file ipsec-secgw can either fail or not depending on
- legacy/library mode
- selected security action type

As an example with config file:

sp ipv4 in esp protect 11 pri 2 src 192.168.0.0/16 dst 192.168.0.0/16 sport 0:65535 dport 0:65535
sp ipv6 in esp protect 11 pri 2 src fd12:3456:789a:0031:0000:0000:0000:0092/64 dst fd12:3456:789a:0031:0000:0000:0000:0014/64 sport 0:65535 dport 0:65535 sa out 11 cipher_algo null auth_algo null mode transport
sa in 11 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 port_id 0 type inline-crypto-offload

library mode would fail to start, legacy mode would start but wouldn't be able to work correctly.

That is the issue that Lukasz reported:
https://bugs.dpdk.org/show_bug.cgi?id=239

The reason for that: in some cases we do need to know SA IP type (and SIP/DIP values) at SA creation time.
The way ipsec-secgw obtains that information - search for given SPI value across SPDs (IPv4 and IPv6).
So when it finds entries in both IPv4 and IPv6 it is not clear which one to use and exits with an error.
To avoid such situation that patch does the following:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6.
For each one a separate rte_security/crypto session will be created and programmed.

Quoted 2 lines

As side effect of that - we have to split ipsec-secgw SADB into two, as right now it is just a raw array indexed by (SPI%N) value.

I got the intent of this patch in first place.
I agree that there is a bug in the current application, but this patch is not fixing it. Rather it is just avoiding it. I have seen the patch for the SAD support in IPSEC. That is the correct solution and we should pursue that. When you have that logic in place You would be replacing this code entirely.
You have time till RC2. Application patches are acceptable till RC2 which is close to 3 weeks from now.

Regards,
Akhil

#10 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Quoted 86 lines
Quoted 83 lines
Quoted 9 lines
Quoted 9 lines

Ipsec-secgw example application fails to initialize when using default configuration file (ep0.cfg) in library mode (librte_ipsec enabled).

The reason is that two of SP rules in ep0.cfg, one for IPv4 and one for IPv6, are using the same SPI number. When SA rules are initialized, their SPI number is checked against SPIs stored in SPD. For library mode, it is not allowed for the same SA to handle both IPv4 and IPv6.

Quoted 6 lines
Quoted 4 lines

Solution is to split SAD into two separate parts - one for IPv4 and one for IPv6. Usage of SAs stays the same. Only change is to pass correct SAD (IPv4 or IPv6) in places where previously combined database was passed.

Can we have 2 different SAs with same SPI value and with different IPv4

addresses?

Quoted 2 lines

Will the IPSec library be able to handle this case. With Setkey it is possible in

linux.

Quoted 1 line

Now that we have IPSEC library we should be compatible with what linux can

do.

For sure, SADB implementation has to be inside librte_ipsec.
In fact Vladimir submitted patches for that:
http://patches.dpdk.org/cover/60910/
I think we already looked at them.
We also plan to integrate it into ipsec-secgw, it would be a separate patch. We aim for 19.11 right now but might slip to 20.02.

This patch is not about improve/change ipsec-secgw SAD implementation, see description below.

Quoted 2 lines

So splitting the SADB with IPv4 and IPv6 will just avoid the issue for IPv4 and

IPv6 but the

Quoted 3 lines

Issue will still be there.
I believe this should be fixed in library rather than application maintaining Two different databases. Library's intent is to reduce the application overhead

for maintaining

Quoted 1 line

IPSec specific stuff.

Probably we didn't put enough effort to describe the patch goals and methods. Let me try again:
Right now there is an inconsistency in ipsec-secgw behavior.
In some cases it allows two different IPv4 and IPv6 SP rules to refer to the same SPI (SA),
in other it doesn't.
So for same config-file ipsec-secgw can either fail or not depending on
- legacy/library mode
- selected security action type

As an example with config file:

sp ipv4 in esp protect 11 pri 2 src 192.168.0.0/16 dst 192.168.0.0/16 sport 0:65535 dport 0:65535
sp ipv6 in esp protect 11 pri 2 src fd12:3456:789a:0031:0000:0000:0000:0092/64 dst fd12:3456:789a:0031:0000:0000:0000:0014/64 sport 0:65535 dport 0:65535 sa out 11 cipher_algo null auth_algo null mode transport
sa in 11 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 port_id 0 type inline-crypto-offload

library mode would fail to start, legacy mode would start but wouldn't be able to work correctly.

That is the issue that Lukasz reported:
https://bugs.dpdk.org/show_bug.cgi?id=239

The reason for that: in some cases we do need to know SA IP type (and SIP/DIP values) at SA creation time.
The way ipsec-secgw obtains that information - search for given SPI value across SPDs (IPv4 and IPv6).
So when it finds entries in both IPv4 and IPv6 it is not clear which one to use and exits with an error.
To avoid such situation that patch does the following:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6.
For each one a separate rte_security/crypto session will be created and programmed.

Quoted 2 lines

As side effect of that - we have to split ipsec-secgw SADB into two, as right now it is just a raw array indexed by (SPI%N) value.

Quoted 7 lines

I got the intent of this patch in first place.
I agree that there is a bug in the current application, but this patch is not fixing it. Rather it is just avoiding it. I have seen the patch for the SAD support in IPSEC. That is the correct solution and we should pursue that. When you have that logic in place You would be replacing this code entirely.
You have time till RC2. Application patches are acceptable till RC2 which is close to 3 weeks from now.

Ok, so to confirm:
Your only issue here is that patch is that we have to split ipsec-secgw SADB into two?

No objections to other part:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6.
For each one a separate rte_security/crypto session will be created and programmed. ?

Because, I think that part will still be needed even when will have new SAD in place. Konstantin

#11 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Quoted 15 lines

Ok, so to confirm:
Your only issue here is that patch is that we have to split ipsec-secgw SADB into two?

No objections to other part:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6. For each one a separate rte_security/crypto session will be created and programmed.
?

Quoted 2 lines

Because, I think that part will still be needed even when will have new SAD in place.

Agreed.

Quoted 2 lines

Konstantin

#12 lore raw

Re: [dpdk-dev] [PATCH v2 1/2] examples/ipsec-secgw: fix SAD selection logic

Quoted 17 lines
Quoted 17 lines

Ok, so to confirm:
Your only issue here is that patch is that we have to split ipsec-secgw SADB into two?

No objections to other part:
- search for given SPI value across both SPDs (IPv4 and IPv6)
- for each positive result create a new SA.
So if we have same SPI in both IPv4 and IPv6 SPDs instead of one SA that would be referred by both SPD tables (current situation),
we will create 2 independent SAs - one for IPv4, second for IPv6. For each one a separate rte_security/crypto session will be created and programmed.
?

Quoted 3 lines
Quoted 2 lines

Because, I think that part will still be needed even when will have new SAD in place.

Agreed.

Ok, then let's postpone this patch till new SAD will be in ipsec-secgw. Konstantin

#13 lore raw

PATCH v2 2/2 examples/ipsec-secgw: tests for split SAD

In reply to Mariusz Drost

Test scripts updated to reflect change of SAD (split into IPv4 SAD and IPv6 SAD). New parameter added to run_test.sh for performing tests with mixed IP version, eg. IPv4 ipsec tunnel with IPv6 traffic.

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")
---
 examples/ipsec-secgw/ep0.cfg                  | 58 ++++++++++--
 examples/ipsec-secgw/ep1.cfg                  | 62 +++++++++---
 examples/ipsec-secgw/test/common_defs.sh      |  7 +-
 .../test/{linux_test6.sh => linux_test.sh}    | 94 +++++++++++++++----
 examples/ipsec-secgw/test/linux_test4.sh      | 78 ---------------
 examples/ipsec-secgw/test/run_test.sh         | 42 +++++++--
 .../ipsec-secgw/test/trs_3descbc_sha1_defs.sh |  7 +-
 .../test/trs_3descbc_sha1_esn_defs.sh         |  7 +-
 .../ipsec-secgw/test/trs_aescbc_sha1_defs.sh  |  7 +-
 .../test/trs_aescbc_sha1_esn_defs.sh          |  7 +-
 .../ipsec-secgw/test/trs_aesctr_sha1_defs.sh  |  7 +-
 .../test/trs_aesctr_sha1_esn_defs.sh          |  7 +-
 examples/ipsec-secgw/test/trs_aesgcm_defs.sh  |  7 +-
 .../ipsec-secgw/test/trs_aesgcm_esn_defs.sh   |  7 +-
 .../test/tun_3descbc_sha1_common_defs.sh      | 68 ++++++++++++++
 .../ipsec-secgw/test/tun_3descbc_sha1_defs.sh | 77 ++++++++++++++-
 .../test/tun_3descbc_sha1_esn_defs.sh         | 77 ++++++++++++++-
 .../test/tun_aescbc_sha1_common_defs.sh       | 64 +++++++++++++
 .../ipsec-secgw/test/tun_aescbc_sha1_defs.sh  | 77 ++++++++++++++-
 .../test/tun_aescbc_sha1_esn_defs.sh          | 77 ++++++++++++++-
 .../test/tun_aesctr_sha1_common_defs.sh       | 64 +++++++++++++
 .../ipsec-secgw/test/tun_aesctr_sha1_defs.sh  | 77 ++++++++++++++-
 .../test/tun_aesctr_sha1_esn_defs.sh          | 77 ++++++++++++++-
 .../test/tun_aesgcm_common_defs.sh            | 56 +++++++++++
 examples/ipsec-secgw/test/tun_aesgcm_defs.sh  | 77 ++++++++++++++-
 .../ipsec-secgw/test/tun_aesgcm_esn_defs.sh   | 77 ++++++++++++++-
 26 files changed, 1085 insertions(+), 180 deletions(-)
 rename examples/ipsec-secgw/test/{linux_test6.sh => linux_test.sh} (50%)
 delete mode 100644 examples/ipsec-secgw/test/linux_test4.sh
examples/ipsec-secgw/ep0.cfg +48 -10
index 299aa9e06..ffd09156a 100644
@@ -28,38 +28,36 @@ sp ipv4 in esp protect 110 pri 1 dst 192.168.185.0/24 sport 0:65535 dport 0:6553
 sp ipv4 in esp protect 111 pri 1 dst 192.168.186.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp protect 115 pri 1 dst 192.168.210.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp protect 116 pri 1 dst 192.168.211.0/24 sport 0:65535 dport 0:65535
-sp ipv4 in esp protect 115 pri 1 dst 192.168.210.0/24 sport 0:65535 dport 0:65535
-sp ipv4 in esp protect 125 pri 1 dst 192.168.65.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp protect 125 pri 1 dst 192.168.65.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp protect 126 pri 1 dst 192.168.66.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp bypass pri 1 dst 192.168.245.0/24 sport 0:65535 dport 0:65535
 sp ipv4 in esp bypass pri 1 dst 192.168.246.0/24 sport 0:65535 dport 0:65535
 
 #SP IPv6 rules
-sp ipv6 out esp protect 5 pri 1 dst 0000:0000:0000:0000:5555:5555:0000:0000/96 \
+sp ipv6 out esp protect 7 pri 1 dst 0000:0000:0000:0000:5555:5555:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 out esp protect 6 pri 1 dst 0000:0000:0000:0000:6666:6666:0000:0000/96 \
+sp ipv6 out esp protect 8 pri 1 dst 0000:0000:0000:0000:6666:6666:0000:0000/96 \
 sport 0:65535 dport 0:65535
 sp ipv6 out esp protect 10 pri 1 dst 0000:0000:1111:1111:0000:0000:0000:0000/96 \
 sport 0:65535 dport 0:65535
 sp ipv6 out esp protect 11 pri 1 dst 0000:0000:1111:1111:1111:1111:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 out esp protect 25 pri 1 dst 0000:0000:0000:0000:aaaa:aaaa:0000:0000/96 \
+sp ipv6 out esp protect 27 pri 1 dst 0000:0000:0000:0000:aaaa:aaaa:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 out esp protect 26 pri 1 dst 0000:0000:0000:0000:bbbb:bbbb:0000:0000/96 \
+sp ipv6 out esp protect 28 pri 1 dst 0000:0000:0000:0000:bbbb:bbbb:0000:0000/96 \
 sport 0:65535 dport 0:65535
 
-sp ipv6 in esp protect 15 pri 1 dst ffff:0000:0000:0000:5555:5555:0000:0000/96 \
+sp ipv6 in esp protect 107 pri 1 dst ffff:0000:0000:0000:5555:5555:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 in esp protect 16 pri 1 dst ffff:0000:0000:0000:6666:6666:0000:0000/96 \
+sp ipv6 in esp protect 108 pri 1 dst ffff:0000:0000:0000:6666:6666:0000:0000/96 \
 sport 0:65535 dport 0:65535
 sp ipv6 in esp protect 110 pri 1 dst ffff:0000:1111:1111:0000:0000:0000:0000/96 \
 sport 0:65535 dport 0:65535
 sp ipv6 in esp protect 111 pri 1 dst ffff:0000:1111:1111:1111:1111:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 in esp protect 125 pri 1 dst ffff:0000:0000:0000:aaaa:aaaa:0000:0000/96 \
+sp ipv6 in esp protect 127 pri 1 dst ffff:0000:0000:0000:aaaa:aaaa:0000:0000/96 \
 sport 0:65535 dport 0:65535
-sp ipv6 in esp protect 126 pri 1 dst ffff:0000:0000:0000:bbbb:bbbb:0000:0000/96 \
+sp ipv6 in esp protect 128 pri 1 dst ffff:0000:0000:0000:bbbb:bbbb:0000:0000/96 \
 sport 0:65535 dport 0:65535
 
 #SA rules
@@ -71,6 +69,14 @@ sa out 6 cipher_algo aes-128-cbc cipher_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
 a0:a0:a0:a0:a0 auth_algo sha1-hmac auth_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
 a0:a0:a0:a0:a0:a0:a0:a0:a0 mode ipv4-tunnel src 172.16.1.6 dst 172.16.2.6
 
+sa out 7 cipher_algo aes-128-cbc cipher_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
+auth_algo sha1-hmac auth_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
+mode ipv4-tunnel src 172.16.1.5 dst 172.16.2.5
+
+sa out 8 cipher_algo aes-128-cbc cipher_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
+a0:a0:a0:a0:a0 auth_algo sha1-hmac auth_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
+a0:a0:a0:a0:a0:a0:a0:a0:a0 mode ipv4-tunnel src 172.16.1.6 dst 172.16.2.6
+
 sa out 10 cipher_algo aes-128-cbc cipher_key a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:\
 a1:a1:a1:a1:a1 auth_algo sha1-hmac auth_key a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:\
 a1:a1:a1:a1:a1:a1:a1:a1:a1 mode transport
@@ -97,6 +103,18 @@ sa out 26 cipher_algo aes-128-cbc cipher_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
 src 1111:1111:1111:1111:1111:1111:1111:6666 \
 dst 2222:2222:2222:2222:2222:2222:2222:6666
 
+sa out 27 cipher_algo aes-128-cbc cipher_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:\
+c3:c3:c3:c3:c3 auth_algo sha1-hmac auth_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:\
+c3:c3:c3:c3:c3:c3:c3:c3:c3 mode ipv6-tunnel \
+src 1111:1111:1111:1111:1111:1111:1111:5555 \
+dst 2222:2222:2222:2222:2222:2222:2222:5555
+
+sa out 28 cipher_algo aes-128-cbc cipher_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
+4d:4d:4d:4d:4d auth_algo sha1-hmac auth_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
+4d:4d:4d:4d:4d:4d:4d:4d:4d mode ipv6-tunnel \
+src 1111:1111:1111:1111:1111:1111:1111:6666 \
+dst 2222:2222:2222:2222:2222:2222:2222:6666
+
 sa in 105 cipher_algo aes-128-cbc cipher_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
 auth_algo sha1-hmac auth_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
 mode ipv4-tunnel src 172.16.2.5 dst 172.16.1.5
@@ -105,6 +123,14 @@ sa in 106 cipher_algo aes-128-cbc cipher_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
 a0:a0:a0:a0:a0 auth_algo sha1-hmac auth_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
 a0:a0:a0:a0:a0:a0:a0:a0:a0 mode ipv4-tunnel src 172.16.2.6 dst 172.16.1.6
 
+sa in 107 cipher_algo aes-128-cbc cipher_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
+auth_algo sha1-hmac auth_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
+mode ipv4-tunnel src 172.16.2.5 dst 172.16.1.5
+
+sa in 108 cipher_algo aes-128-cbc cipher_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
+a0:a0:a0:a0:a0 auth_algo sha1-hmac auth_key a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:a0:\
+a0:a0:a0:a0:a0:a0:a0:a0:a0 mode ipv4-tunnel src 172.16.2.6 dst 172.16.1.6
+
 sa in 110 cipher_algo aes-128-cbc cipher_key a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:\
 a1:a1:a1:a1:a1 auth_algo sha1-hmac auth_key a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:\
 a1:a1:a1:a1:a1:a1:a1:a1:a1 mode transport
@@ -130,6 +156,18 @@ sa in 126 cipher_algo aes-128-cbc cipher_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
 src 2222:2222:2222:2222:2222:2222:2222:6666 \
 dst 1111:1111:1111:1111:1111:1111:1111:6666
 
+sa in 127 cipher_algo aes-128-cbc cipher_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:\
+c3:c3:c3:c3:c3 auth_algo sha1-hmac auth_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:\
+c3:c3:c3:c3:c3:c3:c3:c3:c3 mode ipv6-tunnel \
+src 2222:2222:2222:2222:2222:2222:2222:5555 \
+dst 1111:1111:1111:1111:1111:1111:1111:5555
+
+sa in 128 cipher_algo aes-128-cbc cipher_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
+4d:4d:4d:4d:4d auth_algo sha1-hmac auth_key 4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:4d:\
+4d:4d:4d:4d:4d:4d:4d:4d:4d mode ipv6-tunnel \
+src 2222:2222:2222:2222:2222:2222:2222:6666 \
+dst 1111:1111:1111:1111:1111:1111:1111:6666
+
 #Routing rules
 rt ipv4 dst 172.16.2.5/32 port 0
 rt ipv4 dst 172.16.2.6/32 port 1
examples/ipsec-secgw/ep1.cfg +50 -12

120 lines not on this page · raw message

examples/ipsec-secgw/test/common_defs.sh +2 -5
index 09689af78..911857a60 100644
@@ -80,11 +80,8 @@ config_remote_iface()
 
 	ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE}
 
-	# by some reason following ip neigh doesn't work for me here properly:
-	#ssh ${REMOTE_HOST} ip neigh add ${LOCAL_IPV4} \
-	#		dev ${REMOTE_IFACE} lladr ${LOCAL_MAC}
-	# so used arp instead.
-	ssh ${REMOTE_HOST} arp -i ${REMOTE_IFACE} -s ${LOCAL_IPV4} ${LOCAL_MAC}
+	ssh ${REMOTE_HOST} ip neigh add ${LOCAL_IPV4} \
+			dev ${REMOTE_IFACE} lladdr ${LOCAL_MAC}
 	ssh ${REMOTE_HOST} ip neigh show dev ${REMOTE_IFACE}
 
 	ssh ${REMOTE_HOST} iptables --flush
examples/ipsec-secgw/test/linux_test.sh renamed from examples/ipsec-secgw/test/linux_test6.sh +77 -17

130 lines not on this page · raw message

examples/ipsec-secgw/test/linux_test4.sh deleted +0 -78

78 lines not on this page · raw message

examples/ipsec-secgw/test/run_test.sh +32 -10

88 lines not on this page · raw message

examples/ipsec-secgw/test/trs_3descbc_sha1_defs.sh +4 -3
index 31f94492f..b124d7888 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "cbc\(des3_ede\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_3descbc_sha1_esn_defs.sh +4 -3
index e4283f3dd..255acbb32 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "cbc\(des3_ede\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aescbc_sha1_defs.sh +4 -3
index d68552fce..55f696cbc 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc aes 0xdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aescbc_sha1_esn_defs.sh +4 -3
index ce7c977a3..851b38d59 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc aes 0xdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesctr_sha1_defs.sh +4 -3
index 73642f881..50f778ae5 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "rfc3686\(ctr\(aes\)\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesctr_sha1_esn_defs.sh +4 -3
index e401a4bed..88e2eed08 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ enc "rfc3686\(ctr\(aes\)\)" 0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesgcm_defs.sh +4 -3
index 8382d3d52..c47578a38 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ aead "rfc4106\(gcm\(aes\)\)" \
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/trs_aesgcm_esn_defs.sh +4 -3
index 94958d199..182f05a34 100644
@@ -4,7 +4,7 @@
 
 SGW_CMD_XPRM='-e -w 300'
 
-config_remote_xfrm()
+config_remote_xfrm_44()
 {
 	ssh ${REMOTE_HOST} ip xfrm policy flush
 	ssh ${REMOTE_HOST} ip xfrm state flush
@@ -35,9 +35,10 @@ aead "rfc4106\(gcm\(aes\)\)" \
 	ssh ${REMOTE_HOST} ip xfrm state list
 }
 
-config6_remote_xfrm()
+config_remote_xfrm_66()
 {
-	config_remote_xfrm
+	ssh ${REMOTE_HOST} ip xfrm policy flush
+	ssh ${REMOTE_HOST} ip xfrm state flush
 
 	ssh ${REMOTE_HOST} ip xfrm policy add \
 src ${REMOTE_IPV6} dst ${LOCAL_IPV6} \
examples/ipsec-secgw/test/tun_3descbc_sha1_common_defs.sh +68 -0

71 lines not on this page · raw message

examples/ipsec-secgw/test/tun_3descbc_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_3descbc_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_common_defs.sh +64 -0

67 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aescbc_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_common_defs.sh +64 -0

67 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesctr_sha1_esn_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_common_defs.sh +56 -0

59 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_defs.sh +74 -3

90 lines not on this page · raw message

examples/ipsec-secgw/test/tun_aesgcm_esn_defs.sh +74 -3

90 lines not on this page · raw message

Signature · 1 line
2.17.1
Acked-by Tested-by on v2 2/2
#14 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/ipsec-secgw: tests for split SAD

Quoted 7 lines

Test scripts updated to reflect change of SAD (split into IPv4 SAD and IPv6 SAD). New parameter added to run_test.sh for performing tests with mixed IP version, eg. IPv4 ipsec tunnel with IPv6 traffic.

Quoted 6 lines

Bugzilla ID: 239

Fixes 5a032a71c6d3 ("examples/ipsec-secgw: make app to use IPsec library")

---

Quoted 1 line

2.17.1