diff mbox series

[net] ipv6: take care of disable_policy when restoring routes

Message ID 20220623120015.32640-1-nicolas.dichtel@6wind.com (mailing list archive)
State Accepted
Commit 3b0dc529f56b5f2328244130683210be98f16f7f
Delegated to: Netdev Maintainers
Headers show
Series [net] ipv6: take care of disable_policy when restoring routes | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-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: 23 this patch: 23
netdev/cc_maintainers warning 1 maintainers not CCed: yoshfuji@linux-ipv6.org
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
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

Nicolas Dichtel June 23, 2022, noon UTC
When routes corresponding to addresses are restored by
fixup_permanent_addr(), the dst_nopolicy parameter was not set.
The typical use case is a user that configures an address on a down
interface and then put this interface up.

Let's take care of this flag in addrconf_f6i_alloc(), so that every callers
benefit ont it.

CC: stable@kernel.org
CC: David Forster <dforster@brocade.com>
Fixes: df789fe75206 ("ipv6: Provide ipv6 version of "disable_policy" sysctl")
Reported-by: Siwar Zitouni <siwar.zitouni@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---

I choose to be conservative in my patch, thus I filter anycast addresses. But
I don't see why this flag is not set on anycast routes. Any thoughts
about this?

 net/ipv6/addrconf.c | 4 ----
 net/ipv6/route.c    | 9 ++++++++-
 2 files changed, 8 insertions(+), 5 deletions(-)

Comments

David Ahern June 26, 2022, 5:19 p.m. UTC | #1
On 6/23/22 6:00 AM, Nicolas Dichtel wrote:
> When routes corresponding to addresses are restored by
> fixup_permanent_addr(), the dst_nopolicy parameter was not set.
> The typical use case is a user that configures an address on a down
> interface and then put this interface up.
> 
> Let's take care of this flag in addrconf_f6i_alloc(), so that every callers
> benefit ont it.
> 
> CC: stable@kernel.org
> CC: David Forster <dforster@brocade.com>
> Fixes: df789fe75206 ("ipv6: Provide ipv6 version of "disable_policy" sysctl")
> Reported-by: Siwar Zitouni <siwar.zitouni@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
> 
> I choose to be conservative in my patch, thus I filter anycast addresses. But
> I don't see why this flag is not set on anycast routes. Any thoughts
> about this?

no strong opinions here.

> 
>  net/ipv6/addrconf.c | 4 ----
>  net/ipv6/route.c    | 9 ++++++++-
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 1b1932502e9e..5864cbc30db6 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -1109,10 +1109,6 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
>  		goto out;
>  	}
>  
> -	if (net->ipv6.devconf_all->disable_policy ||
> -	    idev->cnf.disable_policy)
> -		f6i->dst_nopolicy = true;
> -
>  	neigh_parms_data_state_setall(idev->nd_parms);
>  
>  	ifa->addr = *cfg->pfx;
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index d25dc83bac62..828355710c57 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -4569,8 +4569,15 @@ struct fib6_info *addrconf_f6i_alloc(struct net *net,
>  	}
>  
>  	f6i = ip6_route_info_create(&cfg, gfp_flags, NULL);
> -	if (!IS_ERR(f6i))
> +	if (!IS_ERR(f6i)) {
>  		f6i->dst_nocount = true;
> +
> +		if (!anycast &&
> +		    (net->ipv6.devconf_all->disable_policy ||
> +		     idev->cnf.disable_policy))
> +			f6i->dst_nopolicy = true;
> +	}
> +
>  	return f6i;
>  }
>  

Reviewed-by: David Ahern <dsahern@kernel.org>
patchwork-bot+netdevbpf@kernel.org June 28, 2022, 5:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 23 Jun 2022 14:00:15 +0200 you wrote:
> When routes corresponding to addresses are restored by
> fixup_permanent_addr(), the dst_nopolicy parameter was not set.
> The typical use case is a user that configures an address on a down
> interface and then put this interface up.
> 
> Let's take care of this flag in addrconf_f6i_alloc(), so that every callers
> benefit ont it.
> 
> [...]

Here is the summary with links:
  - [net] ipv6: take care of disable_policy when restoring routes
    https://git.kernel.org/netdev/net/c/3b0dc529f56b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1b1932502e9e..5864cbc30db6 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1109,10 +1109,6 @@  ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
 		goto out;
 	}
 
-	if (net->ipv6.devconf_all->disable_policy ||
-	    idev->cnf.disable_policy)
-		f6i->dst_nopolicy = true;
-
 	neigh_parms_data_state_setall(idev->nd_parms);
 
 	ifa->addr = *cfg->pfx;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d25dc83bac62..828355710c57 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4569,8 +4569,15 @@  struct fib6_info *addrconf_f6i_alloc(struct net *net,
 	}
 
 	f6i = ip6_route_info_create(&cfg, gfp_flags, NULL);
-	if (!IS_ERR(f6i))
+	if (!IS_ERR(f6i)) {
 		f6i->dst_nocount = true;
+
+		if (!anycast &&
+		    (net->ipv6.devconf_all->disable_policy ||
+		     idev->cnf.disable_policy))
+			f6i->dst_nopolicy = true;
+	}
+
 	return f6i;
 }