DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yangchao Zhou <zhouyates@gmail.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [dpdk-dev] [PATCH v4] lpm: skip table entries update if rules found
Date: Mon, 20 Apr 2020 10:48:50 +0800	[thread overview]
Message-ID: <20200420024850.21481-1-zhouyates@gmail.com> (raw)
In-Reply-To: <20200417150912.6911-1-zhouyates@gmail.com>

Table entries do not need to be updated if the same rules can be found.

Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
---
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)
+					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


  parent reply	other threads:[~2020-04-20  2:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-17 13:48 [dpdk-dev] [PATCH] " Yangchao Zhou
2020-04-17 14:01 ` Medvedkin, Vladimir
     [not found]   ` <CABLiTuxTNQYYSCwWRuqqSZy+0JhBqjcE2v5ha+OqWk+YH42+TA@mail.gmail.com>
2020-04-17 15:07     ` Yangchao Zhou
2020-04-17 15:09 ` [dpdk-dev] [PATCH v2] " Yangchao Zhou
2020-04-17 17:26   ` [dpdk-dev] [PATCH v3] " Yangchao Zhou
2020-04-20  2:48   ` Yangchao Zhou [this message]
2020-04-21 15:44     ` [dpdk-dev] [PATCH v4] " Medvedkin, Vladimir
2020-04-24 17:17       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200420024850.21481-1-zhouyates@gmail.com \
    --to=zhouyates@gmail.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).