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 E917343399; Wed, 22 Nov 2023 09:18:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AED7406FF; Wed, 22 Nov 2023 09:18:02 +0100 (CET) Received: from out30-74.freemail.mail.aliyun.com (out30-74.freemail.mail.aliyun.com [115.124.30.74]) by mails.dpdk.org (Postfix) with ESMTP id A66484028C for ; Wed, 22 Nov 2023 08:59:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aliyun.com; s=s1024; t=1700639966; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cxF+yZKxZoiCWQQHpWZsafuaTlUvgzhPMaMLQMKvTOY=; b=FOEtiGdRekANX8Ym/Ki3V4Zc57xS1KjQtufwKJy9+ze8Mf+5Ig3jbizq95TDYb/oqxh56c6osSkxLQrEsGMp2vMPRfED4dV50Dal+ACVy93zhCJGyGVHs31oOf4Wd4ngFRppEGwL0UOGax17a3e4jg8kqLNRXRsWDD3Sx1XpDUQ= X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07740735|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.00735108-0.000238935-0.99241; FP=16534270645479644902|6|1|5|0|-1|-1|-1; HT=ay29a033018046050; MF=supeng2087@aliyun.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---0VwvESNI_1700639935; Received: from speng-Vostro-3670..(mailfrom:supeng2087@aliyun.com fp:SMTPD_---0VwvESNI_1700639935) by smtp.aliyun-inc.com; Wed, 22 Nov 2023 15:59:07 +0800 From: supeng2087 To: dev@dpdk.org Cc: supeng Subject: [PATCH] examples/ipsec-secgw: fix cmp_sa_key bug Date: Wed, 22 Nov 2023 15:58:40 +0800 Message-Id: <20231122075840.58703-1-supeng2087@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