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 D9F07A058A; Fri, 17 Apr 2020 17:09:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50B2C1E547; Fri, 17 Apr 2020 17:09:20 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id A18D91E4C0 for ; Fri, 17 Apr 2020 17:09:18 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id u65so1188466pfb.4 for ; Fri, 17 Apr 2020 08:09:18 -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=1bcg7f4v9j+/x0BsKd+7QSwzLMq47GSABu4WyK1kSe8=; b=Rw+U2GJtJrxB/wA0lnL+rxdkT63nYzwN1i9Iz5mg8Kxi6NuJCFjsbyp4f2MameMPKE H0qo8pOLjJsSel7C4llKPmKOh454ILu2Y0AG6DhjD8zXOmy54H4YTjq/5vprEIyB0DvL +3X7XF4xoTC9qQiSAvfw89xGL2Icpr4SephEK3W/MDIhM97/2Xz6cxbbofXuWthIkidy lZYJjYZCnsNfrW7o6onxwGiQuoEfTw9HBRxQl74zDv0BkoldoMxnQZoLFIjgkFyH6urU 0hoTlCH2U37xuS8StG9Pn+aTb6odPyKg3iYG5NQekzbcRWZZbcp2KWAixXEnCRzrz83r GzUw== 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=1bcg7f4v9j+/x0BsKd+7QSwzLMq47GSABu4WyK1kSe8=; b=jSJwK/AWzoZXcn8behgP09Y8rrKH4/CfvvsCI+H7ITBIx8w3VPrtgjYejKEr6Pk87Q LlQDC3VZWGMcom04s1wLG2tthuSc8txnbglbzpWDNR0CGlHnWd5LOfKMHaUCyz3D6pDJ E2UfHORb3Oa95b/Z0AiVoYGsZ4mPN7pIDfwM9qmYNqMqSHiI04Qwo6xxplU5xBRMFd5M PDLCRgq2gSQ37sT/ULOjASb2qhzv90ulw/OvRKP8X2RvUpdffkj9YQAjCttfkbeVTQKo oj3ti/PfNyqsu1DBVvrClG4AJFsQ69gtpYbElozx6Hqajy7DJy75qSO+3OZtfhp/86bx 05QQ== X-Gm-Message-State: AGi0PubYQlsWspSmZqZsUsYQTuAgoLXsGGOso4SbEI+57+moNk0i0Etw QeEHnbqIVwG/7HBxj8g2xVwKMhO6tsE= X-Google-Smtp-Source: APiQypIhcvm5wycjJgfNT09YK0QetKYZZ9Mgc6CTUTk6K6yBwfKd1Pd561rGBSf5jchM5LG1vihZPQ== X-Received: by 2002:a63:c74d:: with SMTP id v13mr1449661pgg.370.1587136157654; Fri, 17 Apr 2020 08:09:17 -0700 (PDT) Received: from yateszhou-PC0.tencent.com ([203.205.141.47]) by smtp.gmail.com with ESMTPSA id 135sm17345844pfx.58.2020.04.17.08.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2020 08:09:17 -0700 (PDT) From: Yangchao Zhou To: dev@dpdk.org Cc: Bruce Richardson , Vladimir Medvedkin Date: Fri, 17 Apr 2020 23:09:12 +0800 Message-Id: <20200417150912.6911-1-zhouyates@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200417134830.13600-1-zhouyates@gmail.com> References: <20200417134830.13600-1-zhouyates@gmail.com> Subject: [dpdk-dev] [PATCH v2] 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..83db3cd34 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,11 @@ 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