From eac6dfc314abe4dc50c54bf6c6cc004dfd73d5ac Mon Sep 17 00:00:00 2001 From: Kevin Vigor Date: Thu, 15 Dec 2016 13:41:14 -0800 Subject: 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 Reviewed-on: https://review.gluster.org/16178 Smoke: Gluster Build System Reviewed-by: Niels de Vos NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Vijay Bellur --- rpc/rpc-transport/socket/src/name.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rpc/rpc-transport/socket') 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 -- cgit