summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2021-11-10 13:57:58 -0500
committerSteve Dickson <steved@redhat.com>2021-11-10 13:58:33 -0500
commitf054365d7f8e69b103edca2fbcd8bfa3b1cd6a14 (patch)
tree1196639eb9c7938a50d4e5b4a0039f01c5575f92 /utils
parent49822c2130a2a6e1d5a9e414f5a0726a461d9b00 (diff)
downloadnfs-utils-f054365d7f8e69b103edca2fbcd8bfa3b1cd6a14.tar.gz
mount: don't bind a socket needlessly.nfs-utils-2-5-5-rc4
When clnt_ping() calls get_socket(), get_socket() will create a socket, call bind() to choose an unused local port, and then connect to the given address. The "bind()" call is unnecessary and problematic. It is unnecessary as the "connect()" call will bind the socket as required. It is problematic as it requires a completely unused port number, rather than just a port number which isn't currently in use for connecting to the given remote address. If all local ports (net.ipv4.ip_local_port_range) are in use, the bind() will fail. However the connect() call will only fail if all those port are in use for connecting to the same address. So remove the unnecessary bind() call. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/mount/network.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/utils/mount/network.c b/utils/mount/network.c
index e803dbb..3526117 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -429,10 +429,6 @@ static int get_socket(struct sockaddr_in *saddr, unsigned int p_prot,
if (resvp) {
if (bindresvport(so, &laddr) < 0)
goto err_bindresvport;
- } else {
- cc = bind(so, SAFE_SOCKADDR(&laddr), namelen);
- if (cc < 0)
- goto err_bind;
}
if (type == SOCK_STREAM || (conn && type == SOCK_DGRAM)) {
cc = connect_to(so, SAFE_SOCKADDR(saddr), namelen,