Skip to content

Commit

Permalink
net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
Browse files Browse the repository at this point in the history
We can remove a bit of code duplication by reusing the new
fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
that fib6_nh_release's version doesn't use atomic operation to swap the
pointers because it assumes the fib6_nh is no longer visible, while
fib6_nh_release_dsts can be used anywhere.

Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Nov 30, 2021
1 parent 7709efa commit 6130805
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3656,24 +3656,8 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)

rcu_read_unlock();

if (fib6_nh->rt6i_pcpu) {
int cpu;

for_each_possible_cpu(cpu) {
struct rt6_info **ppcpu_rt;
struct rt6_info *pcpu_rt;

ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu);
pcpu_rt = *ppcpu_rt;
if (pcpu_rt) {
dst_dev_put(&pcpu_rt->dst);
dst_release(&pcpu_rt->dst);
*ppcpu_rt = NULL;
}
}

free_percpu(fib6_nh->rt6i_pcpu);
}
fib6_nh_release_dsts(fib6_nh);
free_percpu(fib6_nh->rt6i_pcpu);

fib_nh_common_release(&fib6_nh->nh_common);
}
Expand Down

0 comments on commit 6130805

Please sign in to comment.