net: IP_MULTICAST_IF setsockopt now recognizes struct mreq
authorJiri Pirko <jpirko@redhat.com>
Thu, 3 May 2012 22:37:45 +0000 (22:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 May 2012 03:03:22 +0000 (23:03 -0400)
Until now, struct mreq has not been recognized and it was worked with
as with struct in_addr. That means imr_multiaddr was copied to
imr_address. So do recognize struct mreq here and copy that correctly.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_sockglue.c

index 51c6c672c8aa62dfc51e15bbfdb86d4f73066ca2..0d11f234d615aa8443e5ce071c3071246ce15487 100644 (file)
@@ -673,10 +673,15 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                                break;
                } else {
                        memset(&mreq, 0, sizeof(mreq));
-                       if (optlen >= sizeof(struct in_addr) &&
-                           copy_from_user(&mreq.imr_address, optval,
-                                          sizeof(struct in_addr)))
-                               break;
+                       if (optlen >= sizeof(struct ip_mreq)) {
+                               if (copy_from_user(&mreq, optval,
+                                                  sizeof(struct ip_mreq)))
+                                       break;
+                       } else if (optlen >= sizeof(struct in_addr)) {
+                               if (copy_from_user(&mreq.imr_address, optval,
+                                                  sizeof(struct in_addr)))
+                                       break;
+                       }
                }
 
                if (!mreq.imr_ifindex) {