]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - net/ipv6/raw.c
Merge tag 'v3.16-rc1' into i2c/for-next
[karo-tx-linux.git] / net / ipv6 / raw.c
index b6bb87e55805873ec3244db9586f58b14700835d..b2dc60b0c76403d38a6a96c8a1c299977ecb7bad 100644 (file)
@@ -250,6 +250,10 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 
        if (addr_len < SIN6_LEN_RFC2133)
                return -EINVAL;
+
+       if (addr->sin6_family != AF_INET6)
+               return -EINVAL;
+
        addr_type = ipv6_addr_type(&addr->sin6_addr);
 
        /* Raw sockets are IPv6 only */
@@ -457,7 +461,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
                  int noblock, int flags, int *addr_len)
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
-       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name;
+       DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name);
        struct sk_buff *skb;
        size_t copied;
        int err;
@@ -734,7 +738,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                   struct msghdr *msg, size_t len)
 {
        struct ipv6_txoptions opt_space;
-       struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
+       DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name);
        struct in6_addr *daddr, *final_p, final;
        struct inet_sock *inet = inet_sk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -864,19 +868,13 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                fl6.flowi6_oif = np->ucast_oif;
        security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
 
-       dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
+       dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
        if (IS_ERR(dst)) {
                err = PTR_ERR(dst);
                goto out;
        }
-       if (hlimit < 0) {
-               if (ipv6_addr_is_multicast(&fl6.daddr))
-                       hlimit = np->mcast_hops;
-               else
-                       hlimit = np->hop_limit;
-               if (hlimit < 0)
-                       hlimit = ip6_dst_hoplimit(dst);
-       }
+       if (hlimit < 0)
+               hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
 
        if (tclass < 0)
                tclass = np->tclass;
@@ -1209,7 +1207,7 @@ struct proto rawv6_prot = {
        .owner             = THIS_MODULE,
        .close             = rawv6_close,
        .destroy           = raw6_destroy,
-       .connect           = ip6_datagram_connect,
+       .connect           = ip6_datagram_connect_v6_only,
        .disconnect        = udp_disconnect,
        .ioctl             = rawv6_ioctl,
        .init              = rawv6_init_sk,
@@ -1324,7 +1322,6 @@ static struct inet_protosw rawv6_protosw = {
        .protocol       = IPPROTO_IP,   /* wild card */
        .prot           = &rawv6_prot,
        .ops            = &inet6_sockraw_ops,
-       .no_check       = UDP_CSUM_DEFAULT,
        .flags          = INET_PROTOSW_REUSE,
 };