From: David S. Miller Date: Wed, 8 Oct 2003 01:33:00 +0000 (-0700) Subject: [UDP/TCP]: Fix binding conflict tests wrt. SO_BINDTODEVICE. X-Git-Tag: v2.6.0-test7~3^2~9 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=4044a3f8f3b8deecc1b6b7e7750100fcaf010e52;p=history.git [UDP/TCP]: Fix binding conflict tests wrt. SO_BINDTODEVICE. --- diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 4529c0f2c823..67ec90ce3d05 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -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) { if (sk != 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 || sk2->sk_state == TCP_LISTEN) { struct inet_opt *inet2 = inet_sk(sk2); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 2762e0548761..c0e4710a18c2 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -176,7 +176,9 @@ gotit: if (inet2->num == snum && sk2 != sk && !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 || !inet->rcv_saddr || inet2->rcv_saddr == inet->rcv_saddr) && diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index fc1b3e8837d9..0e1ca9018f8c 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -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 */ 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 || sk2->sk_state == TCP_LISTEN) && ipv6_rcv_saddr_equal(sk, sk2)) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 2ee6d5e55734..87f282f2f9cf 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -112,7 +112,9 @@ gotit: &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]) { if (inet_sk(sk2)->num == snum && 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) && ipv6_rcv_saddr_equal(sk, sk2)) goto fail;