]> err.no Git - linux-2.6/blobdiff - net/ipv6/ip6_tunnel.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[linux-2.6] / net / ipv6 / ip6_tunnel.c
index 7d2aa6e772acef982f0d39a6d4067f53438850c5..17c7b098cdb0cc61021db7d080e0414536c48d3c 100644 (file)
@@ -6,8 +6,6 @@
  *     Ville Nuorvala          <vnuorval@tcs.hut.fi>
  *     Yasuyuki Kozakai        <kozakai@linux-ipv6.org>
  *
- *     $Id$
- *
  *      Based on:
  *      linux/net/ipv6/sit.c and linux/net/ipv4/ipip.c
  *
@@ -243,6 +241,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
        if (dev == NULL)
                goto failed;
 
+       dev_net_set(dev, net);
+
        if (strchr(name, '%')) {
                if (dev_alloc_name(dev, name) < 0)
                        goto failed_free;
@@ -543,7 +543,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        fl.fl4_dst = eiph->saddr;
        fl.fl4_tos = RT_TOS(eiph->tos);
        fl.proto = IPPROTO_IPIP;
-       if (ip_route_output_key(&init_net, &rt, &fl))
+       if (ip_route_output_key(dev_net(skb->dev), &rt, &fl))
                goto out;
 
        skb2->dev = rt->u.dst.dev;
@@ -555,7 +555,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                fl.fl4_dst = eiph->daddr;
                fl.fl4_src = eiph->saddr;
                fl.fl4_tos = eiph->tos;
-               if (ip_route_output_key(&init_net, &rt, &fl) ||
+               if (ip_route_output_key(dev_net(skb->dev), &rt, &fl) ||
                    rt->u.dst.dev->type != ARPHRD_TUNNEL) {
                        ip_rt_put(rt);
                        goto out;
@@ -612,7 +612,8 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                skb_reset_network_header(skb2);
 
                /* Try to guess incoming interface */
-               rt = rt6_lookup(&init_net, &ipv6_hdr(skb2)->saddr, NULL, 0, 0);
+               rt = rt6_lookup(dev_net(skb->dev), &ipv6_hdr(skb2)->saddr,
+                               NULL, 0, 0);
 
                if (rt && rt->rt6i_dev)
                        skb2->dev = rt->rt6i_dev;
@@ -656,16 +657,17 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
 {
        struct ip6_tnl_parm *p = &t->parms;
        int ret = 0;
+       struct net *net = dev_net(t->dev);
 
        if (p->flags & IP6_TNL_F_CAP_RCV) {
                struct net_device *ldev = NULL;
 
                if (p->link)
-                       ldev = dev_get_by_index(&init_net, p->link);
+                       ldev = dev_get_by_index(net, p->link);
 
                if ((ipv6_addr_is_multicast(&p->laddr) ||
-                    likely(ipv6_chk_addr(&init_net, &p->laddr, ldev, 0))) &&
-                   likely(!ipv6_chk_addr(&init_net, &p->raddr, NULL, 0)))
+                    likely(ipv6_chk_addr(net, &p->laddr, ldev, 0))) &&
+                   likely(!ipv6_chk_addr(net, &p->raddr, NULL, 0)))
                        ret = 1;
 
                if (ldev)
@@ -707,7 +709,7 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
                }
 
                if (!ip6_tnl_rcv_ctl(t)) {
-                       t->stat.rx_dropped++;
+                       t->dev->stats.rx_dropped++;
                        read_unlock(&ip6_tnl_lock);
                        goto discard;
                }
@@ -724,8 +726,8 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
 
                dscp_ecn_decapsulate(t, ipv6h, skb);
 
-               t->stat.rx_packets++;
-               t->stat.rx_bytes += skb->len;
+               t->dev->stats.rx_packets++;
+               t->dev->stats.rx_bytes += skb->len;
                netif_rx(skb);
                read_unlock(&ip6_tnl_lock);
                return 0;
@@ -793,19 +795,20 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
 {
        struct ip6_tnl_parm *p = &t->parms;
        int ret = 0;
+       struct net *net = dev_net(t->dev);
 
        if (p->flags & IP6_TNL_F_CAP_XMIT) {
                struct net_device *ldev = NULL;
 
                if (p->link)
-                       ldev = dev_get_by_index(&init_net, p->link);
+                       ldev = dev_get_by_index(net, p->link);
 
-               if (unlikely(!ipv6_chk_addr(&init_net, &p->laddr, ldev, 0)))
+               if (unlikely(!ipv6_chk_addr(net, &p->laddr, ldev, 0)))
                        printk(KERN_WARNING
                               "%s xmit: Local address not yet configured!\n",
                               p->name);
                else if (!ipv6_addr_is_multicast(&p->raddr) &&
-                        unlikely(ipv6_chk_addr(&init_net, &p->raddr, NULL, 0)))
+                        unlikely(ipv6_chk_addr(net, &p->raddr, NULL, 0)))
                        printk(KERN_WARNING
                               "%s xmit: Routing loop! "
                               "Remote address found on this node!\n",
@@ -844,7 +847,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
                         __u32 *pmtu)
 {
        struct ip6_tnl *t = netdev_priv(dev);
-       struct net_device_stats *stats = &t->stat;
+       struct net_device_stats *stats = &t->dev->stats;
        struct ipv6hdr *ipv6h = ipv6_hdr(skb);
        struct ipv6_tel_txoption opt;
        struct dst_entry *dst;
@@ -858,7 +861,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
        if ((dst = ip6_tnl_dst_check(t)) != NULL)
                dst_hold(dst);
        else {
-               dst = ip6_route_output(&init_net, NULL, fl);
+               dst = ip6_route_output(dev_net(dev), NULL, fl);
 
                if (dst->error || xfrm_lookup(&dst, fl, NULL, 0) < 0)
                        goto tx_err_link_failure;
@@ -1038,11 +1041,11 @@ static int
 ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
-       struct net_device_stats *stats = &t->stat;
+       struct net_device_stats *stats = &t->dev->stats;
        int ret;
 
        if (t->recursion++) {
-               t->stat.collisions++;
+               stats->collisions++;
                goto tx_err;
        }
 
@@ -1123,7 +1126,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
                int strict = (ipv6_addr_type(&p->raddr) &
                              (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
 
-               struct rt6_info *rt = rt6_lookup(&init_net, &p->raddr, &p->laddr,
+               struct rt6_info *rt = rt6_lookup(dev_net(dev),
+                                                &p->raddr, &p->laddr,
                                                 p->link, strict);
 
                if (rt == NULL)
@@ -1282,19 +1286,6 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return err;
 }
 
-/**
- * ip6_tnl_get_stats - return the stats for tunnel device
- *   @dev: virtual device associated with tunnel
- *
- * Return: stats for device
- **/
-
-static struct net_device_stats *
-ip6_tnl_get_stats(struct net_device *dev)
-{
-       return &(((struct ip6_tnl *)netdev_priv(dev))->stat);
-}
-
 /**
  * ip6_tnl_change_mtu - change mtu manually for tunnel device
  *   @dev: virtual device associated with tunnel
@@ -1328,7 +1319,6 @@ static void ip6_tnl_dev_setup(struct net_device *dev)
        dev->uninit = ip6_tnl_dev_uninit;
        dev->destructor = free_netdev;
        dev->hard_start_xmit = ip6_tnl_xmit;
-       dev->get_stats = ip6_tnl_get_stats;
        dev->do_ioctl = ip6_tnl_ioctl;
        dev->change_mtu = ip6_tnl_change_mtu;
 
@@ -1337,6 +1327,7 @@ static void ip6_tnl_dev_setup(struct net_device *dev)
        dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr);
        dev->flags |= IFF_NOARP;
        dev->addr_len = sizeof(struct in6_addr);
+       dev->features |= NETIF_F_NETNS_LOCAL;
 }