Revert "tcp: disallow bind() to reuse addr/port"

This reverts commit c191a836a908d1dd6b40c503741f91b914de3348.

It causes known regressions for programs that expect to be able to use
SO_REUSEADDR to shutdown a socket, then successfully rebind another
socket to the same ID.

Programs such as haproxy and amavisd expect this to work.

This should fix kernel bugzilla 32832.

Signed-off-by: David S. Miller <davem@davemloft.net>

+3 -4
+2 -3
net/ipv4/inet_connection_sock.c
··· 73 73 !sk2->sk_bound_dev_if || 74 74 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) { 75 75 if (!reuse || !sk2->sk_reuse || 76 - ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) { 76 + sk2->sk_state == TCP_LISTEN) { 77 77 const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2); 78 78 if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) || 79 79 sk2_rcv_saddr == sk_rcv_saddr(sk)) ··· 122 122 (tb->num_owners < smallest_size || smallest_size == -1)) { 123 123 smallest_size = tb->num_owners; 124 124 smallest_rover = rover; 125 - if (atomic_read(&hashinfo->bsockets) > (high - low) + 1 && 126 - !inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) { 125 + if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) { 127 126 spin_unlock(&head->lock); 128 127 snum = smallest_rover; 129 128 goto have_snum;
+1 -1
net/ipv6/inet6_connection_sock.c
··· 44 44 !sk2->sk_bound_dev_if || 45 45 sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && 46 46 (!sk->sk_reuse || !sk2->sk_reuse || 47 - ((1 << sk2->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))) && 47 + sk2->sk_state == TCP_LISTEN) && 48 48 ipv6_rcv_saddr_equal(sk, sk2)) 49 49 break; 50 50 }