Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.git] / net / ipv6 / route.c
index 19c906f..b46ad53 100644 (file)
@@ -3,7 +3,7 @@
  *     FIB front-end.
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $
  *
@@ -201,7 +201,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
        if (idev != NULL) {
                rt->rt6i_idev = NULL;
                in6_dev_put(idev);
-       }       
+       }
 }
 
 static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -243,7 +243,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
        struct rt6_info *sprt;
 
        if (oif) {
-               for (sprt = rt; sprt; sprt = sprt->u.next) {
+               for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
                        struct net_device *dev = sprt->rt6i_dev;
                        if (dev->ifindex == oif)
                                return sprt;
@@ -252,7 +252,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
                                    sprt->rt6i_idev->dev->ifindex != oif) {
                                        if (strict && oif)
                                                continue;
-                                       if (local && (!oif || 
+                                       if (local && (!oif ||
                                                      local->rt6i_idev->dev->ifindex == oif))
                                                continue;
                                }
@@ -308,27 +308,18 @@ static inline void rt6_probe(struct rt6_info *rt)
 /*
  * Default Router Selection (RFC 2461 6.3.6)
  */
-static int inline rt6_check_dev(struct rt6_info *rt, int oif)
+static inline int rt6_check_dev(struct rt6_info *rt, int oif)
 {
        struct net_device *dev = rt->rt6i_dev;
-       int ret = 0;
-
-       if (!oif)
-               return 2;
-       if (dev->flags & IFF_LOOPBACK) {
-               if (!WARN_ON(rt->rt6i_idev == NULL) &&
-                   rt->rt6i_idev->dev->ifindex == oif)
-                       ret = 1;
-               else
-                       return 0;
-       }
-       if (dev->ifindex == oif)
+       if (!oif || dev->ifindex == oif)
                return 2;
-
-       return ret;
+       if ((dev->flags & IFF_LOOPBACK) &&
+           rt->rt6i_idev && rt->rt6i_idev->dev->ifindex == oif)
+               return 1;
+       return 0;
 }
 
-static int inline rt6_check_neigh(struct rt6_info *rt)
+static inline int rt6_check_neigh(struct rt6_info *rt)
 {
        struct neighbour *neigh = rt->rt6i_nexthop;
        int m = 0;
@@ -350,7 +341,7 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
                           int strict)
 {
        int m, n;
-               
+
        m = rt6_check_dev(rt, oif);
        if (!m && (strict & RT6_LOOKUP_F_IFACE))
                return -1;
@@ -363,55 +354,76 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
        return m;
 }
 
-static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
-                                  int strict)
+static struct rt6_info *find_match(struct rt6_info *rt, int oif, int strict,
+                                  int *mpri, struct rt6_info *match)
+{
+       int m;
+
+       if (rt6_check_expired(rt))
+               goto out;
+
+       m = rt6_score_route(rt, oif, strict);
+       if (m < 0)
+               goto out;
+
+       if (m > *mpri) {
+               if (strict & RT6_LOOKUP_F_REACHABLE)
+                       rt6_probe(match);
+               *mpri = m;
+               match = rt;
+       } else if (strict & RT6_LOOKUP_F_REACHABLE) {
+               rt6_probe(rt);
+       }
+
+out:
+       return match;
+}
+
+static struct rt6_info *find_rr_leaf(struct fib6_node *fn,
+                                    struct rt6_info *rr_head,
+                                    u32 metric, int oif, int strict)
 {
-       struct rt6_info *match = NULL, *last = NULL;
-       struct rt6_info *rt, *rt0 = *head;
-       u32 metric;
+       struct rt6_info *rt, *match;
        int mpri = -1;
 
-       RT6_TRACE("%s(head=%p(*head=%p), oif=%d)\n",
-                 __FUNCTION__, head, head ? *head : NULL, oif);
+       match = NULL;
+       for (rt = rr_head; rt && rt->rt6i_metric == metric;
+            rt = rt->u.dst.rt6_next)
+               match = find_match(rt, oif, strict, &mpri, match);
+       for (rt = fn->leaf; rt && rt != rr_head && rt->rt6i_metric == metric;
+            rt = rt->u.dst.rt6_next)
+               match = find_match(rt, oif, strict, &mpri, match);
 
-       for (rt = rt0, metric = rt0->rt6i_metric;
-            rt && rt->rt6i_metric == metric && (!last || rt != rt0);
-            rt = rt->u.next) {
-               int m;
+       return match;
+}
 
-               if (rt6_check_expired(rt))
-                       continue;
+static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict)
+{
+       struct rt6_info *match, *rt0;
 
-               last = rt;
+       RT6_TRACE("%s(fn->leaf=%p, oif=%d)\n",
+                 __FUNCTION__, fn->leaf, oif);
 
-               m = rt6_score_route(rt, oif, strict);
-               if (m < 0)
-                       continue;
+       rt0 = fn->rr_ptr;
+       if (!rt0)
+               fn->rr_ptr = rt0 = fn->leaf;
 
-               if (m > mpri) {
-                       if (strict & RT6_LOOKUP_F_REACHABLE)
-                               rt6_probe(match);
-                       match = rt;
-                       mpri = m;
-               } else if (strict & RT6_LOOKUP_F_REACHABLE) {
-                       rt6_probe(rt);
-               }
-       }
+       match = find_rr_leaf(fn, rt0, rt0->rt6i_metric, oif, strict);
 
        if (!match &&
-           (strict & RT6_LOOKUP_F_REACHABLE) &&
-           last && last != rt0) {
+           (strict & RT6_LOOKUP_F_REACHABLE)) {
+               struct rt6_info *next = rt0->u.dst.rt6_next;
+
                /* no entries matched; do round-robin */
-               static DEFINE_SPINLOCK(lock);
-               spin_lock(&lock);
-               *head = rt0->u.next;
-               rt0->u.next = last->u.next;
-               last->u.next = rt0;
-               spin_unlock(&lock);
+               if (!next || next->rt6i_metric != rt0->rt6i_metric)
+                       next = fn->leaf;
+
+               if (next != rt0)
+                       fn->rr_ptr = next;
        }
 
-       RT6_TRACE("%s() => %p, score=%d\n",
-                 __FUNCTION__, match, mpri);
+       RT6_TRACE("%s() => %p\n",
+                 __FUNCTION__, match);
 
        return (match ? match : &ip6_null_entry);
 }
@@ -563,6 +575,8 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr,
        return NULL;
 }
 
