Commit 4044a3f8 authored by David S. Miller's avatar David S. Miller

[UDP/TCP]: Fix binding conflict tests wrt. SO_BINDTODEVICE.

parent 0a58cf1a
...@@ -188,7 +188,9 @@ static inline int tcp_bind_conflict(struct sock *sk, struct tcp_bind_bucket *tb) ...@@ -188,7 +188,9 @@ static inline int tcp_bind_conflict(struct sock *sk, struct tcp_bind_bucket *tb)
sk_for_each_bound(sk2, node, &tb->owners) { sk_for_each_bound(sk2, node, &tb->owners) {
if (sk != sk2 && if (sk != sk2 &&
!ipv6_only_sock(sk2) && !ipv6_only_sock(sk2) &&
sk->sk_bound_dev_if == sk2->sk_bound_dev_if) { (!sk->sk_bound_dev_if ||
!sk2->sk_bound_dev_if ||
sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
if (!reuse || !sk2->sk_reuse || if (!reuse || !sk2->sk_reuse ||
sk2->sk_state == TCP_LISTEN) { sk2->sk_state == TCP_LISTEN) {
struct inet_opt *inet2 = inet_sk(sk2); struct inet_opt *inet2 = inet_sk(sk2);
......
...@@ -176,7 +176,9 @@ static int udp_v4_get_port(struct sock *sk, unsigned short snum) ...@@ -176,7 +176,9 @@ static int udp_v4_get_port(struct sock *sk, unsigned short snum)
if (inet2->num == snum && if (inet2->num == snum &&
sk2 != sk && sk2 != sk &&
!ipv6_only_sock(sk2) && !ipv6_only_sock(sk2) &&
sk2->sk_bound_dev_if == sk->sk_bound_dev_if && (!sk2->bound_dev_if ||
!sk->bound_dev_if ||
sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
(!inet2->rcv_saddr || (!inet2->rcv_saddr ||
!inet->rcv_saddr || !inet->rcv_saddr ||
inet2->rcv_saddr == inet->rcv_saddr) && inet2->rcv_saddr == inet->rcv_saddr) &&
......
...@@ -101,7 +101,10 @@ static inline int tcp_v6_bind_conflict(struct sock *sk, ...@@ -101,7 +101,10 @@ static inline int tcp_v6_bind_conflict(struct sock *sk,
/* We must walk the whole port owner list in this case. -DaveM */ /* We must walk the whole port owner list in this case. -DaveM */
sk_for_each_bound(sk2, node, &tb->owners) { sk_for_each_bound(sk2, node, &tb->owners) {
if (sk != sk2 && sk->sk_bound_dev_if == sk2->sk_bound_dev_if && if (sk != sk2 &&
(!sk->sk_bound_dev_if ||
!sk2->sk_bound_dev_if ||
sk->sk_bound_dev_if == sk2->sk_bound_dev_if) &&
(!sk->sk_reuse || !sk2->sk_reuse || (!sk->sk_reuse || !sk2->sk_reuse ||
sk2->sk_state == TCP_LISTEN) && sk2->sk_state == TCP_LISTEN) &&
ipv6_rcv_saddr_equal(sk, sk2)) ipv6_rcv_saddr_equal(sk, sk2))
......
...@@ -112,7 +112,9 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum) ...@@ -112,7 +112,9 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
&udp_hash[snum & (UDP_HTABLE_SIZE - 1)]) { &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]) {
if (inet_sk(sk2)->num == snum && if (inet_sk(sk2)->num == snum &&
sk2 != sk && sk2 != sk &&
sk2->sk_bound_dev_if == sk->sk_bound_dev_if && (!sk2->sk_bound_dev_if ||
!sk->sk_bound_dev_if ||
sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
(!sk2->sk_reuse || !sk->sk_reuse) && (!sk2->sk_reuse || !sk->sk_reuse) &&
ipv6_rcv_saddr_equal(sk, sk2)) ipv6_rcv_saddr_equal(sk, sk2))
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment