diff options
author | Vlad Yasevich <vladislav.yasevich@hp.com> | 2009-03-24 12:24:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-24 22:49:09 -0400 |
commit | 783ed5a78373253052bc61a3c5c8b9f17af4e3c6 (patch) | |
tree | e927af1d258187767995fc77bda8eebf5a513077 /net/ipv6/af_inet6.c | |
parent | 4097f663cbe9e58de7ebed222f8af33267f297a8 (diff) |
ipv6: Disallow binding to v4-mapped address on v6-only socket.
A socket marked v6-only, can not receive or send traffic to v4-mapped
addresses. Thus allowing binding to v4-mapped address on such a
socket makes no sense.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/af_inet6.c')
-rw-r--r-- | net/ipv6/af_inet6.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index fbf533cc9dce..7f092fa912bd 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -276,6 +276,13 @@ 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 | /* Binding to v4-mapped address on a v6-only socket | ||
280 | * makes no sense | ||
281 | */ | ||
282 | if (np->ipv6only) { | ||
283 | err = -EINVAL; | ||
284 | goto out; | ||
285 | } | ||
279 | v4addr = addr->sin6_addr.s6_addr32[3]; | 286 | v4addr = addr->sin6_addr.s6_addr32[3]; |
280 | if (inet_addr_type(net, v4addr) != RTN_LOCAL) { | 287 | if (inet_addr_type(net, v4addr) != RTN_LOCAL) { |
281 | err = -EADDRNOTAVAIL; | 288 | err = -EADDRNOTAVAIL; |