diff options
author | Tom Herbert <tom@herbertland.com> | 2016-12-15 01:54:16 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-17 17:13:19 +0100 |
commit | 0643ee4fd1b79c1af3bd7bc8968dbf5fd047f490 (patch) | |
tree | ddae48385faf13e6537d82b1f72cff8553456a9a /include/net/inet6_connection_sock.h | |
parent | inet: Don't go into port scan when looking for specific bind port (diff) | |
download | linux-0643ee4fd1b79c1af3bd7bc8968dbf5fd047f490.tar.xz linux-0643ee4fd1b79c1af3bd7bc8968dbf5fd047f490.zip |
inet: Fix get port to handle zero port number with soreuseport set
A user may call listen with binding an explicit port with the intent
that the kernel will assign an available port to the socket. In this
case inet_csk_get_port does a port scan. For such sockets, the user may
also set soreuseport with the intent a creating more sockets for the
port that is selected. The problem is that the initial socket being
opened could inadvertently choose an existing and unreleated port
number that was already created with soreuseport.
This patch adds a boolean parameter to inet_bind_conflict that indicates
rather soreuseport is allowed for the check (in addition to
sk->sk_reuseport). In calls to inet_bind_conflict from inet_csk_get_port
the argument is set to true if an explicit port is being looked up (snum
argument is nonzero), and is false if port scan is done.
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet6_connection_sock.h')
-rw-r--r-- | include/net/inet6_connection_sock.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h index 954ad6bfb56a..3212b39b5bfc 100644 --- a/include/net/inet6_connection_sock.h +++ b/include/net/inet6_connection_sock.h @@ -22,7 +22,8 @@ struct sock; struct sockaddr; int inet6_csk_bind_conflict(const struct sock *sk, - const struct inet_bind_bucket *tb, bool relax); + const struct inet_bind_bucket *tb, bool relax, + bool soreuseport_ok); struct dst_entry *inet6_csk_route_req(const struct sock *sk, struct flowi6 *fl6, const struct request_sock *req, u8 proto); |