+EXPORT_SYMBOL(rt6_lookup);
+
 /* ip6_ins_rt is called with FREE table->tb6_lock.
    It takes new route entry, the addition fails by any reason the
    route is freed. In any case, if caller does not hold it, it may
@@ -657,7 +671,7 @@ restart_2:
        fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
 
 restart:
-       rt = rt6_select(&fn->leaf, fl->iif, strict | reachable);
+       rt = rt6_select(fn, fl->iif, strict | reachable);
        BACKTRACK(&fl->fl6_src);
        if (rt == &ip6_null_entry ||
            rt->rt6i_flags & RTF_CACHE)
@@ -712,7 +726,7 @@ out2:
 
 void ip6_route_input(struct sk_buff *skb)
 {
-       struct ipv6hdr *iph = skb->nh.ipv6h;
+       struct ipv6hdr *iph = ipv6_hdr(skb);
        int flags = RT6_LOOKUP_F_HAS_SADDR;
        struct flowi fl = {
                .iif = skb->dev->ifindex,
@@ -723,7 +737,7 @@ void ip6_route_input(struct sk_buff *skb)
                                .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
                        },
                },
-               .mark = skb->mark,
+               .mark = skb->mark,
                .proto = iph->nexthdr,
        };
 
@@ -752,7 +766,7 @@ restart_2:
        fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
 
 restart:
-       rt = rt6_select(&fn->leaf, fl->oif, strict | reachable);
+       rt = rt6_select(fn, fl->oif, strict | reachable);
        BACKTRACK(&fl->fl6_src);
        if (rt == &ip6_null_entry ||
            rt->rt6i_flags & RTF_CACHE)
@@ -817,6 +831,7 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
        return fib6_rule_lookup(fl, flags, ip6_pol_route_output);
 }
 
+EXPORT_SYMBOL(ip6_route_output);
 
 /*
  *     Destination cache support functions
@@ -888,9 +903,9 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
                mtu = ip6_rt_min_advmss;
 
        /*
-        * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and 
-        * corresponding MSS is IPV6_MAXPLEN - tcp_header_size. 
-        * IPV6_MAXPLEN is also valid and means: "any MSS, 
+        * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
+        * corresponding MSS is IPV6_MAXPLEN - tcp_header_size.
+        * IPV6_MAXPLEN is also valid and means: "any MSS,
         * rely only on pmtu discovery"
         */
        if (mtu > IPV6_MAXPLEN - sizeof(struct tcphdr))
