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 02A4743399; Wed, 22 Nov 2023 09:17:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89048402EC; Wed, 22 Nov 2023 09:17:57 +0100 (CET) Received: from out30-88.freemail.mail.aliyun.com (out30-88.freemail.mail.aliyun.com [115.124.30.88]) by mails.dpdk.org (Postfix) with ESMTP id 3B0244028C for ; Wed, 22 Nov 2023 07:50:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aliyun.com; s=s1024; t=1700635811; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cxF+yZKxZoiCWQQHpWZsafuaTlUvgzhPMaMLQMKvTOY=; b=tFbv00ju9Ad7Bb1Lq+EazW+HPRx3O+mEnjyLOumNFBxV57TqkItfBjAVRpn5QO5XWeYglAxHeGEa/gmy6ZcMLgg9ilBIS8v1ZVqa8ZidEj3495GcdjvlIjQOZCQfGCTKHm5h46bhqYgPvt8Qnme8Visxt0kNN8TGcLTWBmE6vHE= 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|2|1|3|0|-1|-1|-1; HT=ay29a033018045176; MF=speng975@aliyun.com; NM=1; PH=DS; RN=4; RT=4; SR=0; TI=SMTPD_---0Vwv3kYR_1700635802; Received: from speng-Vostro-3670..(mailfrom:speng975@aliyun.com fp:SMTPD_---0Vwv3kYR_1700635802) by smtp.aliyun-inc.com; Wed, 22 Nov 2023 14:50:10 +0800 From: supeng To: dev@dpdk.org Cc: radu.nicolau@intel.com, akhil.goyal@nxp.com, supeng Subject: [PATCH] examples/ipsec-secgw: fix cmp_sa_key bug Date: Wed, 22 Nov 2023 14:49:53 +0800 Message-Id: <20231122064953.57368-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