[IPv6] RAW: Compact the API for the kernel
[safe/jmp/linux-2.6] / net / ipv6 / datagram.c
index 4a355fe..5d4245a 100644 (file)
@@ -123,11 +123,11 @@ ipv4_connected:
                                goto out;
                        }
                        sk->sk_bound_dev_if = usin->sin6_scope_id;
-                       if (!sk->sk_bound_dev_if &&
-                           (addr_type & IPV6_ADDR_MULTICAST))
-                               fl.oif = np->mcast_oif;
                }
 
+               if (!sk->sk_bound_dev_if && (addr_type & IPV6_ADDR_MULTICAST))
+                       sk->sk_bound_dev_if = np->mcast_oif;
+
                /* Connect to link-local address requires an interface */
                if (!sk->sk_bound_dev_if) {
                        err = -EINVAL;
@@ -177,8 +177,12 @@ ipv4_connected:
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
-               goto out;
+       if ((err = __xfrm_lookup(&dst, &fl, sk, 1)) < 0) {
+               if (err == -EREMOTE)
+                       err = ip6_dst_blackhole(sk, &dst, &fl);
+               if (err < 0)
+                       goto out;
+       }
 
        /* source address lookup done in ip6_dst_lookup */
 
@@ -540,7 +544,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                                if (!src_info->ipi6_ifindex)
                                        return -EINVAL;
                                else {
-                                       dev = dev_get_by_index(src_info->ipi6_ifindex);
+                                       dev = dev_get_by_index(&init_net, src_info->ipi6_ifindex);
                                        if (!dev)
                                                return -ENODEV;
                                }
@@ -653,11 +657,10 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        rthdr = (struct ipv6_rt_hdr *)CMSG_DATA(cmsg);
 
                        switch (rthdr->type) {
-                       case IPV6_SRCRT_TYPE_0:
-#ifdef CONFIG_IPV6_MIP6
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
                        case IPV6_SRCRT_TYPE_2:
-#endif
                                break;
+#endif
                        default:
                                err = -EINVAL;
                                goto exit_f;
@@ -723,7 +726,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                                       cmsg->cmsg_type);
                        err = -EINVAL;
                        break;
-               };
+               }
        }
 
 exit_f: