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 CF8F443399; Wed, 22 Nov 2023 09:18:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D232540697; Wed, 22 Nov 2023 09:17:59 +0100 (CET) Received: from out30-82.freemail.mail.aliyun.com (out30-82.freemail.mail.aliyun.com [115.124.30.82]) by mails.dpdk.org (Postfix) with ESMTP id 2F1564028C for ; Wed, 22 Nov 2023 07:57:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aliyun.com; s=s1024; t=1700636261; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cxF+yZKxZoiCWQQHpWZsafuaTlUvgzhPMaMLQMKvTOY=; b=OG/uFDM5lGcPXjfGxAFK+zvFIf+Uf6M3HXgeQnePm3AQkUOpweT2xDQ7t/ZD0TaFSSbjkICQnxU92iBAmk9T18nM+g4pee8GDFuFuPAFIRIcEqP7sD1d9uncLBtNYbjd764JnrrYDNI4jZRvfgEBbGk/86JdUevkXmVAmDZ/IgM= X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07740735|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.00766378-0.000357211-0.991979; FP=16534270645479644902|4|1|5|0|-1|-1|-1; HT=ay29a033018046059; MF=speng975@aliyun.com; NM=1; PH=DS; RN=3; RT=3; SR=0; TI=SMTPD_---0Vwv5D4N_1700636252; Received: from speng-Vostro-3670..(mailfrom:speng975@aliyun.com fp:SMTPD_---0Vwv5D4N_1700636252) by smtp.aliyun-inc.com; Wed, 22 Nov 2023 14:57:40 +0800 From: supeng To: dev@dpdk.org Cc: radu.nicolau@intel.com, supeng Subject: [PATCH] examples/ipsec-secgw: fix cmp_sa_key bug Date: Wed, 22 Nov 2023 14:57:23 +0800 Message-Id: <20231122065723.57566-1-speng975@aliyun.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 22 Nov 2023 09:17:56 +0100 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 From: supeng Inbound direction, sad_lookup function will call cmp_sa_key to compare packet outer ip info with local sa. Local sa src ip should equal packet dst ip, Local sa dst ip should equal src ip. --- examples/ipsec-secgw/sad.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/ipsec-secgw/sad.h b/examples/ipsec-secgw/sad.h index 3224b6252c..e1fa8a26f6 100644 --- a/examples/ipsec-secgw/sad.h +++ b/examples/ipsec-secgw/sad.h @@ -33,12 +33,12 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4, if ((sa_type == TRANSPORT) || /* IPv4 check */ (is_v4 && (sa_type == IP4_TUNNEL) && - (sa->src.ip.ip4 == ipv4->src_addr) && - (sa->dst.ip.ip4 == ipv4->dst_addr)) || + (sa->src.ip.ip4 == ipv4->dst_addr) && + (sa->dst.ip.ip4 == ipv4->src_addr)) || /* IPv6 check */ (!is_v4 && (sa_type == IP6_TUNNEL) && - (!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) && - (!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16)))) + (!memcmp(sa->src.ip.ip6.ip6, ipv6->dst_addr, 16)) && + (!memcmp(sa->dst.ip.ip6.ip6, ipv6->src_addr, 16)))) return 1; return 0; -- 2.34.1