Skip to content

Commit 002dba1

Browse files
q2venkuba-moo
authored andcommitted
ipv6: Revert two per-cpu var allocation for RTM_NEWROUTE.
These two commits preallocated two per-cpu variables in ip6_route_info_create() as fib_nh_common_init() and fib6_nh_init() were expected to be called under RCU. * commit d27b9c4 ("ipv6: Preallocate nhc_pcpu_rth_output in ip6_route_info_create().") * commit 5720a32 ("ipv6: Preallocate rt->fib6_nh->rt6i_pcpu in ip6_route_info_create().") Now these functions can be called without RCU and can use GFP_KERNEL. Let's revert the commits. Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d465bd0 commit 002dba1

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

net/ipv4/fib_semantics.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,10 @@ int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc,
617617
{
618618
int err;
619619

620-
if (!nhc->nhc_pcpu_rth_output) {
621-
nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *,
622-
gfp_flags);
623-
if (!nhc->nhc_pcpu_rth_output)
624-
return -ENOMEM;
625-
}
620+
nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *,
621+
gfp_flags);
622+
if (!nhc->nhc_pcpu_rth_output)
623+
return -ENOMEM;
626624

627625
if (encap) {
628626
struct lwtunnel_state *lwtstate;

net/ipv6/route.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,12 +3674,10 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
36743674
goto out;
36753675

36763676
pcpu_alloc:
3677+
fib6_nh->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, gfp_flags);
36773678
if (!fib6_nh->rt6i_pcpu) {
3678-
fib6_nh->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, gfp_flags);
3679-
if (!fib6_nh->rt6i_pcpu) {
3680-
err = -ENOMEM;
3681-
goto out;
3682-
}
3679+
err = -ENOMEM;
3680+
goto out;
36833681
}
36843682

36853683
fib6_nh->fib_nh_dev = dev;
@@ -3739,24 +3737,6 @@ void fib6_nh_release_dsts(struct fib6_nh *fib6_nh)
37393737
}
37403738
}
37413739

3742-
static int fib6_nh_prealloc_percpu(struct fib6_nh *fib6_nh, gfp_t gfp_flags)
3743-
{
3744-
struct fib_nh_common *nhc = &fib6_nh->nh_common;
3745-
3746-
fib6_nh->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, gfp_flags);
3747-
if (!fib6_nh->rt6i_pcpu)
3748-
return -ENOMEM;
3749-
3750-
nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *,
3751-
gfp_flags);
3752-
if (!nhc->nhc_pcpu_rth_output) {
3753-
free_percpu(fib6_nh->rt6i_pcpu);
3754-
return -ENOMEM;
3755-
}
3756-
3757-
return 0;
3758-
}
3759-
37603740
static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
37613741
gfp_t gfp_flags,
37623742
struct netlink_ext_ack *extack)
@@ -3794,12 +3774,6 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
37943774
goto free;
37953775
}
37963776

3797-
if (!cfg->fc_nh_id) {
3798-
err = fib6_nh_prealloc_percpu(&rt->fib6_nh[0], gfp_flags);
3799-
if (err)
3800-
goto free_metrics;
3801-
}
3802-
38033777
if (cfg->fc_flags & RTF_ADDRCONF)
38043778
rt->dst_nocount = true;
38053779

@@ -3824,8 +3798,6 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
38243798
rt->fib6_src.plen = cfg->fc_src_len;
38253799
#endif
38263800
return rt;
3827-
free_metrics:
3828-
ip_fib_metrics_put(rt->fib6_metrics);
38293801
free:
38303802
kfree(rt);
38313803
err:

0 commit comments

Comments
 (0)