]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/ip6_fib.c
[IPV6]: Remove useless code from fib6_del_route().
[net-next-2.6.git] / net / ipv6 / ip6_fib.c
index ca08ee88d07f2913558c0ac331201f7d3a05527b..7165a5e90f451062a052b6576c8c2a412054c1e4 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];
 
@@ -619,14 +623,6 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
 
        ins = &fn->leaf;
 
-       if (fn->fn_flags&RTN_TL_ROOT &&
-           fn->leaf == &ip6_null_entry &&
-           !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
-               fn->leaf = rt;
-               rt->u.dst.rt6_next = NULL;
-               goto out;
-       }
-
        for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) {
                /*
                 *      Search for duplicates
@@ -666,7 +662,6 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
         *      insert node
         */
 
-out:
        rt->u.dst.rt6_next = iter;
        *ins = rt;
        rt->rt6i_node = fn;
@@ -1131,9 +1126,6 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
 
        rt->u.dst.rt6_next = NULL;
 
-       if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
-               fn->leaf = &ip6_null_entry;
-
        /* If it was last route, expunge its radix tree node */
        if (fn->leaf == NULL) {
                fn->fn_flags &= ~RTN_RTINFO;
@@ -1320,15 +1312,16 @@ static int fib6_walk(struct fib6_walker_t *w)
 
 static int fib6_clean_node(struct fib6_walker_t *w)
 {
+       struct nl_info info = {};
        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);
                if (res < 0) {
                        w->leaf = rt;
-                       res = fib6_del(rt, NULL);
+                       res = fib6_del(rt, &info);
                        if (res) {
 #if RT6_DEBUG >= 2
                                printk(KERN_DEBUG "fib6_clean_node: del failed: rt=%p@%p err=%d\n", rt, rt->rt6i_node, res);
@@ -1478,16 +1471,27 @@ 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, NULL);
+                                          0, SLAB_HWCACHE_ALIGN,
+                                          NULL);
+       if (!fib6_node_kmem)
+               return -ENOMEM;
 
        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)