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 6999742E3F; Tue, 11 Jul 2023 04:14:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45B0C40A7D; Tue, 11 Jul 2023 04:14:13 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id D72204003C; Tue, 11 Jul 2023 04:14:11 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-666ed230c81so4501892b3a.0; Mon, 10 Jul 2023 19:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689041651; x=1691633651; 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=8HRkACsX2iQoiEGeWwBdfC+Uw2kO/PimN6mn9Ywb86c=; b=AWh7O34dFk5Z1M1N4zb109C+c1IJtJvYcKU+7UNdx11vMU956MrqXq6tsICvOiiGxq b6QfM1vGSsdgKory/8mJrnTk7u5m//5w/4Gz+VXV8H2zaewfQUi7M0U/04gIoQx5cC6r Kl0YTzZxxJAHscE8WXoTiXAlM5r3WnGLjayU4+lVtU2hsjjICuA15yMInkqpceB8f57s 0LdKP/4yR5Y5vhBE4Fn8ehgikpUmfBOn+PEJVisOdBs5P8UP0KNtqK7Vij3O1I4q3RF/ WPrhHP4Dyaf1pOatHnWrQMY38MJSMnxVS+kxBFOxwKQn/sAYTIhrIFn0NrA6CWaTWX9D I5tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689041651; x=1691633651; 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=8HRkACsX2iQoiEGeWwBdfC+Uw2kO/PimN6mn9Ywb86c=; b=E7hUWVb9zgUDpPKuniIbeIJVFzX/Pdn0Km8C9ALZU1t4Gd/NFJzdzQwL/cWAp6hnog oeYVuy+byLjrCQGLzfONaqewO8ZX4OnIYmjBiYWWNztXM39/mOiVeyqX8tld6r/97tn6 M3Rga8su/qHhUw9o/R7OvapJP2kYJXSNj2WSXTkN/0kgfl9VQvaTsHQrvIV1UgUO/u2D 4VpOV2gVw+KQ18ltbUHgRFQFnIeOfJwy76um/SNnPfBQ0rd2k5dXxcejJ6x5tcngeN+7 aXtE+n0oZoNd6t/+wpTwLv/4odJaONElFMH2UPCBmIUR4mD2mlY44wgkKnIK7QIJzgFT NqGQ== X-Gm-Message-State: ABy/qLbdjujS5hqVCjmItLS5gSLKQNITG6321KY3Gr4KJaWMJSkJUwP5 XNF0lhesUTpGr7EGkKSdRnvFGwqGqnx14zNB X-Google-Smtp-Source: APBJJlGrPRnb5reNkjuOgJr7iyC1IiPmTyf6pdMBqvtojLmc1ut0DJkeD8Lk22UrsnaC1mEXeLFfng== X-Received: by 2002:a05:6a00:1709:b0:67c:5c21:b430 with SMTP id h9-20020a056a00170900b0067c5c21b430mr19247292pfc.33.1689041650731; Mon, 10 Jul 2023 19:14:10 -0700 (PDT) Received: from nova-ws.. ([103.167.140.11]) by smtp.gmail.com with ESMTPSA id b20-20020aa78714000000b0064f7c56d8b7sm420306pfo.219.2023.07.10.19.14.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 19:14:10 -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:13:17 +0800 Message-ID: <20230711021335.7239-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: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 caculation. 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