Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[powerpc.git] / net / ipv6 / ip6_fib.c
index f90ab52..ca08ee8 100644 (file)
@@ -150,8 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
 {
        struct fib6_node *fn;
 
-       if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL)
-               memset(fn, 0, sizeof(struct fib6_node));
+       fn = kmem_cache_zalloc(fib6_node_kmem, GFP_ATOMIC);
 
        return fn;
 }
@@ -298,7 +297,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
        int res;
        struct rt6_info *rt;
 
-       for (rt = w->leaf; rt; rt = rt->u.next) {
+       for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
                res = rt6_dump_route(rt, w->args);
                if (res < 0) {
                        /* Frame is full, suspend walking */
@@ -360,7 +359,7 @@ end:
        return res;
 }
 
-int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
 {
        unsigned int h, s_h;
        unsigned int e = 0, s_e;
@@ -624,11 +623,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
            fn->leaf == &ip6_null_entry &&
            !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
                fn->leaf = rt;
-               rt->u.next = NULL;
+               rt->u.dst.rt6_next = NULL;
                goto out;
        }
 
-       for (iter = fn->leaf; iter; iter=iter->u.next) {
+       for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) {
                /*
                 *      Search for duplicates
                 */
@@ -656,15 +655,19 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
                if (iter->rt6i_metric > rt->rt6i_metric)
                        break;
 
-               ins = &iter->u.next;
+               ins = &iter->u.dst.rt6_next;
        }
 
+       /* Reset round-robin state, if necessary */
+       if (ins == &fn->leaf)
+               fn->rr_ptr = NULL;
+
        /*
         *      insert node
         */
 
 out:
-       rt->u.next = iter;
+       rt->u.dst.rt6_next = iter;
        *ins = rt;
        rt->rt6i_node = fn;
        atomic_inc(&rt->rt6i_ref);
@@ -1105,24 +1108,28 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
        RT6_TRACE("fib6_del_route\n");
 
        /* Unlink it */
-       *rtp = rt->u.next;
+       *rtp = rt->u.dst.rt6_next;
        rt->rt6i_node = NULL;
        rt6_stats.fib_rt_entries--;
        rt6_stats.fib_discarded_routes++;
 
+       /* Reset round-robin state, if necessary */
+       if (fn->rr_ptr == rt)
+               fn->rr_ptr = NULL;
+
        /* Adjust walkers */
        read_lock(&fib6_walker_lock);
        FOR_WALKERS(w) {
                if (w->state == FWS_C && w->leaf == rt) {
                        RT6_TRACE("walker %p adjusted by delroute\n", w);
-                       w->leaf = rt->u.next;
+                       w->leaf = rt->u.dst.rt6_next;
                        if (w->leaf == NULL)
                                w->state = FWS_U;
                }
        }
        read_unlock(&fib6_walker_lock);
 
-       rt->u.next = NULL;
+       rt->u.dst.rt6_next = NULL;
 
        if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
                fn->leaf = &ip6_null_entry;
@@ -1190,7 +1197,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
         *      Walk the leaf entries looking for ourself
         */
 
-       for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) {
+       for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.dst.rt6_next) {
                if (*rtp == rt) {
                        fib6_del_route(fn, rtp, info);
                        return 0;
@@ -1317,7 +1324,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
        struct rt6_info *rt;
        struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w;
 
-       for (rt = w->leaf; rt; rt = rt->u.next) {
+       for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
                res = c->func(rt, c->arg);
                if (res < 0) {
                        w->leaf = rt;
@@ -1479,6 +1486,8 @@ void __init fib6_init(void)
                                           NULL, NULL);
 
        fib6_tables_init();
+
+       __rtnl_register(PF_INET6, RTM_GETROUTE, NULL, inet6_dump_fib);
 }
 
 void fib6_gc_cleanup(void)