patches for DPDK stable branches
 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

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).