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 66D6FA0597; Fri, 17 Apr 2020 19:26:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4623E1EAE2; Fri, 17 Apr 2020 19:26:22 +0200 (CEST) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id DE20F1EADD for ; Fri, 17 Apr 2020 19:26:20 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id o1so1360651pjs.4 for ; Fri, 17 Apr 2020 10:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hZTLFkgYUjKF4v9Q/wZo0A+mJTiJleBC10FJGOfwsSE=; b=sB5vHwBAcJkJSBIor7nCMgkpA8hJ65aaAck9yCp1bM916Wg1XX3Yo4+u2YcFJtZlZd b276GSugZU0lPZv1bhPBJe4nw5OzrJ7BOxdItwad53YPB+qzM8J8R3ACKbtBzjJC/yL1 OLfjcJ0XZjsg7IELh+nOCimC9HnaKjs9MYpDtTrqEDxYlZBdaRBXflFXcdVAvp04MvDQ 9NERBm9ZZquS6brS/zZyn5esuMtkqM9Z9H1nxEceqFhO8YtGoDfIEnogfRQRG8x21TKY 4khaz8Bhyt9j4qyFYMCARp26ZteHo2adYJDSicSyv/SDUM1cbK7mIFo/HQXeVn0DB9TZ 65MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hZTLFkgYUjKF4v9Q/wZo0A+mJTiJleBC10FJGOfwsSE=; b=QzLs9Qt52OGs6NOcr83ALZnbwwGIaWI8UuHBjf8umjGO1PivdaCjAyGxTKWs6TwB3p ITacEuuDaRKq7O6yyEmzo8yuSV9eFxTT5lo+1hr53DehF/1lROg1weQH7lcqNlVLfPm3 W/fviUeJi6WT7/aGxQUjkhS0NnGuhboQLu95nNnIQ8hH0DnQxE+EkpOU8CQ2zW5/mzeq NlbeAAe26WiZOs7sc2QA6NR2/R14aVyCUbfyvnXP6d+F142ShQQA37vZkWIVaNnXHUcE 0EseLdrG41KDq15RihtAVwegzsGeKBWd8IDcvEV60DGqAwhtQSq8mqvfTIauBu9EJbHM rxPw== X-Gm-Message-State: AGi0Pub5RFYZrnQsEzH1oDi9FHjkJuKuwNI3/rdJYHA9bYuC9OD2d6UP zxJLZGGSH9MYfJwr1YfAYAXUmPGeXGs= X-Google-Smtp-Source: APiQypJQAETx52WWEE/w9zaZmZ8naGTv0iCqYcMHr3KkuAtTAn7mpOSavKd0K3uAPZuduqXXhjZE3g== X-Received: by 2002:a17:90a:ce08:: with SMTP id f8mr5830929pju.76.1587144379726; Fri, 17 Apr 2020 10:26:19 -0700 (PDT) Received: from yateszhou-PC0.tencent.com ([203.205.141.47]) by smtp.gmail.com with ESMTPSA id g25sm19853961pfh.55.2020.04.17.10.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2020 10:26:19 -0700 (PDT) From: Yangchao Zhou To: dev@dpdk.org Cc: Bruce Richardson , Vladimir Medvedkin Date: Sat, 18 Apr 2020 01:26:14 +0800 Message-Id: <20200417172614.7559-1-zhouyates@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200417150912.6911-1-zhouyates@gmail.com> References: <20200417150912.6911-1-zhouyates@gmail.com> Subject: [dpdk-dev] [PATCH v3] 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" Table entries do not need to be updated if the same rules can be found. Signed-off-by: Yangchao Zhou --- 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..9085f935e 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) + 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; -- 2.17.1