bridge: fix IPV6=n build
[safe/jmp/linux-2.6] / net / ipv6 / ip6mr.c
index da673ef..90e7630 100644 (file)
 #include <linux/fcntl.h>
 #include <linux/stat.h>
 #include <linux/socket.h>
-#include <linux/in.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
 #include <linux/inetdevice.h>
-#include <linux/igmp.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
-#include <net/ip.h>
 #include <net/protocol.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
-#include <net/icmp.h>
-#include <net/udp.h>
 #include <net/raw.h>
-#include <net/route.h>
 #include <linux/notifier.h>
 #include <linux/if_arp.h>
-#include <linux/netfilter_ipv4.h>
-#include <net/ipip.h>
 #include <net/checksum.h>
 #include <net/netlink.h>
 
@@ -83,7 +74,7 @@ static int mroute_do_pim;
 #define mroute_do_pim 0
 #endif
 
-static struct mfc6_cache *mfc6_cache_array[MFC_LINES]; /* Forwarding cache     */
+static struct mfc6_cache *mfc6_cache_array[MFC6_LINES];        /* Forwarding cache     */
 
 static struct mfc6_cache *mfc_unres_queue;             /* Queue of unresolved entries */
 static atomic_t cache_resolve_queue_len;               /* Size of unresolved   */
@@ -102,7 +93,7 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
 static struct kmem_cache *mrt_cachep __read_mostly;
 
 static int ip6_mr_forward(struct sk_buff *skb, struct mfc6_cache *cache);
-static int ip6mr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert);
+static int ip6mr_cache_report(struct sk_buff *pkt, mifi_t mifi, int assert);
 static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm);
 
 #ifdef CONFIG_IPV6_PIMSM_V2
@@ -206,7 +197,7 @@ static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
                const char *name = vif->dev ? vif->dev->name : "none";
 
                seq_printf(seq,
-                          "%2Zd %-10s %8ld %7ld  %8ld %7ld %05X\n",
+                          "%2td %-10s %8ld %7ld  %8ld %7ld %05X\n",
                           vif - vif6_table,
                           name, vif->bytes_in, vif->pkt_in,
                           vif->bytes_out, vif->pkt_out,
@@ -367,7 +358,7 @@ static int pim6_rcv(struct sk_buff *skb)
        if (pim->type != ((PIM_VERSION << 4) | PIM_REGISTER) ||
            (pim->flags & PIM_NULL_REGISTER) ||
            (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
-            (u16)csum_fold(skb_checksum(skb, 0, skb->len, 0))))
+            csum_fold(skb_checksum(skb, 0, skb->len, 0))))
                goto drop;
 
        /* check if the inner packet is destined to mcast group */
@@ -397,8 +388,8 @@ static int pim6_rcv(struct sk_buff *skb)
        skb->ip_summed = 0;
        skb->pkt_type = PACKET_HOST;
        dst_release(skb->dst);
-       ((struct net_device_stats *)netdev_priv(reg_dev))->rx_bytes += skb->len;
-       ((struct net_device_stats *)netdev_priv(reg_dev))->rx_packets++;
+       reg_dev->stats.rx_bytes += skb->len;
+       reg_dev->stats.rx_packets++;
        skb->dst = NULL;
        nf_reset(skb);
        netif_rx(skb);
@@ -418,37 +409,28 @@ static struct inet6_protocol pim6_protocol = {
 static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        read_lock(&mrt_lock);
-       ((struct net_device_stats *)netdev_priv(dev))->tx_bytes += skb->len;
-       ((struct net_device_stats *)netdev_priv(dev))->tx_packets++;
+       dev->stats.tx_bytes += skb->len;
+       dev->stats.tx_packets++;
        ip6mr_cache_report(skb, reg_vif_num, MRT6MSG_WHOLEPKT);
        read_unlock(&mrt_lock);
        kfree_skb(skb);
        return 0;
 }
 
-static struct net_device_stats *reg_vif_get_stats(struct net_device *dev)
-{
-       return (struct net_device_stats *)netdev_priv(dev);
-}
-
 static void reg_vif_setup(struct net_device *dev)
 {
        dev->type               = ARPHRD_PIMREG;
        dev->mtu                = 1500 - sizeof(struct ipv6hdr) - 8;
        dev->flags              = IFF_NOARP;
        dev->hard_start_xmit    = reg_vif_xmit;
-       dev->get_stats          = reg_vif_get_stats;
        dev->destructor         = free_netdev;
 }
 
 static struct net_device *ip6mr_reg_vif(void)
 {
        struct net_device *dev;
-       struct inet6_dev *in_dev;
-
-       dev = alloc_netdev(sizeof(struct net_device_stats), "pim6reg",
-                          reg_vif_setup);
 
+       dev = alloc_netdev(0, "pim6reg", reg_vif_setup);
        if (dev == NULL)
                return NULL;
 
@@ -458,10 +440,6 @@ static struct net_device *ip6mr_reg_vif(void)
        }
        dev->iflink = 0;
 
-       in_dev = ipv6_find_idev(dev);
-       if (!in_dev)
-               goto failure;
-
        if (dev_open(dev))
                goto failure;
 