@@ -901,7 +916,7 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
 static struct dst_entry *ndisc_dst_gc_list;
 static DEFINE_SPINLOCK(ndisc_lock);
 
-struct dst_entry *ndisc_dst_alloc(struct net_device *dev, 
+struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
                                  struct neighbour *neigh,
                                  struct in6_addr *addr,
                                  int (*output)(struct sk_buff *))
@@ -934,8 +949,8 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
        rt->u.dst.output  = output;
 
 #if 0  /* there's no chance to use these for ndisc */
-       rt->u.dst.flags   = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST 
-                               ? DST_HOST 
+       rt->u.dst.flags   = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST
+                               ? DST_HOST
                                : 0;
        ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
        rt->rt6i_dst.plen = 128;
@@ -958,7 +973,7 @@ int ndisc_dst_gc(int *more)
        int freed;
 
        next = NULL;
-       freed = 0;
+       freed = 0;
 
        spin_lock_bh(&ndisc_lock);
        pprev = &ndisc_dst_gc_list;
@@ -1276,9 +1291,9 @@ static int ip6_route_del(struct fib6_config *cfg)
        fn = fib6_locate(&table->tb6_root,
                         &cfg->fc_dst, cfg->fc_dst_len,
                         &cfg->fc_src, cfg->fc_src_len);
-       
+
        if (fn) {
-               for (rt = fn->leaf; rt; rt = rt->u.next) {
+               for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                        if (cfg->fc_ifindex &&
                            (rt->rt6i_dev == NULL ||
                             rt->rt6i_dev->ifindex != cfg->fc_ifindex))
@@ -1329,7 +1344,7 @@ static struct rt6_info *__ip6_route_redirect(struct fib6_table *table,
        read_lock_bh(&table->tb6_lock);
        fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
 restart:
-       for (rt = fn->leaf; rt; rt = rt->u.next) {
+       for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                /*
                 * Current route is on-link; redirect is always invalid.
                 *
@@ -1405,7 +1420,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
         *      We have finally decided to accept it.
         */
 
-       neigh_update(neigh, lladdr, NUD_STALE, 
+       neigh_update(neigh, lladdr, NUD_STALE,
                     NEIGH_UPDATE_F_WEAK_OVERRIDE|
                     NEIGH_UPDATE_F_OVERRIDE|
                     (on_link ? 0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
@@ -1454,7 +1469,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
        }
 
 out:
-        dst_release(&rt->u.dst);
+       dst_release(&rt->u.dst);
        return;
 }
 
@@ -1478,7 +1493,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
 
        if (pmtu < IPV6_MIN_MTU) {
                /*
-                * According to RFC2460, PMTU is set to the IPv6 Minimum Link 
+                * According to RFC2460, PMTU is set to the IPv6 Minimum Link
                 * MTU (1280) and a fragment header should always be included
                 * after a node receiving Too Big message reporting PMTU is
                 * less than the IPv6 Minimum Link MTU.
@@ -1590,7 +1605,7 @@ static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixle
        if (!fn)
                goto out;
 
-       for (rt = fn->leaf; rt; rt = rt->u.next) {
+       for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
                if (rt->rt6i_dev->ifindex != ifindex)
                        continue;
                if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY))
@@ -1632,7 +1647,7 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle
 #endif
 
 struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *dev)
-{      
+{
        struct rt6_info *rt;
        struct fib6_table *table;
 
@@ -1641,7 +1656,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d
                return NULL;
 
        write_lock_bh(&table->tb6_lock);
-       for (rt = table->tb6_root.leaf; rt; rt=rt->u.next) {
+       for (rt = table->tb6_root.leaf; rt; rt=rt->u.dst.rt6_next) {
                if (dev == rt->rt6i_dev &&
                    ((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) &&
                    ipv6_addr_equal(&rt->rt6i_gateway, addr))
@@ -1684,7 +1699,7 @@ void rt6_purge_dflt_routers(void)
 
 restart:
        read_lock_bh(&table->tb6_lock);
-       for (rt = table->tb6_root.leaf; rt; rt = rt->u.next) {
+       for (rt = table->tb6_root.leaf; rt; rt = rt->u.dst.rt6_next) {
                if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
                        dst_hold(&rt->u.dst);
                        read_unlock_bh(&table->tb6_lock);
@@ -1745,7 +1760,7 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
                rtnl_unlock();
 
                return err;
-       };
+       }
 
        return -EINVAL;
 }
@@ -1754,13 +1769,22 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
  *     Drop the packet on the floor
  */
 
-static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
+static inline int ip6_pkt_drop(struct sk_buff *skb, int code,
+                              int ipstats_mib_noroutes)
 {
-       int type = ipv6_addr_type(&skb->nh.ipv6h->daddr);
-       if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED)
-               IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INADDRERRORS);
-
-       IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_OUTNOROUTES);
+       int type;
+       switch (ipstats_mib_noroutes) {
+       case IPSTATS_MIB_INNOROUTES:
+               type = ipv6_addr_type(&ipv6_hdr(skb)->daddr);
+               if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED) {
+                       IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INADDRERRORS);
+                       break;
+               }
+               /* FALLTHROUGH */
+       case IPSTATS_MIB_OUTNOROUTES:
+               IP6_INC_STATS(ip6_dst_idev(skb->dst), ipstats_mib_noroutes);
+               break;
+       }
        icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev);
        kfree_skb(skb);
        return 0;
@@ -1768,26 +1792,26 @@ static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
 
 static int ip6_pkt_discard(struct sk_buff *skb)
 {
-       return ip6_pkt_drop(skb, ICMPV6_NOROUTE);
+       return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_INNOROUTES);
 }
 
 static int ip6_pkt_discard_out(struct sk_buff *skb)
 {
        skb->dev = skb->dst->dev;
-       return ip6_pkt_discard(skb);
+       return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES);
 }
 
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
 
 static int ip6_pkt_prohibit(struct sk_buff *skb)
 {
-       return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED);
+       return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES);
 }
 
 static int ip6_pkt_prohibit_out(struct sk_buff *skb)
 {
        skb->dev = skb->dst->dev;
-       return ip6_pkt_prohibit(skb);
+       return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
 }
 
 static int ip6_pkt_blk_hole(struct sk_buff *skb)
