Skip to content

Commit 9a40a1e

Browse files
Eric Dumazetgregkh
Eric Dumazet
authored andcommitted
ipv4: convert fib_num_tclassid_users to atomic_t
commit 213f5f8 upstream. Before commit faa041a ("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: faa041a ("ipv4: Create cleanup helper for fib_nh") Signed-off-by: Eric Dumazet <[email protected]> Cc: David Ahern <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fa973bf commit 9a40a1e

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

include/net/ip_fib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
437437
#ifdef CONFIG_IP_ROUTE_CLASSID
438438
static inline int fib_num_tclassid_users(struct net *net)
439439
{
440-
return net->ipv4.fib_num_tclassid_users;
440+
return atomic_read(&net->ipv4.fib_num_tclassid_users);
441441
}
442442
#else
443443
static inline int fib_num_tclassid_users(struct net *net)

include/net/netns/ipv4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct netns_ipv4 {
6161
#endif
6262
bool fib_has_custom_local_routes;
6363
#ifdef CONFIG_IP_ROUTE_CLASSID
64-
int fib_num_tclassid_users;
64+
atomic_t fib_num_tclassid_users;
6565
#endif
6666
struct hlist_head *fib_table_hash;
6767
bool fib_offload_disabled;

net/ipv4/fib_frontend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ static int __net_init fib_net_init(struct net *net)
15781578
int error;
15791579

15801580
#ifdef CONFIG_IP_ROUTE_CLASSID
1581-
net->ipv4.fib_num_tclassid_users = 0;
1581+
atomic_set(&net->ipv4.fib_num_tclassid_users, 0);
15821582
#endif
15831583
error = ip_fib_net_init(net);
15841584
if (error < 0)

net/ipv4/fib_rules.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
264264
if (tb[FRA_FLOW]) {
265265
rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
266266
if (rule4->tclassid)
267-
net->ipv4.fib_num_tclassid_users++;
267+
atomic_inc(&net->ipv4.fib_num_tclassid_users);
268268
}
269269
#endif
270270

@@ -296,7 +296,7 @@ static int fib4_rule_delete(struct fib_rule *rule)
296296

297297
#ifdef CONFIG_IP_ROUTE_CLASSID
298298
if (((struct fib4_rule *)rule)->tclassid)
299-
net->ipv4.fib_num_tclassid_users--;
299+
atomic_dec(&net->ipv4.fib_num_tclassid_users);
300300
#endif
301301
net->ipv4.fib_has_custom_rules = true;
302302

net/ipv4/fib_semantics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh)
222222
{
223223
#ifdef CONFIG_IP_ROUTE_CLASSID
224224
if (fib_nh->nh_tclassid)
225-
net->ipv4.fib_num_tclassid_users--;
225+
atomic_dec(&net->ipv4.fib_num_tclassid_users);
226226
#endif
227227
fib_nh_common_release(&fib_nh->nh_common);
228228
}
@@ -633,7 +633,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
633633
#ifdef CONFIG_IP_ROUTE_CLASSID
634634
nh->nh_tclassid = cfg->fc_flow;
635635
if (nh->nh_tclassid)
636-
net->ipv4.fib_num_tclassid_users++;
636+
atomic_inc(&net->ipv4.fib_num_tclassid_users);
637637
#endif
638638
#ifdef CONFIG_IP_ROUTE_MULTIPATH
639639
nh->fib_nh_weight = nh_weight;

0 commit comments

Comments
 (0)