[NETNS][IPV6] route6 - Pass the network namespace parameter to rt6_lookup
[deliverable/linux.git] / net / ipv6 / sit.c
index 1c6fddb80b37ba72c4be0ba3c48de9eea667d94d..68720aa63f962f5899865d37453e12f7e60a11b8 100644 (file)
@@ -164,21 +164,18 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
 
        if (parms->name[0])
                strlcpy(name, parms->name, IFNAMSIZ);
-       else {
-               int i;
-               for (i=1; i<100; i++) {
-                       sprintf(name, "sit%d", i);
-                       if (__dev_get_by_name(&init_net, name) == NULL)
-                               break;
-               }
-               if (i==100)
-                       goto failed;
-       }
+       else
+               sprintf(name, "sit%%d");
 
        dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);
        if (dev == NULL)
                return NULL;
 
+       if (strchr(name, '%')) {
+               if (dev_alloc_name(dev, name) < 0)
+                       goto failed_free;
+       }
+
        nt = netdev_priv(dev);
        dev->init = ipip6_tunnel_init;
        nt->parms = *parms;
@@ -186,16 +183,16 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
        if (parms->i_flags & SIT_ISATAP)
                dev->priv_flags |= IFF_ISATAP;
 
-       if (register_netdevice(dev) < 0) {
-               free_netdev(dev);
-               goto failed;
-       }
+       if (register_netdevice(dev) < 0)
+               goto failed_free;
 
        dev_hold(dev);
 
        ipip6_tunnel_link(nt);
        return nt;
 
+failed_free:
+       free_netdev(dev);
 failed:
        return NULL;
 }
@@ -342,11 +339,11 @@ out:
        skb_reset_network_header(skb2);
 
        /* Try to guess incoming interface */
-       rt6i = rt6_lookup(&iph6->saddr, NULL, NULL, 0);
+       rt6i = rt6_lookup(&init_net, &iph6->saddr, NULL, NULL, 0);
        if (rt6i && rt6i->rt6i_dev) {
                skb2->dev = rt6i->rt6i_dev;
 
-               rt6i = rt6_lookup(&iph6->daddr, &iph6->saddr, NULL, 0);
+               rt6i = rt6_lookup(&init_net, &iph6->daddr, &iph6->saddr, NULL, 0);
 
                if (rt6i && rt6i->rt6i_dev && rt6i->rt6i_dev->type == ARPHRD_SIT) {
                        struct ip_tunnel *t = netdev_priv(rt6i->rt6i_dev);
@@ -557,7 +554,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                                                .tos = RT_TOS(tos) } },
                                    .oif = tunnel->parms.link,
                                    .proto = IPPROTO_IPV6 };
-               if (ip_route_output_key(&rt, &fl)) {
+               if (ip_route_output_key(&init_net, &rt, &fl)) {
                        tunnel->stat.tx_carrier_errors++;
                        goto tx_error_icmp;
                }
@@ -686,7 +683,7 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
                                    .oif = tunnel->parms.link,
                                    .proto = IPPROTO_IPV6 };
                struct rtable *rt;
-               if (!ip_route_output_key(&rt, &fl)) {
+               if (!ip_route_output_key(&init_net, &rt, &fl)) {
                        tdev = rt->u.dst.dev;
                        ip_rt_put(rt);
                }
This page took 0.082854 seconds and 5 git commands to generate.