X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_lpm%2Frte_lpm.c;h=38ab512a42c3c25875f9205a6a359db1bee32da2;hb=d6bba625cd5097199bde4a766a03e61bb2349778;hp=b78c487447749321e1b66a90a9ecfbacf9ed62ab;hpb=c381a8d554b70f7108ce7a87e0c7bc15e1c99c02;p=dpdk.git diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index b78c487447..38ab512a42 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "rte_lpm.h" @@ -284,8 +283,12 @@ rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth, for (; rule_index < last_rule; rule_index++) { - /* If rule already exists update its next_hop and return. */ + /* If rule already exists update 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; @@ -675,6 +678,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;