[NETFILTER]: nf_conntrack: replace NF_CT_DUMP_TUPLE macro indrection by function...
[h-e-n] / net / ipv6 / raw.c
index 12c7a15..6193b12 100644 (file)
@@ -53,6 +53,7 @@
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
 #include <net/mip6.h>
 #endif
+#include <linux/mroute6.h>
 
 #include <net/raw.h>
 #include <net/rawv6.h>
@@ -76,7 +77,7 @@ static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
                if (inet_sk(sk)->num == num) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
 
-                       if (sock_net(sk) != net)
+                       if (!net_eq(sock_net(sk), net))
                                continue;
 
                        if (!ipv6_addr_any(&np->daddr) &&
@@ -168,11 +169,6 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
        read_lock(&raw_v6_hashinfo.lock);
        sk = sk_head(&raw_v6_hashinfo.ht[hash]);
 
-       /*
-        *      The first socket found will be delivered after
-        *      delivery to transport protocols.
-        */
-
        if (sk == NULL)
                goto out;
 
@@ -361,8 +357,10 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
        read_lock(&raw_v6_hashinfo.lock);
        sk = sk_head(&raw_v6_hashinfo.ht[hash]);
        if (sk != NULL) {
-               saddr = &ipv6_hdr(skb)->saddr;
-               daddr = &ipv6_hdr(skb)->daddr;
+               /* Note: ipv6_hdr(skb) != skb->data */
+               struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data;
+               saddr = &ip6h->saddr;
+               daddr = &ip6h->daddr;
                net = dev_net(skb->dev);
 
                while ((sk = __raw_v6_lookup(net, sk, nexthdr, saddr, daddr,
@@ -809,15 +807,6 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                fl.fl6_flowlabel = np->flow_label;
        }
 
-       if (ipv6_addr_any(daddr)) {
-               /*
-                * unspecified destination address
-                * treated as error... is this correct ?
-                */
-               fl6_sock_release(flowlabel);
-               return(-EINVAL);
-       }
-
        if (fl.oif == 0)
                fl.oif = sk->sk_bound_dev_if;
 
@@ -850,7 +839,10 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        if (err)
                goto out;
 
-       ipv6_addr_copy(&fl.fl6_dst, daddr);
+       if (!ipv6_addr_any(daddr))
+               ipv6_addr_copy(&fl.fl6_dst, daddr);
+       else
+               fl.fl6_dst.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
        if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
 
@@ -1140,7 +1132,11 @@ static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg)
                }
 
                default:
+#ifdef CONFIG_IPV6_MROUTE
+                       return ip6mr_ioctl(sk, cmd, (void __user *)arg);
+#else
                        return -ENOIOCTLCMD;
+#endif
        }
 }
 
@@ -1148,7 +1144,7 @@ static void rawv6_close(struct sock *sk, long timeout)
 {
        if (inet_sk(sk)->num == IPPROTO_RAW)
                ip6_ra_control(sk, -1, NULL);
-
+       ip6mr_sk_done(sk);
        sk_common_release(sk);
 }
 
@@ -1171,8 +1167,6 @@ static int rawv6_init_sk(struct sock *sk)
        return(0);
 }
 
-DEFINE_PROTO_INUSE(rawv6)
-
 struct proto rawv6_prot = {
        .name              = "RAWv6",
        .owner             = THIS_MODULE,
@@ -1196,7 +1190,6 @@ struct proto rawv6_prot = {
        .compat_setsockopt = compat_rawv6_setsockopt,
        .compat_getsockopt = compat_rawv6_getsockopt,
 #endif
-       REF_PROTO_INUSE(rawv6)
 };
 
 #ifdef CONFIG_PROC_FS