]> Pileus Git - ~andy/linux/blobdiff - net/ipv6/ip6_fib.c
[IPV6]: Make fib6_init to return an error code.
[~andy/linux] / net / ipv6 / ip6_fib.c
index 6a612a701eaaa34b35d6d7778b80c7f62c6bde31..c100b44f2b87cc64b48c9bdb36b25b2fcf73e05c 100644 (file)
@@ -361,6 +361,7 @@ end:
 
 static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        unsigned int h, s_h;
        unsigned int e = 0, s_e;
        struct rt6_rtnl_dump_arg arg;
@@ -369,6 +370,9 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
        struct hlist_node *node;
        int res = 0;
 
+       if (net != &init_net)
+               return 0;
+
        s_h = cb->args[0];
        s_e = cb->args[1];
 
@@ -1313,7 +1317,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
 {
        int res;
        struct rt6_info *rt;
-       struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w;
+       struct fib6_cleaner_t *c = container_of(w, struct fib6_cleaner_t, w);
 
        for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
                res = c->func(rt, c->arg);
@@ -1469,16 +1473,24 @@ void fib6_run_gc(unsigned long dummy)
        spin_unlock_bh(&fib6_gc_lock);
 }
 
-void __init fib6_init(void)
+int __init fib6_init(void)
 {
+       int ret;
        fib6_node_kmem = kmem_cache_create("fib6_nodes",
                                           sizeof(struct fib6_node),
                                           0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
                                           NULL);
-
        fib6_tables_init();
 
-       __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
+       ret = __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
+       if (ret)
+               goto out_kmem_cache_create;
+out:
+       return ret;
+
+out_kmem_cache_create:
+       kmem_cache_destroy(fib6_node_kmem);
+       goto out;
 }
 
 void fib6_gc_cleanup(void)