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 44F68A058A; Fri, 17 Apr 2020 15:48:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 048941E8F4; Fri, 17 Apr 2020 15:48:44 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 6CA031E8C3 for ; Fri, 17 Apr 2020 15:48:42 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id m21so1067717pff.13 for ; Fri, 17 Apr 2020 06:48:42 -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; bh=g4+CipsXgmq4OnTftoUp1QaVviSQEz9pO9s4uBaJTWs=; b=mKQJu1teTuO9GziQvi5lqLwfzmsa7NvmL3+NAv3+gHnNvIP+D6hbFbe/RmtdInnKDp xX4rDguK0vVql3bNKSQkDocDP20SkQZcsQ5waUpmC2Lrc5vQlEtmkrTuD7M9B7A42iJI f7Q8QRkzf8Yxt58NrVEbySyoMiQfrMmQwSZs3S7cVoPx1EZce8QgKhQwcBgo6wUR1Ews hmILq7rGHUVdHoe/XCJRdUTP5mSV+L8hBFSkP7y5JJ2UkoyJhGYpVPkMO2nPWPmaqm+E 5KHFWy70poomZWytbBygKLuWB5JbnA4hMyGpOAJ6JEBa354pS8jZw958btTMH3Y33beT 5u2g== 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; bh=g4+CipsXgmq4OnTftoUp1QaVviSQEz9pO9s4uBaJTWs=; b=d+ntvAy496AdpzQivqF+d381Wa2CRSh4ehhpD+6VMpJrpjINkYrdIr44cafss4YYD+ nsCv0uO/rquCoYu0e9HtO9zHSIzSuwnRCZJZ+JT5oMtZpeziLlZG48gbfC7AlipprsK5 1gtLCoA6DnCszdKRyzIss9hnHm/V0CsotZU9hv+xhcS2DNhY6msepQeQICijPzZGMel5 Jijj6djfUKX8RE2N8JkineyPN8U/Y8LeFDKx/mT9g9XbLv50AXPRN7EIRgtMih8xPAq8 hMnXLuEOZAz9lYPzYfajulmFPC5WJb2gc5WVG8JMMYTnHalyNzSJgdJDnKs+LUL7LZTs RQxg== X-Gm-Message-State: AGi0PuYpWC9sSap3RaB7cmix8LvtbkfqoWBYf4JLqT4KPlqigh9DvMlk IFeLG3weJ7Tby6PWQucXA5thpLj2YHU= X-Google-Smtp-Source: APiQypJyo2knFfAB/9kG+gbPA43HdpH1PLv1YklV686akwASJOanl3425NtJj6QgMX2ytp7efh6RUQ== X-Received: by 2002:a63:4004:: with SMTP id n4mr3026016pga.234.1587131321036; Fri, 17 Apr 2020 06:48:41 -0700 (PDT) Received: from yateszhou-PC0.tencent.com ([203.205.141.47]) by smtp.gmail.com with ESMTPSA id z60sm5741839pjj.14.2020.04.17.06.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Apr 2020 06:48:40 -0700 (PDT) From: Yangchao Zhou To: dev@dpdk.org Cc: Bruce Richardson , Vladimir Medvedkin Date: Fri, 17 Apr 2020 21:48:30 +0800 Message-Id: <20200417134830.13600-1-zhouyates@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 268756419..ee44fc4e5 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -287,7 +287,7 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, if (lpm->rules_tbl[rule_index].ip == ip_masked) { lpm->rules_tbl[rule_index].next_hop = next_hop; - return rule_index; + return -EEXIST; } } @@ -674,6 +674,10 @@ 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 rule is found in rule 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