DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/3] ipsec: fix NAT-T ports and length
@ 2022-05-25 13:59 Radu Nicolau
  2022-05-25 13:59 ` [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields Radu Nicolau
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Radu Nicolau @ 2022-05-25 13:59 UTC (permalink / raw)
  To: Konstantin Ananyev, Bernard Iremonger, Vladimir Medvedkin
  Cc: dev, daniel.m.buckley, qi.z.zhang, Radu Nicolau, stable

Fix the UDP header fields, wrong byte order used for src and dst port
and wrong offset used when updating UDP datagram length.

Fixes: 01eef5907fc3 ("ipsec: support NAT-T")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 lib/ipsec/esp_outb.c | 2 +-
 lib/ipsec/sa.c       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index 6925bb9945..5a5429a12b 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -196,7 +196,7 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t sqc,
 	/* if UDP encap is enabled update the dgram_len */
 	if (sa->type & RTE_IPSEC_SATP_NATT_ENABLE) {
 		struct rte_udp_hdr *udph = (struct rte_udp_hdr *)
-				(ph - sizeof(struct rte_udp_hdr));
+			(ph + sa->hdr_len - sizeof(struct rte_udp_hdr));
 		udph->dgram_len = rte_cpu_to_be_16(mb->pkt_len - sqh_len -
 				sa->hdr_l3_off - sa->hdr_len);
 	}
diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
index 1b673b6a18..59a547637d 100644
--- a/lib/ipsec/sa.c
+++ b/lib/ipsec/sa.c
@@ -364,8 +364,8 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct rte_ipsec_sa_prm *prm)
 		struct rte_udp_hdr *udph = (struct rte_udp_hdr *)
 				&sa->hdr[prm->tun.hdr_len];
 		sa->hdr_len += sizeof(struct rte_udp_hdr);
-		udph->src_port = prm->ipsec_xform.udp.sport;
-		udph->dst_port = prm->ipsec_xform.udp.dport;
+		udph->src_port = rte_cpu_to_be_16(prm->ipsec_xform.udp.sport);
+		udph->dst_port = rte_cpu_to_be_16(prm->ipsec_xform.udp.dport);
 		udph->dgram_cksum = 0;
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields
  2022-05-25 13:59 [PATCH 1/3] ipsec: fix NAT-T ports and length Radu Nicolau
@ 2022-05-25 13:59 ` Radu Nicolau
  2022-06-14 15:49   ` Zhang, Roy Fan
  2022-05-25 13:59 ` [PATCH 3/3] net/iavf: fix NAT-T payload length Radu Nicolau
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Radu Nicolau @ 2022-05-25 13:59 UTC (permalink / raw)
  To: Radu Nicolau, Akhil Goyal; +Cc: dev, daniel.m.buckley, qi.z.zhang, stable

Use the proper IP protocol (UDP instead of ESP) and set the ports when
UDP encapsulation is enabled.

Fixes: 9ae86b4cfc77 ("examples/ipsec-secgw: support UDP encap for inline crypto")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 examples/ipsec-secgw/sa.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 1839ac71af..45509c5c68 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1458,6 +1458,8 @@ fill_ipsec_sa_prm(struct rte_ipsec_sa_prm *prm, const struct ipsec_sa *ss,
 		RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT :
 		RTE_SECURITY_IPSEC_SA_MODE_TUNNEL;
 	prm->ipsec_xform.options.udp_encap = ss->udp_encap;
+	prm->ipsec_xform.udp.dport = ss->udp.dport;
+	prm->ipsec_xform.udp.sport = ss->udp.sport;
 	prm->ipsec_xform.options.ecn = 1;
 	prm->ipsec_xform.options.copy_dscp = 1;
 
@@ -1513,13 +1515,13 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size)
 		.version_ihl = IPVERSION << 4 |
 			sizeof(v4) / RTE_IPV4_IHL_MULTIPLIER,
 		.time_to_live = IPDEFTTL,
