OpenVZ Forum


Home » Mailing lists » Devel » [patch 27/38][IPV6] route6 - Make proc entry /proc/net/rt6_stats per namespace
[patch 27/38][IPV6] route6 - Make proc entry /proc/net/rt6_stats per namespace [message #24276] Mon, 03 December 2007 16:17
Daniel Lezcano is currently offline  Daniel Lezcano
Messages: 417
Registered: June 2006
Senior Member
Make the proc entry /proc/net/rt6_stats work in all network namespace.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
---
 net/ipv6/route.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

Index: linux-2.6-netns/net/ipv6/route.c
===================================================================
--- linux-2.6-netns.orig/net/ipv6/route.c
+++ linux-2.6-netns/net/ipv6/route.c
@@ -2350,21 +2350,31 @@ static const struct file_operations ipv6
 
 static int rt6_stats_seq_show(struct seq_file *seq, void *v)
 {
+	struct net *net = (struct net*)seq->private;
 	seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n",
-		   init_net.rt6_stats->fib_nodes,
-		   init_net.rt6_stats->fib_route_nodes,
-		   init_net.rt6_stats->fib_rt_alloc,
-		   init_net.rt6_stats->fib_rt_entries,
-		   init_net.rt6_stats->fib_rt_cache,
+		   net->rt6_stats->fib_nodes,
+		   net->rt6_stats->fib_route_nodes,
+		   net->rt6_stats->fib_rt_alloc,
+		   net->rt6_stats->fib_rt_entries,
+		   net->rt6_stats->fib_rt_cache,
 		   atomic_read(&ip6_dst_ops.entries),
-		   init_net.rt6_stats->fib_discarded_routes);
+		   net->rt6_stats->fib_discarded_routes);
 
 	return 0;
 }
 
 static int rt6_stats_seq_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, rt6_stats_seq_show, NULL);
+	struct net *net = get_proc_net(inode);
+	return single_open(file, rt6_stats_seq_show, net);
+}
+
+static int rt6_stats_seq_release(struct inode *inode, struct file *file)
+{
+	struct seq_file *seq = file->private_data;
+	struct net *net = (struct net *)seq->private;
+	put_net(net);
+	return single_release(inode, file);
 }
 
 static const struct file_operations rt6_stats_seq_fops = {
@@ -2372,7 +2382,7 @@ static const struct file_operations rt6_
 	.open	 = rt6_stats_seq_open,
 	.read	 = seq_read,
 	.llseek	 = seq_lseek,
-	.release = single_release,
+	.release = rt6_stats_seq_release,
 };
 #endif	/* CONFIG_PROC_FS */
 

-- 
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Previous Topic: [patch 26/38][IPV6] route6 - Pass the network namespace parameter to rt6_lookup
Next Topic: [patch 28/38][IPV6] route6 - Pass network namespace to rt6_add_route_info and rt6_get_route_info
Goto Forum:
  


Current Time: Thu Aug 14 10:42:26 GMT 2025

Total time taken to generate the page: 0.58133 seconds