summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Vigor <kvigor@fb.com>2016-12-15 13:41:14 -0800
committerVijay Bellur <vbellur@redhat.com>2017-03-12 11:28:45 -0400
commiteac6dfc314abe4dc50c54bf6c6cc004dfd73d5ac (patch)
tree1e412015264da4ec678924e7b0e76b1d5dce7d05
parentb3ac24cdd759fb4cd2946329860bcc004f736b23 (diff)
transport: allow OS to assign us a port
Replace complex and slow port selection code with bind(0) which already respects privileged ports. Change-Id: I408a8528e58e1aafcd32eba6a8f1a759e0bf274e BUG: 1405628 Reviewed-on-release-3.8-fb: http://review.gluster.org/16150 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: https://review.gluster.org/16178 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--configure.ac11
-rw-r--r--rpc/rpc-transport/rdma/src/name.c5
-rw-r--r--rpc/rpc-transport/socket/src/name.c5
3 files changed, 21 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 28ff3e5a3f4..3d796a01128 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,6 +301,16 @@ else
CFLAGS="${CFLAGS} -g -O2"
fi
+AC_ARG_ENABLE([privport_tracking],
+ AC_HELP_STRING([--disable-privport_tracking],
+ [Disable internal tracking of privileged ports.]))
+TRACK_PRIVPORTS="yes"
+if test x"$enable_privport_tracking" = x"no"; then
+ TRACK_PRIVPORTS="no"
+ AC_DEFINE(GF_DISABLE_PRIVPORT_TRACKING, 1,
+ [Disable internal tracking of privileged ports.])
+fi
+
case $host_os in
darwin*)
if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 7; then
@@ -1544,6 +1554,7 @@ echo "Use syslog : $USE_SYSLOG"
echo "XML output : $BUILD_XML_OUTPUT"
echo "Encryption xlator : $BUILD_CRYPT_XLATOR"
echo "Unit Tests : $BUILD_UNITTEST"
+echo "Track priv ports : $TRACK_PRIVPORTS"
echo "POSIX ACLs : $BUILD_POSIX_ACLS"
echo "Data Classification : $BUILD_GFDB"
echo "firewalld-config : $BUILD_FIREWALLD"
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c
index 5064427e01e..be7490abac1 100644
--- a/rpc/rpc-transport/rdma/src/name.c
+++ b/rpc/rpc-transport/rdma/src/name.c
@@ -54,6 +54,10 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id,
struct sockaddr *sockaddr,
socklen_t sockaddr_len, uint32_t ceiling)
{
+#if GF_DISABLE_PRIVPORT_TRACKING
+ _assign_port (sockaddr, 0);
+ return rdma_bind_addr (cm_id, sockaddr);
+#else
int32_t ret = -1;
uint16_t port = ceiling - 1;
unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,};
@@ -100,6 +104,7 @@ loop:
}
return ret;
+#endif /* GF_DISABLE_PRIVPORT_TRACKING */
}
#if 0
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
index acd1dc7b55e..e9de1a78813 100644
--- a/rpc/rpc-transport/socket/src/name.c
+++ b/rpc/rpc-transport/socket/src/name.c
@@ -42,6 +42,10 @@ static int32_t
af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr,
socklen_t sockaddr_len, uint32_t ceiling)
{
+#if GF_DISABLE_PRIVPORT_TRACKING
+ _assign_port (sockaddr, 0);
+ return bind (fd, sockaddr, sockaddr_len);
+#else
int32_t ret = -1;
uint16_t port = ceiling - 1;
unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,};
@@ -88,6 +92,7 @@ loop:
}
return ret;
+#endif /* GF_DISABLE_PRIVPORT_TRACKING */
}
static int32_t