-		.next_proto_id = IPPROTO_ESP,
+		.next_proto_id = lsa->udp_encap ? IPPROTO_UDP : IPPROTO_ESP,
 		.src_addr = lsa->src.ip.ip4,
 		.dst_addr = lsa->dst.ip.ip4,
 	};
 	struct rte_ipv6_hdr v6 = {
 		.vtc_flow = htonl(IP6_VERSION << 28),
-		.proto = IPPROTO_ESP,
+		.proto = lsa->udp_encap ? IPPROTO_UDP : IPPROTO_ESP,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] net/iavf: fix NAT-T payload length
  2022-05-25 13:59 [PATCH 1/3] ipsec: fix NAT-T ports and length Radu Nicolau
  2022-05-25 13:59 ` [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields Radu Nicolau
@ 2022-05-25 13:59 ` Radu Nicolau
  2022-06-14 15:50   ` Zhang, Roy Fan
  2022-06-14 15:49 ` [PATCH 1/3] ipsec: fix NAT-T ports and length Zhang, Roy Fan
  2022-06-15 15:07 ` [EXT] " Akhil Goyal
  3 siblings, 1 reply; 7+ messages in thread
From: Radu Nicolau @ 2022-05-25 13:59 UTC (permalink / raw)
  To: Jingjing Wu, Beilei Xing
  Cc: dev, daniel.m.buckley, qi.z.zhang, Radu Nicolau, stable

Correct the length calculation used for NAT-T

Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 drivers/net/iavf/iavf_ipsec_crypto.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c
index b1949cee91..b398819096 100644
--- a/drivers/net/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/iavf/iavf_ipsec_crypto.c
@@ -1118,11 +1118,14 @@ iavf_ipsec_crypto_compute_l4_payload_length(struct rte_mbuf *m,
 		 * ipv4/6 hdr + ext hdrs
 		 */
 
-	if (s->udp_encap.enabled)
+	if (s->udp_encap.enabled) {
 		ol4_len = sizeof(struct rte_udp_hdr);
-
-	l3_len = m->l3_len;
-	l4_len = m->l4_len;
+		l3_len = m->l3_len - ol4_len;
+		l4_len = l3_len;
+	} else {
+		l3_len = m->l3_len;
+		l4_len = m->l4_len;
+	}
 
 	return rte_pktmbuf_pkt_len(m) - (ol2_len + ol3_len + ol4_len +
 			esp_hlen + l3_len + l4_len + esp_tlen);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields
  2022-05-25 13:59 ` [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields Radu Nicolau
@ 2022-06-14 15:49   ` Zhang, Roy Fan
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Roy Fan @ 2022-06-14 15:49 UTC (permalink / raw)
  To: Nicolau, Radu, Nicolau, Radu, Akhil Goyal
  Cc: dev, Buckley, Daniel M, Zhang, Qi Z, stable

> -----Original Message-----
> From: Radu Nicolau <radu.nicolau@intel.com>
> Sent: Wednesday, May 25, 2022 2:59 PM
> To: Nicolau, Radu <radu.nicolau@intel.com>; Akhil Goyal <gakhil@marvell.com>
> Cc: dev@dpdk.org; Buckley, Daniel M <daniel.m.buckley@intel.com>; Zhang, Qi
> Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields
> 
> Use the proper IP protocol (UDP instead of ESP) and set the ports when
> UDP encapsulation is enabled.
> 
> Fixes: 9ae86b4cfc77 ("examples/ipsec-secgw: support UDP encap for inline
> crypto")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 1/3] ipsec: fix NAT-T ports and length
  2022-05-25 13:59 [PATCH 1/3] ipsec: fix NAT-T ports and length Radu Nicolau
  2022-05-25 13:59 ` [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields Radu Nicolau
  2022-05-25 13:59 ` [PATCH 3/3] net/iavf: fix NAT-T payload length Radu Nicolau
@ 2022-06-14 15:49 ` Zhang, Roy Fan
  2022-06-15 15:07 ` [EXT] " Akhil Goyal
  3 siblings, 0 replies; 7+ messages in thread
From: Zhang, Roy Fan @ 2022-06-14 15:49 UTC (permalink / raw)
  To: Nicolau, Radu, Konstantin Ananyev, Iremonger, Bernard, Medvedkin,
	Vladimir
  Cc: dev, Buckley, Daniel M, Zhang, Qi Z, Nicolau,  Radu, stable

> -----Original Message-----
> From: Radu Nicolau <radu.nicolau@intel.com>
> Sent: Wednesday, May 25, 2022 2:59 PM
> To: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Medvedkin, Vladimir
> <vladimir.medvedkin@intel.com>
> Cc: dev@dpdk.org; Buckley, Daniel M <daniel.m.buckley@intel.com>; Zhang, Qi
> Z <qi.z.zhang@intel.com>; Nicolau, Radu <radu.nicolau@intel.com>;
> stable@dpdk.org
> Subject: [PATCH 1/3] ipsec: fix NAT-T ports and length
> 
> Fix the UDP header fields, wrong byte order used for src and dst port
> and wrong offset used when updating UDP datagram length.
> 
> Fixes: 01eef5907fc3 ("ipsec: support NAT-T")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 3/3] net/iavf: fix NAT-T payload length
  2022-05-25 13:59 ` [PATCH 3/3] net/iavf: fix NAT-T payload length Radu Nicolau
@ 2022-06-14 15:50   ` Zhang, Roy Fan
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Roy Fan @ 2022-06-14 15:50 UTC (permalink / raw)
  To: Nicolau, Radu, Wu, Jingjing, Xing, Beilei
  Cc: dev, Buckley, Daniel M, Zhang, Qi Z, Nicolau,  Radu, stable

> -----Original Message-----
> From: Radu Nicolau <radu.nicolau@intel.com>
> Sent: Wednesday, May 25, 2022 2:59 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Buckley, Daniel M <daniel.m.buckley@intel.com>; Zhang, Qi
> Z <qi.z.zhang@intel.com>; Nicolau, Radu <radu.nicolau@intel.com>;
> stable@dpdk.org
> Subject: [PATCH 3/3] net/iavf: fix NAT-T payload length
> 
> Correct the length calculation used for NAT-T
> 
> Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXT] [PATCH 1/3] ipsec: fix NAT-T ports and length
  2022-05-25 13:59 [PATCH 1/3] ipsec: fix NAT-T ports and length Radu Nicolau
                   ` (2 preceding siblings ...)
  2022-06-14 15:49 ` [PATCH 1/3] ipsec: fix NAT-T ports and length Zhang, Roy Fan
@ 2022-06-15 15:07 ` Akhil Goyal
  3 siblings, 0 replies; 7+ messages in thread
From: Akhil Goyal @ 2022-06-15 15:07 UTC (permalink / raw)
  To: Radu Nicolau, Konstantin Ananyev, Bernard Iremonger, Vladimir Medvedkin
  Cc: dev, daniel.m.buckley, qi.z.zhang, stable

> ----------------------------------------------------------------------
> Fix the UDP header fields, wrong byte order used for src and dst port
> and wrong offset used when updating UDP datagram length.
> 
> Fixes: 01eef5907fc3 ("ipsec: support NAT-T")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
Series applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-15 15:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 13:59 [PATCH 1/3] ipsec: fix NAT-T ports and length Radu Nicolau
2022-05-25 13:59 ` [PATCH 2/3] examples/ipsec-secgw: fix NAT-T header fields Radu Nicolau
2022-06-14 15:49   ` Zhang, Roy Fan
2022-05-25 13:59 ` [PATCH 3/3] net/iavf: fix NAT-T payload length Radu Nicolau
2022-06-14 15:50   ` Zhang, Roy Fan
2022-06-14 15:49 ` [PATCH 1/3] ipsec: fix NAT-T ports and length Zhang, Roy Fan
2022-06-15 15:07 ` [EXT] " Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).