Commit 561dac2d authored by Gao feng's avatar Gao feng Committed by David S. Miller

fib:fix BUG_ON in fib_nl_newrule when add new fib rule

add new fib rule can cause BUG_ON happen
the reproduce shell is
ip rule add pref 38
ip rule add pref 38
ip rule add to 192.168.3.0/24 goto 38
ip rule del pref 38
ip rule add to 192.168.3.0/24 goto 38
ip rule add pref 38

then the BUG_ON will happen
del BUG_ON and use (ctarget == NULL) identify whether this rule is unresolved
Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b811ce91
...@@ -384,8 +384,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -384,8 +384,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
*/ */
list_for_each_entry(r, &ops->rules_list, list) { list_for_each_entry(r, &ops->rules_list, list) {
if (r->action == FR_ACT_GOTO && if (r->action == FR_ACT_GOTO &&
r->target == rule->pref) { r->target == rule->pref &&
BUG_ON(rtnl_dereference(r->ctarget) != NULL); rtnl_dereference(r->ctarget) == NULL) {
rcu_assign_pointer(r->ctarget, rule); rcu_assign_pointer(r->ctarget, rule);
if (--ops->unresolved_rules == 0) if (--ops->unresolved_rules == 0)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment