netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay
@ 2024-06-07 11:28 Petr Pavlu
  2024-06-10 15:26 ` David Ahern
  2024-06-13  1:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Petr Pavlu @ 2024-06-07 11:28 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	David Ahern
  Cc: Kui-Feng Lee, netdev, linux-kernel, Petr Pavlu

The net.ipv6.route.flush system parameter takes a value which specifies
a delay used during the flush operation for aging exception routes. The
written value is however not used in the currently requested flush and
instead utilized only in the next one.

A problem is that ipv6_sysctl_rtcache_flush() first reads the old value
of net->ipv6.sysctl.flush_delay into a local delay variable and then
calls proc_dointvec() which actually updates the sysctl based on the
provided input.

Fix the problem by switching the order of the two operations.

Fixes: 4990509f19e8 ("[NETNS][IPV6]: Make sysctls route per namespace.")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
---

Changes since v1 [1]:
- Minimize the fix, correct only the order of operations in
  ipv6_sysctl_rtcache_flush().

[1] https://lore.kernel.org/netdev/20240529135251.4074-1-petr.pavlu@suse.com/

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

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f083d9faba6b..952c2bf11709 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -6343,12 +6343,12 @@ static int ipv6_sysctl_rtcache_flush(struct ctl_table *ctl, int write,
 	if (!write)
 		return -EINVAL;
 
-	net = (struct net *)ctl->extra1;
-	delay = net->ipv6.sysctl.flush_delay;
 	ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
 	if (ret)
 		return ret;
 
+	net = (struct net *)ctl->extra1;
+	delay = net->ipv6.sysctl.flush_delay;
 	fib6_run_gc(delay <= 0 ? 0 : (unsigned long)delay, net, delay > 0);
 	return 0;
 }

base-commit: 8a92980606e3585d72d510a03b59906e96755b8a
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay
  2024-06-07 11:28 [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay Petr Pavlu
@ 2024-06-10 15:26 ` David Ahern
  2024-06-13  1:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2024-06-10 15:26 UTC (permalink / raw)
  To: Petr Pavlu, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: Kui-Feng Lee, netdev, linux-kernel

On 6/7/24 5:28 AM, Petr Pavlu wrote:
> The net.ipv6.route.flush system parameter takes a value which specifies
> a delay used during the flush operation for aging exception routes. The
> written value is however not used in the currently requested flush and
> instead utilized only in the next one.
> 
> A problem is that ipv6_sysctl_rtcache_flush() first reads the old value
> of net->ipv6.sysctl.flush_delay into a local delay variable and then
> calls proc_dointvec() which actually updates the sysctl based on the
> provided input.
> 
> Fix the problem by switching the order of the two operations.
> 
> Fixes: 4990509f19e8 ("[NETNS][IPV6]: Make sysctls route per namespace.")
> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
> ---
> 
> Changes since v1 [1]:
> - Minimize the fix, correct only the order of operations in
>   ipv6_sysctl_rtcache_flush().
> 
> [1] https://lore.kernel.org/netdev/20240529135251.4074-1-petr.pavlu@suse.com/
> 
>  net/ipv6/route.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index f083d9faba6b..952c2bf11709 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -6343,12 +6343,12 @@ static int ipv6_sysctl_rtcache_flush(struct ctl_table *ctl, int write,
>  	if (!write)
>  		return -EINVAL;
>  
> -	net = (struct net *)ctl->extra1;
> -	delay = net->ipv6.sysctl.flush_delay;
>  	ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
>  	if (ret)
>  		return ret;
>  
> +	net = (struct net *)ctl->extra1;
> +	delay = net->ipv6.sysctl.flush_delay;
>  	fib6_run_gc(delay <= 0 ? 0 : (unsigned long)delay, net, delay > 0);
>  	return 0;
>  }
> 
> base-commit: 8a92980606e3585d72d510a03b59906e96755b8a


Reviewed-by: David Ahern <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay
  2024-06-07 11:28 [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay Petr Pavlu
  2024-06-10 15:26 ` David Ahern
@ 2024-06-13  1:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-13  1:00 UTC (permalink / raw)
  To: Petr Pavlu
  Cc: davem, edumazet, kuba, pabeni, dsahern, thinker.li, netdev,
	linux-kernel

Hello:

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

On Fri,  7 Jun 2024 13:28:28 +0200 you wrote:
> The net.ipv6.route.flush system parameter takes a value which specifies
> a delay used during the flush operation for aging exception routes. The
> written value is however not used in the currently requested flush and
> instead utilized only in the next one.
> 
> A problem is that ipv6_sysctl_rtcache_flush() first reads the old value
> of net->ipv6.sysctl.flush_delay into a local delay variable and then
> calls proc_dointvec() which actually updates the sysctl based on the
> provided input.
> 
> [...]

Here is the summary with links:
  - [net,v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay
    https://git.kernel.org/bpf/bpf/c/14a20e5b4ad9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-13  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-07 11:28 [PATCH net v2] net/ipv6: Fix the RT cache flush via sysctl using a previous delay Petr Pavlu
2024-06-10 15:26 ` David Ahern
2024-06-13  1:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).