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 B891543399; Wed, 22 Nov 2023 09:18:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC3F240685; Wed, 22 Nov 2023 09:17:58 +0100 (CET) Received: from out30-73.freemail.mail.aliyun.com (out30-73.freemail.mail.aliyun.com [115.124.30.73]) by mails.dpdk.org (Postfix) with ESMTP id BAD9A4028C for ; Wed, 22 Nov 2023 07:51:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aliyun.com; s=s1024; t=1700635903; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cxF+yZKxZoiCWQQHpWZsafuaTlUvgzhPMaMLQMKvTOY=; b=L2B6DQsijWcBpo/w/QehHGg1O/Rdv2HIOEiONdDUTErQ54s682uccHEOcy+R66pxj7F4QWiaic58Om23BvksTLj2+8ub6Vb9/1t+M3o4P5eE+X2wTGFM1aFYeaWxV05VJRnFKSkMZzrlFcotYqQi+7Cf+fVRILNzS5csLw69UIs= 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|3|1|5|0|-1|-1|-1; HT=ay29a033018046049; MF=speng975@aliyun.com; NM=1; PH=DS; RN=3; RT=3; SR=0; TI=SMTPD_---0Vwv3l2i_1700635897; Received: from speng-Vostro-3670..(mailfrom:speng975@aliyun.com fp:SMTPD_---0Vwv3l2i_1700635897) by smtp.aliyun-inc.com; Wed, 22 Nov 2023 14:51:42 +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:51:35 +0800 Message-Id: <20231122065135.57412-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