]> git.droids-corp.org - dpdk.git/commitdiff
examples/ipsec-secgw: fix NAT-T header fields
authorRadu Nicolau <radu.nicolau@intel.com>
Wed, 25 May 2022 13:59:11 +0000 (14:59 +0100)
committerAkhil Goyal <gakhil@marvell.com>
Tue, 21 Jun 2022 18:04:49 +0000 (20:04 +0200)
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>
examples/ipsec-secgw/sa.c

index 0b27f11fc0232217addbf04a9ae5b6ee6efe683c..fde263ca33aa7d00fc6eca3f485ca49af0bc9d1a 100644 (file)
@@ -1485,6 +1485,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;
 
@@ -1535,13 +1537,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)) {