aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/af_inet6.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/af_inet6.c')
-rw-r--r--net/ipv6/af_inet6.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 9b6a37d16fb0..61f55386a236 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -276,6 +276,8 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
276 276
277 /* Check if the address belongs to the host. */ 277 /* Check if the address belongs to the host. */
278 if (addr_type == IPV6_ADDR_MAPPED) { 278 if (addr_type == IPV6_ADDR_MAPPED) {
279 int chk_addr_ret;
280
279 /* Binding to v4-mapped address on a v6-only socket 281 /* Binding to v4-mapped address on a v6-only socket
280 * makes no sense 282 * makes no sense
281 */ 283 */
@@ -283,11 +285,17 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
283 err = -EINVAL; 285 err = -EINVAL;
284 goto out; 286 goto out;
285 } 287 }
288
289 /* Reproduce AF_INET checks to make the bindings consitant */
286 v4addr = addr->sin6_addr.s6_addr32[3]; 290 v4addr = addr->sin6_addr.s6_addr32[3];
287 if (inet_addr_type(net, v4addr) != RTN_LOCAL) { 291 chk_addr_ret = inet_addr_type(net, v4addr);
288 err = -EADDRNOTAVAIL; 292 if (!sysctl_ip_nonlocal_bind &&
293 !(inet->freebind || inet->transparent) &&
294 v4addr != htonl(INADDR_ANY) &&
295 chk_addr_ret != RTN_LOCAL &&
296 chk_addr_ret != RTN_MULTICAST &&
297 chk_addr_ret != RTN_BROADCAST)
289 goto out; 298 goto out;
290 }
291 } else { 299 } else {
292 if (addr_type != IPV6_ADDR_ANY) { 300 if (addr_type != IPV6_ADDR_ANY) {
293 struct net_device *dev = NULL; 301 struct net_device *dev = NULL;