Skip to content

Commit 170739c

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 94782c8 commit 170739c

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
@@ -438,7 +438,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
438438
#ifdef CONFIG_IP_ROUTE_CLASSID
439439
static inline int fib_num_tclassid_users(struct net *net)
440440
{
441-
return net->ipv4.fib_num_tclassid_users;
441+
return atomic_read(&net->ipv4.fib_num_tclassid_users);
442442
}
443443
#else
444444
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
@@ -65,7 +65,7 @@ struct netns_ipv4 {
6565
bool fib_has_custom_local_routes;
6666
bool fib_offload_disabled;
6767
#ifdef CONFIG_IP_ROUTE_CLASSID
68-
int fib_num_tclassid_users;
68+
atomic_t fib_num_tclassid_users;
6969
#endif
7070
struct hlist_head *fib_table_hash;
7171
struct sock *fibnl;

net/ipv4/fib_frontend.c

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

15841584
#ifdef CONFIG_IP_ROUTE_CLASSID
1585-
net->ipv4.fib_num_tclassid_users = 0;
1585+
atomic_set(&net->ipv4.fib_num_tclassid_users, 0);
15861586
#endif
15871587
error = ip_fib_net_init(net);
15881588
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
@@ -220,7 +220,7 @@ void fib_nh_release(struct net *net, struct fib_nh *fib_nh)
220220
{
221221
#ifdef CONFIG_IP_ROUTE_CLASSID
222222
if (fib_nh->nh_tclassid)
223-
net->ipv4.fib_num_tclassid_users--;
223+
atomic_dec(&net->ipv4.fib_num_tclassid_users);
224224
#endif
225225
fib_nh_common_release(&fib_nh->nh_common);
226226
}
@@ -632,7 +632,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
632632
#ifdef CONFIG_IP_ROUTE_CLASSID
633633
nh->nh_tclassid = cfg->fc_flow;
634634
if (nh->nh_tclassid)
635-
net->ipv4.fib_num_tclassid_users++;
635+
atomic_inc(&net->ipv4.fib_num_tclassid_users);
636636
#endif
637637
#ifdef CONFIG_IP_ROUTE_MULTIPATH
638638
nh->fib_nh_weight = nh_weight;

0 commit comments

Comments
 (0)