aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/udp.c
diff options
context:
space:
mode:
authorVlad Yasevich <vladislav.yasevich@hp.com>2009-03-24 12:24:51 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-24 22:49:11 -0400
commitb2f5e7cd3dee2ed721bf0675e1a1ddebb849aee6 (patch)
treea7b48c260a3cb0050ad6198c6a50b52b318dfcb8 /net/ipv6/udp.c
parent63d9950b08184e6531adceb65f64b429909cc101 (diff)
ipv6: Fix conflict resolutions during ipv6 binding
The ipv6 version of bind_conflict code calls ipv6_rcv_saddr_equal() which at times wrongly identified intersections between addresses. It particularly broke down under a few instances and caused erroneous bind conflicts. Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r--net/ipv6/udp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 84b1a296eecb..6842dd2edd5b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -49,6 +49,34 @@
49#include <linux/seq_file.h> 49#include <linux/seq_file.h>
50#include "udp_impl.h" 50#include "udp_impl.h"
51 51
52int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
53{
54 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
55 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
56 int sk_ipv6only = ipv6_only_sock(sk);
57 int sk2_ipv6only = inet_v6_ipv6only(sk2);
58 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
59 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
60
61 /* if both are mapped, treat as IPv4 */
62 if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
63 return ipv4_rcv_saddr_equal(sk, sk2);
64
65 if (addr_type2 == IPV6_ADDR_ANY &&
66 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
67 return 1;
68
69 if (addr_type == IPV6_ADDR_ANY &&
70 !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
71 return 1;
72
73 if (sk2_rcv_saddr6 &&
74 ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
75 return 1;
76
77 return 0;
78}
79
52int udp_v6_get_port(struct sock *sk, unsigned short snum) 80int udp_v6_get_port(struct sock *sk, unsigned short snum)
53{ 81{
54 return udp_lib_get_port(sk, snum, ipv6_rcv_saddr_equal); 82 return udp_lib_get_port(sk, snum, ipv6_rcv_saddr_equal);