提交 213f5f8f 编写于 作者: E Eric Dumazet 提交者: David S. Miller

ipv4: convert fib_num_tclassid_users to atomic_t

Before commit faa041a4 ("ipv4: Create cleanup helper for fib_nh")
changes to net->ipv4.fib_num_tclassid_users were protected by RTNL.

After the change, this is no longer the case, as free_fib_info_rcu()
runs after rcu grace period, without rtnl being held.

Fixes: faa041a4 ("ipv4: Create cleanup helper for fib_nh")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Cc: David Ahern <dsahern@kernel.org>
Reviewed-by: NDavid Ahern <dsahern@kernel.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a37a0ee4
...@@ -438,7 +438,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, ...@@ -438,7 +438,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
static inline int fib_num_tclassid_users(struct net *net) static inline int fib_num_tclassid_users(struct net *net)
{ {
return net->ipv4.fib_num_tclassid_users; return atomic_read(&net->ipv4.fib_num_tclassid_users);
} }
#else #else
static inline int fib_num_tclassid_users(struct net *net) static inline int fib_num_tclassid_users(struct net *net)
......
...@@ -65,7 +65,7 @@ struct netns_ipv4 { ...@@ -65,7 +65,7 @@ struct netns_ipv4 {
bool fib_has_custom_local_routes; bool fib_has_custom_local_routes;
bool fib_offload_disabled; bool fib_offload_disabled;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
int fib_num_tclassid_users; atomic_t fib_num_tclassid_users;
#endif #endif
struct hlist_head *fib_table_hash; struct hlist_head *fib_table_hash;
struct sock *fibnl; struct sock *fibnl;
......
...@@ -1582,7 +1582,7 @@ static int __net_init fib_net_init(struct net *net) ...@@ -1582,7 +1582,7 @@ static int __net_init fib_net_init(struct net *net)
int error; int error;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
net->ipv4.fib_num_tclassid_users = 0; atomic_set(&net->ipv4.fib_num_tclassid_users, 0);
#endif #endif
error = ip_fib_net_init(net); error = ip_fib_net_init(net);
if (error < 0) if (error < 0)
......
...@@ -264,7 +264,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, ...@@ -264,7 +264,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
if (tb[FRA_FLOW]) { if (tb[FRA_FLOW]) {
rule4->tclassid = nla_get_u32(tb[FRA_FLOW]); rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
if (rule4->tclassid) if (rule4->tclassid)
net->ipv4.fib_num_tclassid_users++; atomic_inc(&net->ipv4.fib_num_tclassid_users);
} }
#endif #endif
...@@ -296,7 +296,7 @@ static int fib4_rule_delete(struct fib_rule *rule) ...@@ -296,7 +296,7 @@ static int fib4_rule_delete(struct fib_rule *rule)
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
if (((struct fib4_rule *)rule)->tclassid) if (((struct fib4_rule *)rule)->tclassid)
net->ipv4.fib_num_tclassid_users--; atomic_dec(&net->ipv4.fib_num_tclassid_users);
#endif #endif
net->ipv4.fib_has_custom_rules = true; net->ipv4.fib_has_custom_rules = true;
......
...@@ -220,7 +220,7 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh) ...@@ -220,7 +220,7 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh)
{ {
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
if (fib_nh->nh_tclassid) if (fib_nh->nh_tclassid)
net->ipv4.fib_num_tclassid_users--; atomic_dec(&net->ipv4.fib_num_tclassid_users);
#endif #endif
fib_nh_common_release(&fib_nh->nh_common); fib_nh_common_release(&fib_nh->nh_common);
} }
...@@ -632,7 +632,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh, ...@@ -632,7 +632,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
nh->nh_tclassid = cfg->fc_flow; nh->nh_tclassid = cfg->fc_flow;
if (nh->nh_tclassid) if (nh->nh_tclassid)
net->ipv4.fib_num_tclassid_users++; atomic_inc(&net->ipv4.fib_num_tclassid_users);
#endif #endif
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
nh->fib_nh_weight = nh_weight; nh->fib_nh_weight = nh_weight;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册