]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/ipv4/ip_sockglue.c
net: Allow IP_MULTICAST_IF to set index to L3 slave
[mirror_ubuntu-bionic-kernel.git] / net / ipv4 / ip_sockglue.c
index 8b13881ed0644c3c32e87718752f8613023c72eb..cf9b43de469024bb2e6c3fd0d1e0055dfd5d7e03 100644 (file)
@@ -44,7 +44,7 @@
 #include <net/ip_fib.h>
 
 #include <linux/errqueue.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 /*
  *     SOL_IP control messages.
@@ -148,7 +148,7 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
        const struct iphdr *iph = ip_hdr(skb);
        __be16 *ports = (__be16 *)skb_transport_header(skb);
 
-       if (skb_transport_offset(skb) + 4 > skb->len)
+       if (skb_transport_offset(skb) + 4 > (int)skb->len)
                return;
 
        /* All current transport protocols have the port numbers in the
@@ -843,6 +843,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
        {
                struct ip_mreqn mreq;
                struct net_device *dev = NULL;
+               int midx;
 
                if (sk->sk_type == SOCK_STREAM)
                        goto e_inval;
@@ -887,11 +888,15 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                err = -EADDRNOTAVAIL;
                if (!dev)
                        break;
+
+               midx = l3mdev_master_ifindex(dev);
+
                dev_put(dev);
 
                err = -EINVAL;
                if (sk->sk_bound_dev_if &&
-                   mreq.imr_ifindex != sk->sk_bound_dev_if)
+                   mreq.imr_ifindex != sk->sk_bound_dev_if &&
+                   (!midx || midx != sk->sk_bound_dev_if))
                        break;
 
                inet->mc_index = mreq.imr_ifindex;