diff mbox series

[net-next,v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release

Message ID 20211129154411.561783-1-razor@blackwall.org (mailing list archive)
State Accepted
Commit 6130805066659cda3d685fc4c8d912c72a005ef5
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers warning 2 maintainers not CCed: yoshfuji@linux-ipv6.org dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Nikolay Aleksandrov Nov. 29, 2021, 3:44 p.m. UTC
From: Nikolay Aleksandrov <nikolay@nvidia.com>

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>
---
v2: no need to check for NULL rt6i_pcpu before calling free_percpu

 net/ipv6/route.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

Comments

David Ahern Nov. 30, 2021, 1:35 a.m. UTC | #1
On 11/29/21 8:44 AM, Nikolay Aleksandrov wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> 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>
> ---
> v2: no need to check for NULL rt6i_pcpu before calling free_percpu
> 
>  net/ipv6/route.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 



Reviewed-by: David Ahern <dsahern@kernel.org>
patchwork-bot+netdevbpf@kernel.org Nov. 30, 2021, 12:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 29 Nov 2021 17:44:11 +0200 you wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
    https://git.kernel.org/netdev/net-next/c/613080506665

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 62f1e16eea2b..f0d29fcb2094 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -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);
 }