summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
036d823)
Table entries do not need to be updated if the same rules can be found.
Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
for (; rule_index < last_rule; rule_index++) {
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].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;
lpm->rules_tbl[rule_index].next_hop = next_hop;
return rule_index;
/* Add the rule to the rule table. */
rule_index = rule_add(lpm, ip_masked, depth, next_hop);
/* 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;
/* If the is no space available for new rule return error. */
if (rule_index < 0) {
return rule_index;