tipc: make sure required IPv6 addresses are scoped
authorRichard Alpe <richard.alpe@ericsson.com>
Thu, 3 Mar 2016 13:20:43 +0000 (14:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2016 03:54:57 +0000 (22:54 -0500)
Make sure the user has provided a scope for multicast and link local
addresses used locally by a UDP bearer.

Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/udp_media.c

index 6fe8740a226fc55c2d2e5f49d19732b9e6bda75c..fb2f7ec68eef2e4106cbff5496b16cbb8acf1876 100644 (file)
@@ -310,9 +310,14 @@ err:
 
 #if IS_ENABLED(CONFIG_IPV6)
        } else if ((sa_local.ss_family & sa_remote.ss_family) == AF_INET6) {
+               int atype;
                struct sockaddr_in6 *ip6;
 
                ip6 = (struct sockaddr_in6 *)&sa_local;
+               atype = ipv6_addr_type(&ip6->sin6_addr);
+               if (__ipv6_addr_needs_scope_id(atype) && !ip6->sin6_scope_id)
+                       return -EINVAL;
+
                local->proto = htons(ETH_P_IPV6);
                local->udp_port = ip6->sin6_port;
                memcpy(&local->ipv6, &ip6->sin6_addr, sizeof(struct in6_addr));
This page took 0.026091 seconds and 5 git commands to generate.