Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: Preallocate nhc_pcpu_rth_output in ip6_route_info_create().

ip6_route_info_create_nh() will be called under RCU.

It calls fib_nh_common_init() and allocates nhc->nhc_pcpu_rth_output.

As with the reason for rt->fib6_nh->rt6i_pcpu, we want to avoid
GFP_ATOMIC allocation for nhc->nhc_pcpu_rth_output under RCU.

Let's preallocate it in ip6_route_info_create().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250418000443.43734-9-kuniyu@amazon.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Kuniyuki Iwashima and committed by
Paolo Abeni
d27b9c40 5720a328

+15 -4
+6 -4
net/ipv4/fib_semantics.c
··· 617 617 { 618 618 int err; 619 619 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; 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 + } 624 626 625 627 if (encap) { 626 628 struct lwtunnel_state *lwtstate;
+9
net/ipv6/route.c
··· 3732 3732 3733 3733 static int fib6_nh_prealloc_percpu(struct fib6_nh *fib6_nh, gfp_t gfp_flags) 3734 3734 { 3735 + struct fib_nh_common *nhc = &fib6_nh->nh_common; 3736 + 3735 3737 fib6_nh->rt6i_pcpu = alloc_percpu_gfp(struct rt6_info *, gfp_flags); 3736 3738 if (!fib6_nh->rt6i_pcpu) 3737 3739 return -ENOMEM; 3740 + 3741 + nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *, 3742 + gfp_flags); 3743 + if (!nhc->nhc_pcpu_rth_output) { 3744 + free_percpu(fib6_nh->rt6i_pcpu); 3745 + return -ENOMEM; 3746 + } 3738 3747 3739 3748 return 0; 3740 3749 }