netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush
@ 2011-02-25  5:48 Lucian Adrian Grijincu
  2011-02-25 15:30 ` Daniel Lezcano
  2011-03-02  3:25 ` Shan Wei
  0 siblings, 2 replies; 5+ messages in thread
From: Lucian Adrian Grijincu @ 2011-02-25  5:48 UTC (permalink / raw)
  To: netdev, David S . Miller, Daniel Lezcano, Benjamin Thery
  Cc: Lucian Adrian Grijincu

Before this patch issuing these commands:

  fd = open("/proc/sys/net/ipv6/route/flush")
  unshare(CLONE_NEWNET)
  write(fd, "stuff")

would flush the newly created net, not the original one.

The equivalent ipv4 code is correct (stores the net inside ->extra1).
---
 net/ipv6/route.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index f786aed..522563e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2604,14 +2604,16 @@ static
 int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write,
 			      void __user *buffer, size_t *lenp, loff_t *ppos)
 {
-	struct net *net = current->nsproxy->net_ns;
-	int delay = net->ipv6.sysctl.flush_delay;
-	if (write) {
-		proc_dointvec(ctl, write, buffer, lenp, ppos);
-		fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
-		return 0;
-	} else
+	struct net *net;
+	int delay;
+	if (!write)
 		return -EINVAL;
+
+	net = (struct net *)ctl->extra1;
+	delay = net->ipv6.sysctl.flush_delay;
+	proc_dointvec(ctl, write, buffer, lenp, ppos);
+	fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
+	return 0;
 }
 
 ctl_table ipv6_route_table_template[] = {
@@ -2698,6 +2700,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
 
 	if (table) {
 		table[0].data = &net->ipv6.sysctl.flush_delay;
+		table[0].extra1 = net;
 		table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh;
 		table[2].data = &net->ipv6.sysctl.ip6_rt_max_size;
 		table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
-- 
1.7.4.rc1.7.g2cf08.dirty


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

* Re: [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush
  2011-02-25  5:48 [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush Lucian Adrian Grijincu
@ 2011-02-25 15:30 ` Daniel Lezcano
  2011-02-25 19:02   ` David Miller
  2011-03-02  3:25 ` Shan Wei
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Lezcano @ 2011-02-25 15:30 UTC (permalink / raw)
  To: Lucian Adrian Grijincu; +Cc: netdev, David S . Miller, Benjamin Thery

On 02/25/2011 06:48 AM, Lucian Adrian Grijincu wrote:
> Before this patch issuing these commands:
>
>    fd = open("/proc/sys/net/ipv6/route/flush")
>    unshare(CLONE_NEWNET)
>    write(fd, "stuff")
>
> would flush the newly created net, not the original one.
>
> The equivalent ipv4 code is correct (stores the net inside ->extra1).
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>

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

* Re: [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush
  2011-02-25 15:30 ` Daniel Lezcano
@ 2011-02-25 19:02   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2011-02-25 19:02 UTC (permalink / raw)
  To: daniel.lezcano; +Cc: lucian.grijincu, netdev, benjamin.thery

From: Daniel Lezcano <daniel.lezcano@free.fr>
Date: Fri, 25 Feb 2011 16:30:25 +0100

> On 02/25/2011 06:48 AM, Lucian Adrian Grijincu wrote:
>> Before this patch issuing these commands:
>>
>>    fd = open("/proc/sys/net/ipv6/route/flush")
>>    unshare(CLONE_NEWNET)
>>    write(fd, "stuff")
>>
>> would flush the newly created net, not the original one.
>>
>> The equivalent ipv4 code is correct (stores the net inside ->extra1).
>> ---
> 
> Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>

Applied, thanks.

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

* Re: [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush
  2011-02-25  5:48 [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush Lucian Adrian Grijincu
  2011-02-25 15:30 ` Daniel Lezcano
@ 2011-03-02  3:25 ` Shan Wei
  2011-03-02 16:38   ` Daniel Lezcano
  1 sibling, 1 reply; 5+ messages in thread
From: Shan Wei @ 2011-03-02  3:25 UTC (permalink / raw)
  To: Lucian Adrian Grijincu
  Cc: netdev, David S . Miller, Daniel Lezcano, Benjamin Thery

Lucian Adrian Grijincu wrote, at 02/25/2011 01:48 PM:
> Before this patch issuing these commands:
> 
>   fd = open("/proc/sys/net/ipv6/route/flush")
>   unshare(CLONE_NEWNET)
>   write(fd, "stuff")
> 
> would flush the newly created net, not the original one.

After appling your patch, when excuting above commands, 
router cache still not be flushed in init net namespace.
But IPv4 is ok.

Host1:                   Host2 
ping6 Host2
                        (shell1)                                 
			open(/proc/sys/net/ipv6/route/flush)
			unshare(CLONE_NEWNET)
			while(1) {write(fd, "stuff")}           


			(shell2)  
                        ip -6 route show cache <==1*
			1*: IPv6 will show one route cache entry.
			    But IPv4 shows nothing.

As changlog said, after this patch, shell1 only fulsh the original
net namespace, not the newly created one. But from shell2, we 
can see that IPv6 route cache is not flushed.

Have i missed something?


-- 
Best Regards
-----
Shan Wei

> 
> The equivalent ipv4 code is correct (stores the net inside ->extra1).
> ---
>  net/ipv6/route.c |   17 ++++++++++-------
>  1 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index f786aed..522563e 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -2604,14 +2604,16 @@ static
>  int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write,
>  			      void __user *buffer, size_t *lenp, loff_t *ppos)
>  {
> -	struct net *net = current->nsproxy->net_ns;
> -	int delay = net->ipv6.sysctl.flush_delay;
> -	if (write) {
> -		proc_dointvec(ctl, write, buffer, lenp, ppos);
> -		fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
> -		return 0;
> -	} else
> +	struct net *net;
> +	int delay;
> +	if (!write)
>  		return -EINVAL;
> +
> +	net = (struct net *)ctl->extra1;
> +	delay = net->ipv6.sysctl.flush_delay;
> +	proc_dointvec(ctl, write, buffer, lenp, ppos);
> +	fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
> +	return 0;
>  }
>  
>  ctl_table ipv6_route_table_template[] = {
> @@ -2698,6 +2700,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
>  
>  	if (table) {
>  		table[0].data = &net->ipv6.sysctl.flush_delay;
> +		table[0].extra1 = net;
>  		table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh;
>  		table[2].data = &net->ipv6.sysctl.ip6_rt_max_size;
>  		table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;


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

* Re: [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush
  2011-03-02  3:25 ` Shan Wei
@ 2011-03-02 16:38   ` Daniel Lezcano
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2011-03-02 16:38 UTC (permalink / raw)
  To: Shan Wei; +Cc: Lucian Adrian Grijincu, netdev, David S . Miller, Benjamin Thery

On 03/02/2011 04:25 AM, Shan Wei wrote:
> Lucian Adrian Grijincu wrote, at 02/25/2011 01:48 PM:
>> Before this patch issuing these commands:
>>
>>    fd = open("/proc/sys/net/ipv6/route/flush")
>>    unshare(CLONE_NEWNET)
>>    write(fd, "stuff")
>>
>> would flush the newly created net, not the original one.
>
> After appling your patch, when excuting above commands,
> router cache still not be flushed in init net namespace.
> But IPv4 is ok.
>
> Host1:                   Host2
> ping6 Host2
>                          (shell1)
> 			open(/proc/sys/net/ipv6/route/flush)
> 			unshare(CLONE_NEWNET)
> 			while(1) {write(fd, "stuff")}
>
>
> 			(shell2)
>                          ip -6 route show cache<==1*
> 			1*: IPv6 will show one route cache entry.
> 			    But IPv4 shows nothing.
>
> As changlog said, after this patch, shell1 only fulsh the original
> net namespace, not the newly created one. But from shell2, we
> can see that IPv6 route cache is not flushed.
>
> Have i missed something?

Yes, you are right you shouldn't see any route from shell2.
Are you sure 'ip -6 route show cache' does not show the route cache in a 
window where ping6 created a new route and 'write(fd, "stuff")' did not 
flushed the new route yet ?

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

end of thread, other threads:[~2011-03-02 16:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-25  5:48 [PATCH] sysctl: ipv6: use correct net in ipv6_sysctl_rtcache_flush Lucian Adrian Grijincu
2011-02-25 15:30 ` Daniel Lezcano
2011-02-25 19:02   ` David Miller
2011-03-02  3:25 ` Shan Wei
2011-03-02 16:38   ` Daniel Lezcano

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).