@@ -1896,8 +1920,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
         */
        if (rt->rt6i_dev == arg->dev &&
            !dst_metric_locked(&rt->u.dst, RTAX_MTU) &&
-            (dst_mtu(&rt->u.dst) > arg->mtu ||
-             (dst_mtu(&rt->u.dst) < arg->mtu &&
+           (dst_mtu(&rt->u.dst) > arg->mtu ||
+            (dst_mtu(&rt->u.dst) < arg->mtu &&
              dst_mtu(&rt->u.dst) == idev->cnf.mtu6)))
                rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu;
        rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu);
@@ -1991,7 +2015,7 @@ errout:
        return err;
 }
 
-int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
        struct fib6_config cfg;
        int err;
@@ -2003,7 +2027,7 @@ int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
        return ip6_route_del(&cfg);
 }
 
-int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
+static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
        struct fib6_config cfg;
        int err;
@@ -2083,13 +2107,13 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
 
        if (dst) {
                NLA_PUT(skb, RTA_DST, 16, dst);
-               rtm->rtm_dst_len = 128;
+               rtm->rtm_dst_len = 128;
        } else if (rtm->rtm_dst_len)
                NLA_PUT(skb, RTA_DST, 16, &rt->rt6i_dst.addr);
 #ifdef CONFIG_IPV6_SUBTREES
        if (src) {
                NLA_PUT(skb, RTA_SRC, 16, src);
-               rtm->rtm_src_len = 128;
+               rtm->rtm_src_len = 128;
        } else if (rtm->rtm_src_len)
                NLA_PUT(skb, RTA_SRC, 16, &rt->rt6i_src.addr);
 #endif
@@ -2140,7 +2164,7 @@ int rt6_dump_route(struct rt6_info *rt, void *p_arg)
                     prefix, NLM_F_MULTI);
 }
 
-int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
+static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
 {
        struct nlattr *tb[RTA_MAX+1];
        struct rt6_info *rt;
@@ -2194,7 +2218,7 @@ int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
        /* Reserve room for dummy headers, this skb can pass
           through good chunk of routing engine.
         */
-       skb->mac.raw = skb->data;
+       skb_reset_mac_header(skb);
        skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr));
 
        rt = (struct rt6_info*) ip6_route_output(NULL, &fl);
