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 <vladimir.medved...@intel.com>
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 <zhouya...@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)
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