]> git.baikalelectronics.ru Git - kernel.git/commit
net: fib_rules: bring back rule_exists to match rule during add
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Fri, 29 Jun 2018 21:32:15 +0000 (14:32 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 13:11:13 +0000 (22:11 +0900)
commitdd4037c3c3bb556da2a3699348a9f45a76e0a82f
tree4f64022fc3ee35c5eb4e94ccabccc31c247e700a
parent949f42da0f4bf4912b2200b174e629baa531b66b
net: fib_rules: bring back rule_exists to match rule during add

After commit c53378ff0354 ("fib_rules: move common handling of newrule
delrule msgs into fib_nl2rule"), rule_exists got replaced by rule_find
for existing rule lookup in both the add and del paths. While this
is good for the delete path, it solves a few problems but opens up
a few invalid key matches in the add path.

$ip -4 rule add table main tos 10 fwmark 1
$ip -4 rule add table main tos 10
RTNETLINK answers: File exists

The problem here is rule_find does not check if the key masks in
the new and old rule are the same and hence ends up matching a more
secific rule. Rule key masks cannot be easily compared today without
an elaborate if-else block. Its best to introduce key masks for easier
and accurate rule comparison in the future. Until then, due to fear of
regressions this patch re-introduces older loose rule_exists during add.
Also fixes both rule_exists and rule_find to cover missing attributes.

Fixes: c53378ff0354 ("fib_rules: move common handling of newrule delrule msgs into fib_nl2rule")
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/fib_rules.c