Skip to content

Commit 561dac2

Browse files
Gao fengdavem330
authored andcommitted
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: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b811ce9 commit 561dac2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/core/fib_rules.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
384384
*/
385385
list_for_each_entry(r, &ops->rules_list, list) {
386386
if (r->action == FR_ACT_GOTO &&
387-
r->target == rule->pref) {
388-
BUG_ON(rtnl_dereference(r->ctarget) != NULL);
387+
r->target == rule->pref &&
388+
rtnl_dereference(r->ctarget) == NULL) {
389389
rcu_assign_pointer(r->ctarget, rule);
390390
if (--ops->unresolved_rules == 0)
391391
break;

0 commit comments

Comments
 (0)