From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E56D3A0598; Tue, 21 Apr 2020 17:45:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 852B01D445; Tue, 21 Apr 2020 17:45:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 6AAE91D42A for ; Tue, 21 Apr 2020 17:45:02 +0200 (CEST) IronPort-SDR: UrtXzxwLdFfNxmdGE6e2/b/cltvSlBNQlBu4brtSg7v2rcjI6aR1zkC877+AhC4JMAOALToZNH 72Y7kFyuD/mw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2020 08:45:00 -0700 IronPort-SDR: qiX3JfWh+BvwzfkUFZ/p2kj2j5O6uu9Gxpvra7av1Vip/YgriVPG2yrwTr8d5hD83BzB+j658N dwTImKif4pQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,410,1580803200"; d="scan'208,217";a="456148913" Received: from vmedvedk-mobl.ger.corp.intel.com (HELO [10.254.156.250]) ([10.254.156.250]) by fmsmga005.fm.intel.com with ESMTP; 21 Apr 2020 08:44:59 -0700 To: Yangchao Zhou , dev@dpdk.org Cc: Bruce Richardson References: <20200417150912.6911-1-zhouyates@gmail.com> <20200420024850.21481-1-zhouyates@gmail.com> From: "Medvedkin, Vladimir" Message-ID: <7c295dc2-1563-4c46-e592-037368c864b8@intel.com> Date: Tue, 21 Apr 2020 16:44:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200420024850.21481-1-zhouyates@gmail.com> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v4] lpm: skip table entries update if rules found X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Yangchao, Thanks for the patch. This might be useful for control plane implementations that don't track inserted routes. I have just a one nit inlined below. Also, could you do the same for lpm6? P.S. Please have a look at rte_fib library, there are more optimizations compared to lpm library. Apart from that, Acked-by: Vladimir Medvedkin On 20/04/2020 03:48, Yangchao Zhou wrote: > Table entries do not need to be updated if the same rules can be found. > > Signed-off-by: Yangchao Zhou > --- > v1-v2: Skip updating when the next hop is the same as the current one > v2-v4: Coding style fix > --- > lib/librte_lpm/rte_lpm.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c > index 268756419..b8a90e385 100644 > --- a/lib/librte_lpm/rte_lpm.c > +++ b/lib/librte_lpm/rte_lpm.c > @@ -285,6 +285,9 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, > > /* If rule already exists update its next_hop and return. */ > if (lpm->rules_tbl[rule_index].ip == ip_masked) { > + > + if (lpm->rules_tbl[rule_index].next_hop == next_hop) Line over 80 characters, please split it by two. > + return -EEXIST; > lpm->rules_tbl[rule_index].next_hop = next_hop; > > return rule_index; > @@ -674,6 +677,12 @@ rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, > /* Add the rule to the rule table. */ > rule_index = rule_add(lpm, ip_masked, depth, next_hop); > > + /* Skip table entries update if The rule is the same as > + * the rule in the rules table. > + */ > + if (rule_index == -EEXIST) > + return 0; > + > /* If the is no space available for new rule return error. */ > if (rule_index < 0) { > return rule_index; -- Regards, Vladimir