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 AAF0D4297B; Tue, 18 Apr 2023 10:46:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80FDD40EDF; Tue, 18 Apr 2023 10:46:51 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 36DF940698 for ; Tue, 18 Apr 2023 10:46:50 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id lh8so14779465plb.1 for ; Tue, 18 Apr 2023 01:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681807609; x=1684399609; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9XkdXT56q8HGhvGHMyR9UN71Fem9TudcWF3jvNCz+QM=; b=Vk5SDUYW4D+x5RR4ed1412stVmff54/Hlxhi5McNiY+u7dghOCljn1uGK/MzIe53+j 8cHxjZ3mnSGs15EVqGt7ULgdF4wQNIJNv5MS9+gYnlZQm8APH9IkXMqHlO3f+0Z8/dUp VhgX71ZKAq4tgz1WJv+bIEAYO+MMM/14/DBqIM/mIBxwOMcvR/VAzE3XEDDyoSjrffEU U0P5wMQS6doVx6bjjrJ5TDrV4UK5T4rSpNYiDBgvo7d9VT3/3QtpknZJet7VqV8n+/LK SMB/3SrgZUm3I8CVcvQPy2LLU4NmiQp64Txle0mgfCvJEsHznq7fNEtozK7LQ2VW7XI2 hJDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681807609; x=1684399609; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9XkdXT56q8HGhvGHMyR9UN71Fem9TudcWF3jvNCz+QM=; b=k4EVVf9SpSbvVE2jU/7VUJuIdhuW1E1i5rf/rZEc0UBsgcOI9G6LqIBib8uLnZrSnC So4OMgRCZx9GURiCwCPaXwVzSMVqSY9tocbNPxLYw04Jarc1fpfZBKANMREeNN+bJ0uv neXJ5x7veGFR5PdgnBG1ozGjx4KHUfnqGs+6ejtgrSenvVSEA5+0Q4bHSFC5Sku/Dhh8 fH6s8ONNmx7Y2ke9PJXto65CbnMmdCCU01vR2TRhRw+NuqljihcXy+hpH5LRRIPHUoh/ 4A+gZWRhbgKxBFi4+Issw8g/jBhdkXwW9iinzuora4ZC1mqtNXZJ+AsRMD36YKrkp0Ft P94g== X-Gm-Message-State: AAQBX9cX/AnDb2PQAmAR/UlXuhzhx+BcLuedH8v9aZnU5xHzTkWcfID/ PMDLGx+dzBY2LN7b62KzP4k= X-Google-Smtp-Source: AKy350bf4S5KdDfMLmGb4/h15Bw1vF65EEIe9iDPo4ocmjJ2AQ/VEKh2ZVauy9h9JsoS+LtqXw9p/Q== X-Received: by 2002:a05:6a20:c701:b0:f0:942e:873b with SMTP id hi1-20020a056a20c70100b000f0942e873bmr1886916pzb.7.1681807609403; Tue, 18 Apr 2023 01:46:49 -0700 (PDT) Received: from nova-ws.. ([103.167.140.11]) by smtp.gmail.com with ESMTPSA id x2-20020a056a00270200b0062db34242aesm8857587pfv.167.2023.04.18.01.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 01:46:49 -0700 (PDT) From: Xiao Liang To: Konstantin Ananyev , Vladimir Medvedkin Cc: Xiao Liang , dev@dpdk.org Subject: [PATCH] ipsec: fix NAT-T length calculation Date: Tue, 18 Apr 2023 16:46:13 +0800 Message-Id: <20230418084613.52740-1-shaw.leon@gmail.com> X-Mailer: git-send-email 2.40.0 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 length is included in sa->hdr_len. Take care of that in L3 header and pakcet length calculation. Fixes: 01eef5907fc3 ("ipsec: support NAT-T") Signed-off-by: Xiao Liang --- 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.40.0