From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 327B642E40 for ; Tue, 11 Jul 2023 04:20:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2AA534114A; Tue, 11 Jul 2023 04:20:11 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 6F1A24003C; Tue, 11 Jul 2023 04:20:09 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1b9cd6a0051so14621875ad.1; Mon, 10 Jul 2023 19:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689042008; x=1691634008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hOnDQytrcLiTaKqhID2hM/FIjFiPERhOrPG+keGdd/4=; b=N28kwvfhE0jXpB2V4HM9UGrauyu+hibY6khmQxW+DJPeFVMGhughvK65eYPbmIpRvt YdIXYnSIChhzUxSj2GgcpfhCt8EEPF7tAFxq1hg02SGYZe/Q53FuqmMZqhPB6cHkY7zj vRycb3h/eq40e9PgU9MmifzcFlLCc31YZZyh+nTN1qNMxJypiScSLRrX/SWsdUR6snlj CVOU8CgGSFt+8/zR1gtcrVWhaKnMjn+M7uBIpejj+IQSYwfkHEaS5TFosemEvByJJHYG mQt2aPSLCk8CsnDGjFVBYGK/rNTKi3fvysevpQTeDl1UWGnmgwfjDlcoNJeWc2aSgUJx VNsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689042008; x=1691634008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hOnDQytrcLiTaKqhID2hM/FIjFiPERhOrPG+keGdd/4=; b=CAJuo+Z9Ihj7AyZ4I2GlzyFC4XN+ShrLznhX0Xyvh5v9zmRSI+2lFKUgKfH/gFqh13 SBgheCga5HZwSsOT9PvJUWy7pJjn3nm8K2oSsD799vwzndsCnHPnBAuhB7/0d6PzFUwR zR3SA5TrlP7SqgeGpi9AFa54rOAQ/8d8PwBdLFoRz7iQMTO4RrOaCtjMrSPGJ4Aw7SVj 6AE1LDngVaQK/f6UlujfTWo9qImxByvedeNKolSZQgkVIb+nxcmoyG0Q0UsJnoNZ7XYy gRYPlDUfWcbWCWe1T4Jxgcpld979ECbDz5Cmrhi3afCi3REnwW7knTuGjEO4oWNPRmwb BuHw== X-Gm-Message-State: ABy/qLYIMxi/T2GSlBX4b7kigGfXd7vdXyeuFqBC6yUaNI0so3zU0h0m 9cVrIA+VNgTTdamXgI9fzggKDHDn+jFyjs5I X-Google-Smtp-Source: APBJJlF/zzqHHSU5IiW/IiHoI/KD3g1NPO9kOayxZvLMFCGQ9BuKiNF4XPDUArHCzC3MNd6ViL1y0A== X-Received: by 2002:a17:902:c3d5:b0:1b8:41d4:89f with SMTP id j21-20020a170902c3d500b001b841d4089fmr11017079plj.4.1689042008297; Mon, 10 Jul 2023 19:20:08 -0700 (PDT) Received: from nova-ws.. ([103.167.140.11]) by smtp.gmail.com with ESMTPSA id jh5-20020a170903328500b001b682336f66sm579074plb.55.2023.07.10.19.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 19:20:07 -0700 (PDT) From: Xiao Liang To: dev@dpdk.org Cc: stable@dpdk.org, Konstantin Ananyev , Vladimir Medvedkin , Radu Nicolau Subject: [PATCH v2] ipsec: fix NAT-T header length calculation Date: Tue, 11 Jul 2023 10:18:47 +0800 Message-ID: <20230711021938.7343-1-shaw.leon@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230418084613.52740-1-shaw.leon@gmail.com> References: <20230418084613.52740-1-shaw.leon@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org UDP header and L2 header (if any) length is included in sa->hdr_len. Take care of that in L3 header and pakcet length calculation. Fixes: 01eef5907fc3 ("ipsec: support NAT-T") Cc: stable@dpdk.org Signed-off-by: Xiao Liang Acked-by: Konstantin Ananyev Acked-by: Radu Nicolau --- lib/ipsec/esp_outb.c | 2 +- lib/ipsec/sa.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c index 9cbd9202f6..ec87b1dce2 100644 --- a/lib/ipsec/esp_outb.c +++ b/lib/ipsec/esp_outb.c @@ -198,7 +198,7 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t sqc, struct rte_udp_hdr *udph = (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); + sa->hdr_len + sizeof(struct rte_udp_hdr)); } /* update original and new ip header fields */ diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c index 59a547637d..2297bd6d72 100644 --- a/lib/ipsec/sa.c +++ b/lib/ipsec/sa.c @@ -371,7 +371,7 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct rte_ipsec_sa_prm *prm) /* update l2_len and l3_len fields for outbound mbuf */ sa->tx_offload.val = rte_mbuf_tx_offload(sa->hdr_l3_off, - sa->hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0); + prm->tun.hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0); esp_outb_init(sa, sa->hdr_len, prm->ipsec_xform.esn.value); } -- 2.41.0