]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/fib_hash.c
[NET]: Make core networking code use seq_open_private
[net-next-2.6.git] / net / ipv4 / fib_hash.c
index b21bb28d1fd04335af25a642b786e9fde85c12a8..527a6e0af5b60eb48b9e15459e8877db10c29db8 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/socket.h>
@@ -36,6 +35,7 @@
 #include <linux/netlink.h>
 #include <linux/init.h>
 
+#include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/protocol.h>
 #include <net/route.h>
@@ -457,6 +457,8 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
                        fib_release_info(fi_drop);
                        if (state & FA_S_ACCESSED)
                                rt_cache_flush(-1);
+                       rtmsg_fib(RTM_NEWROUTE, key, fa, cfg->fc_dst_len, tb->tb_id,
+                                 &cfg->fc_nlinfo, NLM_F_REPLACE);
                        return 0;
                }
 
@@ -524,7 +526,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
        rt_cache_flush(-1);
 
        rtmsg_fib(RTM_NEWROUTE, key, new_fa, cfg->fc_dst_len, tb->tb_id,
-                 &cfg->fc_nlinfo);
+                 &cfg->fc_nlinfo, 0);
        return 0;
 
 out_free_new_fa:
@@ -590,7 +592,7 @@ static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg)
 
                fa = fa_to_delete;
                rtmsg_fib(RTM_DELROUTE, key, fa, cfg->fc_dst_len,
-                         tb->tb_id, &cfg->fc_nlinfo);
+                         tb->tb_id, &cfg->fc_nlinfo, 0);
 
                kill_fn = 0;
                write_lock_bh(&fib_hash_lock);
@@ -770,13 +772,13 @@ struct fib_table * __init fib_hash_init(u32 id)
                fn_hash_kmem = kmem_cache_create("ip_fib_hash",
                                                 sizeof(struct fib_node),
                                                 0, SLAB_HWCACHE_ALIGN,
-                                                NULL, NULL);
+                                                NULL);
 
        if (fn_alias_kmem == NULL)
                fn_alias_kmem = kmem_cache_create("ip_fib_alias",
                                                  sizeof(struct fib_alias),
                                                  0, SLAB_HWCACHE_ALIGN,
-                                                 NULL, NULL);
+                                                 NULL);
 
        tb = kmalloc(sizeof(struct fib_table) + sizeof(struct fn_hash),
                     GFP_KERNEL);
@@ -1028,7 +1030,7 @@ out:
        return 0;
 }
 
-static struct seq_operations fib_seq_ops = {
+static const struct seq_operations fib_seq_ops = {
        .start  = fib_seq_start,
        .next   = fib_seq_next,
        .stop   = fib_seq_stop,
@@ -1037,24 +1039,8 @@ static struct seq_operations fib_seq_ops = {
 
 static int fib_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct fib_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-
-       rc = seq_open(file, &fib_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq          = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &fib_seq_ops,
+                       sizeof(struct fib_iter_state));
 }
 
 static const struct file_operations fib_seq_fops = {
@@ -1067,13 +1053,13 @@ static const struct file_operations fib_seq_fops = {
 
 int __init fib_proc_init(void)
 {
-       if (!proc_net_fops_create("route", S_IRUGO, &fib_seq_fops))
+       if (!proc_net_fops_create(&init_net, "route", S_IRUGO, &fib_seq_fops))
                return -ENOMEM;
        return 0;
 }
 
 void __init fib_proc_exit(void)
 {
-       proc_net_remove("route");
+       proc_net_remove(&init_net, "route");
 }
 #endif /* CONFIG_PROC_FS */