aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2007-11-06 08:27:11 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-11-07 07:09:18 -0500
commit33120b30cc3b8665204d4fcde7288638b0dd04d5 (patch)
treef0da78a94c07156b7c3454fc7741d05b61adf283 /net/ipv6
parent4f9f8311a08c0d95c70261264a2b47f2ae99683a (diff)
[IPV6]: Convert /proc/net/ipv6_route to seq_file interface
This removes last proc_net_create() user. Kudos to Benjamin Thery and Stephen Hemminger for comments on previous version. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/route.c91
1 files changed, 29 insertions, 62 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 95f8e4a62f68..973a97abc446 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -38,12 +38,8 @@
38#include <linux/in6.h> 38#include <linux/in6.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/if_arp.h> 40#include <linux/if_arp.h>
41
42#ifdef CONFIG_PROC_FS
43#include <linux/proc_fs.h> 41#include <linux/proc_fs.h>
44#include <linux/seq_file.h> 42#include <linux/seq_file.h>
45#endif
46
47#include <net/net_namespace.h> 43#include <net/net_namespace.h>
48#include <net/snmp.h> 44#include <net/snmp.h>
49#include <net/ipv6.h> 45#include <net/ipv6.h>
@@ -2288,71 +2284,50 @@ struct rt6_proc_arg
2288 2284
2289static int rt6_info_route(struct rt6_info *rt, void *p_arg) 2285static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2290{ 2286{
2291 struct rt6_proc_arg *arg = (struct rt6_proc_arg *) p_arg; 2287 struct seq_file *m = p_arg;
2292 2288
2293 if (arg->skip < arg->offset / RT6_INFO_LEN) { 2289 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_dst.addr),
2294 arg->skip++; 2290 rt->rt6i_dst.plen);
2295 return 0;
2296 }
2297
2298 if (arg->len >= arg->length)
2299 return 0;
2300
2301 arg->len += sprintf(arg->buffer + arg->len,
2302 NIP6_SEQFMT " %02x ",
2303 NIP6(rt->rt6i_dst.addr),
2304 rt->rt6i_dst.plen);
2305 2291
2306#ifdef CONFIG_IPV6_SUBTREES 2292#ifdef CONFIG_IPV6_SUBTREES
2307 arg->len += sprintf(arg->buffer + arg->len, 2293 seq_printf(m, NIP6_SEQFMT " %02x ", NIP6(rt->rt6i_src.addr),
2308 NIP6_SEQFMT " %02x ", 2294 rt->rt6i_src.plen);
2309 NIP6(rt->rt6i_src.addr),
2310 rt->rt6i_src.plen);
2311#else 2295#else
2312 arg->len += sprintf(arg->buffer + arg->len, 2296 seq_puts(m, "00000000000000000000000000000000 00 ");
2313 "00000000000000000000000000000000 00 ");
2314#endif 2297#endif
2315 2298
2316 if (rt->rt6i_nexthop) { 2299 if (rt->rt6i_nexthop) {
2317 arg->len += sprintf(arg->buffer + arg->len, 2300 seq_printf(m, NIP6_SEQFMT,
2318 NIP6_SEQFMT, 2301 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2319 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2320 } else { 2302 } else {
2321 arg->len += sprintf(arg->buffer + arg->len, 2303 seq_puts(m, "00000000000000000000000000000000");
2322 "00000000000000000000000000000000");
2323 } 2304 }
2324 arg->len += sprintf(arg->buffer + arg->len, 2305 seq_printf(m, " %08x %08x %08x %08x %8s\n",
2325 " %08x %08x %08x %08x %8s\n", 2306 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
2326 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt), 2307 rt->u.dst.__use, rt->rt6i_flags,
2327 rt->u.dst.__use, rt->rt6i_flags, 2308 rt->rt6i_dev ? rt->rt6i_dev->name : "");
2328 rt->rt6i_dev ? rt->rt6i_dev->name : "");
2329 return 0; 2309 return 0;
2330} 2310}
2331 2311
2332static int rt6_proc_info(char *buffer, char **start, off_t offset, int length) 2312static int ipv6_route_show(struct seq_file *m, void *v)
2333{ 2313{
2334 struct rt6_proc_arg arg = { 2314 fib6_clean_all(rt6_info_route, 0, m);
2335 .buffer = buffer, 2315 return 0;
2336 .offset = offset, 2316}
2337 .length = length,
2338 };
2339
2340 fib6_clean_all(rt6_info_route, 0, &arg);
2341
2342 *start = buffer;
2343 if (offset)
2344 *start += offset % RT6_INFO_LEN;
2345
2346 arg.len -= offset % RT6_INFO_LEN;
2347
2348 if (arg.len > length)
2349 arg.len = length;
2350 if (arg.len < 0)
2351 arg.len = 0;
2352 2317
2353 return arg.len; 2318static int ipv6_route_open(struct inode *inode, struct file *file)
2319{
2320 return single_open(file, ipv6_route_show, NULL);
2354} 2321}
2355 2322
2323static const struct file_operations ipv6_route_proc_fops = {
2324 .owner = THIS_MODULE,
2325 .open = ipv6_route_open,
2326 .read = seq_read,
2327 .llseek = seq_lseek,
2328 .release = single_release,
2329};
2330
2356static int rt6_stats_seq_show(struct seq_file *seq, void *v) 2331static int rt6_stats_seq_show(struct seq_file *seq, void *v)
2357{ 2332{
2358 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n", 2333 seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n",
@@ -2489,22 +2464,14 @@ ctl_table ipv6_route_table[] = {
2489 2464
2490void __init ip6_route_init(void) 2465void __init ip6_route_init(void)
2491{ 2466{
2492#ifdef CONFIG_PROC_FS
2493 struct proc_dir_entry *p;
2494#endif
2495 ip6_dst_ops.kmem_cachep = 2467 ip6_dst_ops.kmem_cachep =
2496 kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0, 2468 kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0,
2497 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2469 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
2498 ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; 2470 ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep;
2499 2471
2500 fib6_init(); 2472 fib6_init();
2501#ifdef CONFIG_PROC_FS 2473 proc_net_fops_create(&init_net, "ipv6_route", 0, &ipv6_route_proc_fops);
2502 p = proc_net_create(&init_net, "ipv6_route", 0, rt6_proc_info);
2503 if (p)
2504 p->owner = THIS_MODULE;
2505
2506 proc_net_fops_create(&init_net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops); 2474 proc_net_fops_create(&init_net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops);
2507#endif
2508#ifdef CONFIG_XFRM 2475#ifdef CONFIG_XFRM
2509 xfrm6_init(); 2476 xfrm6_init();
2510#endif 2477#endif