@@ -597,9 +575,9 @@ static void ip6mr_update_thresholds(struct mfc6_cache *cache, unsigned char *ttl
 {
        int vifi;
 
-       cache->mfc_un.res.minvif = MAXVIFS;
+       cache->mfc_un.res.minvif = MAXMIFS;
        cache->mfc_un.res.maxvif = 0;
-       memset(cache->mfc_un.res.ttls, 255, MAXVIFS);
+       memset(cache->mfc_un.res.ttls, 255, MAXMIFS);
 
        for (vifi = 0; vifi < maxvif; vifi++) {
                if (MIF_EXISTS(vifi) && ttls[vifi] && ttls[vifi] < 255) {
@@ -700,7 +678,7 @@ static struct mfc6_cache *ip6mr_cache_alloc(void)
        if (c == NULL)
                return NULL;
        memset(c, 0, sizeof(*c));
-       c->mfc_un.res.minvif = MAXVIFS;
+       c->mfc_un.res.minvif = MAXMIFS;
        return c;
 }
 
@@ -753,7 +731,7 @@ static void ip6mr_cache_resolve(struct mfc6_cache *uc, struct mfc6_cache *c)
  *     Called under mrt_lock.
  */
 
-static int ip6mr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
+static int ip6mr_cache_report(struct sk_buff *pkt, mifi_t mifi, int assert)
 {
        struct sk_buff *skb;
        struct mrt6msg *msg;
@@ -815,7 +793,7 @@ static int ip6mr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
 
        msg->im6_mbz = 0;
        msg->im6_msgtype = assert;
-       msg->im6_mif = vifi;
+       msg->im6_mif = mifi;
        msg->im6_pad = 0;
        ipv6_addr_copy(&msg->im6_src, &ipv6_hdr(pkt)->saddr);
        ipv6_addr_copy(&msg->im6_dst, &ipv6_hdr(pkt)->daddr);
@@ -848,7 +826,7 @@ static int ip6mr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
  */
 
 static int
-ip6mr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
+ip6mr_cache_unresolved(mifi_t mifi, struct sk_buff *skb)
 {
        int err;
        struct mfc6_cache *c;
@@ -883,7 +861,7 @@ ip6mr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
                /*
                 *      Reflect first query at pim6sd
                 */
-               if ((err = ip6mr_cache_report(skb, vifi, MRT6MSG_NOCACHE)) < 0) {
+               if ((err = ip6mr_cache_report(skb, mifi, MRT6MSG_NOCACHE)) < 0) {
                        /* If the report failed throw the cache entry
                           out - Brad Parker
                         */
@@ -992,11 +970,11 @@ static int ip6mr_mfc_add(struct mf6cctl *mfc, int mrtsock)
 {
        int line;
        struct mfc6_cache *uc, *c, **cp;
-       unsigned char ttls[MAXVIFS];
+       unsigned char ttls[MAXMIFS];
        int i;
 
-       memset(ttls, 255, MAXVIFS);
-       for (i = 0; i < MAXVIFS; i++) {
+       memset(ttls, 255, MAXMIFS);
+       for (i = 0; i < MAXMIFS; i++) {
                if (IF_ISSET(i, &mfc->mf6cc_ifset))
                        ttls[i] = 1;
 
@@ -1188,7 +1166,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
                        return -EINVAL;
                if (copy_from_user(&vif, optval, sizeof(vif)))
                        return -EFAULT;
-               if (vif.mif6c_mifi >= MAXVIFS)
+               if (vif.mif6c_mifi >= MAXMIFS)
                        return -ENFILE;
                rtnl_lock();
                ret = mif6_add(&vif, sk == mroute6_socket);
@@ -1238,7 +1216,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
 #ifdef CONFIG_IPV6_PIMSM_V2
        case MRT6_PIM:
        {
-               int v, ret;
+               int v;
                if (get_user(v, (int __user *)optval))
                        return -EFAULT;
                v = !!v;
@@ -1262,7 +1240,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
 
 #endif
        /*
-        *      Spurious command, or MRT_VERSION which you cannot
+        *      Spurious command, or MRT6_VERSION which you cannot
         *      set.
         */
        default:
@@ -1368,7 +1346,7 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
 
 static inline int ip6mr_forward2_finish(struct sk_buff *skb)
 {
-       /* XXX stats */
+       IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
        return dst_output(skb);
 }
 
@@ -1391,8 +1369,8 @@ static int ip6mr_forward2(struct sk_buff *skb, struct mfc6_cache *c, int vifi)
        if (vif->flags & MIFF_REGISTER) {
                vif->pkt_out++;
                vif->bytes_out += skb->len;
-               ((struct net_device_stats *)netdev_priv(vif->dev))->tx_bytes += skb->len;
-               ((struct net_device_stats *)netdev_priv(vif->dev))->tx_packets++;
+               vif->dev->stats.tx_bytes += skb->len;
+               vif->dev->stats.tx_packets++;
                ip6mr_cache_report(skb, vifi, MRT6MSG_WHOLEPKT);
                kfree_skb(skb);
                return 0;