fib_rules: match rules based on suppress_* properties too
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 25 Jun 2018 23:39:32 +0000 (01:39 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Jun 2018 01:33:05 +0000 (10:33 +0900)
Two rules with different values of suppress_prefix or suppress_ifgroup
are not the same. This fixes an -EEXIST when running:

   $ ip -4 rule add table main suppress_prefixlength 0

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Fixes: f9d4b0c1e969 ("fib_rules: move common handling of newrule delrule msgs into fib_nl2rule")
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/fib_rules.c

index 126ffc5bc630cb412e4bcf1a48869ec6711fda54..bc8425d810220558e8457ada83ea3e356c3ceffa 100644 (file)
@@ -416,6 +416,14 @@ static struct fib_rule *rule_find(struct fib_rules_ops *ops,
                if (rule->mark && r->mark != rule->mark)
                        continue;
 
+               if (rule->suppress_ifgroup != -1 &&
+                   r->suppress_ifgroup != rule->suppress_ifgroup)
+                       continue;
+
+               if (rule->suppress_prefixlen != -1 &&
+                   r->suppress_prefixlen != rule->suppress_prefixlen)
+                       continue;
+
                if (rule->mark_mask && r->mark_mask != rule->mark_mask)
                        continue;