summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-transport
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 /rpc/rpc-transport
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>
Diffstat (limited to 'rpc/rpc-transport')
-rw-r--r--rpc/rpc-transport/rdma/src/name.c5
-rw-r--r--rpc/rpc-transport/socket/src/name.c5
2 files changed, 10 insertions, 0 deletions
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