Correct the length calculation used for NAT-T

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

Signed-off-by: Radu Nicolau <radu.nico...@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

Reply via email to