@@ -2299,7 +2323,7 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
        arg->len += sprintf(arg->buffer + arg->len,
                            " %08x %08x %08x %08x %8s\n",
                            rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
-                           rt->u.dst.__use, rt->rt6i_flags, 
+                           rt->u.dst.__use, rt->rt6i_flags,
                            rt->rt6i_dev ? rt->rt6i_dev->name : "");
        return 0;
 }
@@ -2345,7 +2369,7 @@ static int rt6_stats_seq_open(struct inode *inode, struct file *file)
        return single_open(file, rt6_stats_seq_show, NULL);
 }
 
-static struct file_operations rt6_stats_seq_fops = {
+static const struct file_operations rt6_stats_seq_fops = {
        .owner   = THIS_MODULE,
        .open    = rt6_stats_seq_open,
        .read    = seq_read,
@@ -2371,91 +2395,91 @@ int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, struct file * filp,
 }
 
 ctl_table ipv6_route_table[] = {
-        {
-               .ctl_name       =       NET_IPV6_ROUTE_FLUSH, 
+       {
+               .ctl_name       =       NET_IPV6_ROUTE_FLUSH,
                .procname       =       "flush",
-               .data           =       &flush_delay,
+               .data           =       &flush_delay,
                .maxlen         =       sizeof(int),
                .mode           =       0200,
-               .proc_handler   =       &ipv6_sysctl_rtcache_flush
+               .proc_handler   =       &ipv6_sysctl_rtcache_flush
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_THRESH,
                .procname       =       "gc_thresh",
-               .data           =       &ip6_dst_ops.gc_thresh,
+               .data           =       &ip6_dst_ops.gc_thresh,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec,
+               .proc_handler   =       &proc_dointvec,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MAX_SIZE,
                .procname       =       "max_size",
-               .data           =       &ip6_rt_max_size,
+               .data           =       &ip6_rt_max_size,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec,
+               .proc_handler   =       &proc_dointvec,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_MIN_INTERVAL,
                .procname       =       "gc_min_interval",
-               .data           =       &ip6_rt_gc_min_interval,
+               .data           =       &ip6_rt_gc_min_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_TIMEOUT,
                .procname       =       "gc_timeout",
-               .data           =       &ip6_rt_gc_timeout,
+               .data           =       &ip6_rt_gc_timeout,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_INTERVAL,
                .procname       =       "gc_interval",
-               .data           =       &ip6_rt_gc_interval,
+               .data           =       &ip6_rt_gc_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_ELASTICITY,
                .procname       =       "gc_elasticity",
-               .data           =       &ip6_rt_gc_elasticity,
+               .data           =       &ip6_rt_gc_elasticity,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MTU_EXPIRES,
                .procname       =       "mtu_expires",
-               .data           =       &ip6_rt_mtu_expires,
+               .data           =       &ip6_rt_mtu_expires,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_MIN_ADVMSS,
                .procname       =       "min_adv_mss",
-               .data           =       &ip6_rt_min_advmss,
+               .data           =       &ip6_rt_min_advmss,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_jiffies,
+               .proc_handler   =       &proc_dointvec_jiffies,
                .strategy       =       &sysctl_jiffies,
        },
        {
                .ctl_name       =       NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,
                .procname       =       "gc_min_interval_ms",
-               .data           =       &ip6_rt_gc_min_interval,
+               .data           =       &ip6_rt_gc_min_interval,
                .maxlen         =       sizeof(int),
                .mode           =       0644,
-               .proc_handler   =       &proc_dointvec_ms_jiffies,
+               .proc_handler   =       &proc_dointvec_ms_jiffies,
                .strategy       =       &sysctl_ms_jiffies,
        },
        { .ctl_name = 0 }
@@ -2465,8 +2489,9 @@ ctl_table ipv6_route_table[] = {
 
 void __init ip6_route_init(void)
 {
+#ifdef         CONFIG_PROC_FS
        struct proc_dir_entry *p;
-
+#endif
        ip6_dst_ops.kmem_cachep =
                kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0,
                                  SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
@@ -2484,6 +2509,10 @@ void __init ip6_route_init(void)
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
        fib6_rules_init();
 #endif
+
+       __rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL);
+       __rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL);
+       __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL);
 }
 
 void ip6_route_cleanup(void)