Re: [PATCH net] ipv6: fix suspecious RCU usage warning
From: David Ahern <hidden>
Date: 2021-03-09 02:48:28
[ cc Ido and Petr ] On 3/8/21 12:21 PM, Wei Wang wrote:
quoted hunk ↗ jump to hunk
diff --git a/include/net/nexthop.h b/include/net/nexthop.h index 7bc057aee40b..48956b144689 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h@@ -410,31 +410,39 @@ static inline struct fib_nh *fib_info_nh(struct fib_info *fi, int nhsel) int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg, struct netlink_ext_ack *extack); -static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) +static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh, + bool bh_disabled)
Hi Wei: I would prefer not to have a second argument to nexthop_fib6_nh for 1 code path, and a control path at that.
{
struct nh_info *nhi;
if (nh->is_group) {
struct nh_group *nh_grp;
- nh_grp = rcu_dereference_rtnl(nh->nh_grp);
+ if (bh_disabled)
+ nh_grp = rcu_dereference_bh_rtnl(nh->nh_grp);
+ else
+ nh_grp = rcu_dereference_rtnl(nh->nh_grp);
nh = nexthop_mpath_select(nh_grp, 0);
if (!nh)
return NULL;
}
- nhi = rcu_dereference_rtnl(nh->nh_info);
+ if (bh_disabled)
+ nhi = rcu_dereference_bh_rtnl(nh->nh_info);
+ else
+ nhi = rcu_dereference_rtnl(nh->nh_info);
if (nhi->family == AF_INET6)
return &nhi->fib6_nh;
return NULL;
}
I am wary of duplicating code, but this helper is simple enough that it should be ok with proper documentation. Ido/Petr: I think your resilient hashing patch set touches this helper. How ugly does it get to have a second version?