|
|
12a457 |
From c1a7a863d784961010f07ba78531dfc24c473e16 Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
12a457 |
Date: Sat, 30 Apr 2016 14:37:40 +0530
|
|
|
12a457 |
Subject: [PATCH 120/139] rpc: fix gf_process_reserved_ports
|
|
|
12a457 |
|
|
|
12a457 |
this patch also does minor code cleanups.
|
|
|
12a457 |
|
|
|
12a457 |
Backport of:
|
|
|
12a457 |
> Backport of:
|
|
|
12a457 |
>> Change-Id: I0d005bd0f9baaaae498aa1df4faa6fcb65fa7a6e
|
|
|
12a457 |
>> BUG: 1198849
|
|
|
12a457 |
>> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
12a457 |
>> Reviewed-on: http://review.gluster.org/13997
|
|
|
12a457 |
>> Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com>
|
|
|
12a457 |
>> Smoke: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
>> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
>> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
>> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
|
|
|
12a457 |
>> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
|
|
|
12a457 |
> Change-Id: Ia53ba724f6d31cb2fc609786e31a1b676f55fe01
|
|
|
12a457 |
> BUG: 1331941
|
|
|
12a457 |
> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
12a457 |
> Reviewed-on: http://review.gluster.org/14128
|
|
|
12a457 |
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
> Tested-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
> Smoke: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
|
|
|
12a457 |
Change-Id: Ic1ad8a3fafdcec6f529a2d9c5702099c31eeaf13
|
|
|
12a457 |
BUG: 1322306
|
|
|
12a457 |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/73588
|
|
|
12a457 |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
12a457 |
---
|
|
|
12a457 |
libglusterfs/src/common-utils.c | 10 ++++++++++
|
|
|
12a457 |
rpc/rpc-transport/rdma/src/name.c | 8 +-------
|
|
|
12a457 |
rpc/rpc-transport/socket/src/name.c | 10 ++--------
|
|
|
12a457 |
3 files changed, 13 insertions(+), 15 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
|
|
|
12a457 |
index 88fe5f3..b9ada2b 100644
|
|
|
12a457 |
--- a/libglusterfs/src/common-utils.c
|
|
|
12a457 |
+++ b/libglusterfs/src/common-utils.c
|
|
|
12a457 |
@@ -2797,6 +2797,12 @@ int
|
|
|
12a457 |
gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
|
|
12a457 |
{
|
|
|
12a457 |
int ret = -1;
|
|
|
12a457 |
+ int i = 0;
|
|
|
12a457 |
+
|
|
|
12a457 |
+ for (i = 0; i < GF_PORT_MAX; i++) {
|
|
|
12a457 |
+ *(ports + i) = _gf_false;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
#if defined GF_LINUX_HOST_OS
|
|
|
12a457 |
char *ports_info = NULL;
|
|
|
12a457 |
char *tmp = NULL;
|
|
|
12a457 |
@@ -2822,7 +2828,11 @@ gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
|
|
12a457 |
|
|
|
12a457 |
out:
|
|
|
12a457 |
GF_FREE (ports_info);
|
|
|
12a457 |
+
|
|
|
12a457 |
+#else /* FIXME: Non Linux Host */
|
|
|
12a457 |
+ ret = 0;
|
|
|
12a457 |
#endif /* GF_LINUX_HOST_OS */
|
|
|
12a457 |
+
|
|
|
12a457 |
return ret;
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c
|
|
|
12a457 |
index 0bbbbc0..2f69975 100644
|
|
|
12a457 |
--- a/rpc/rpc-transport/rdma/src/name.c
|
|
|
12a457 |
+++ b/rpc/rpc-transport/rdma/src/name.c
|
|
|
12a457 |
@@ -56,15 +56,9 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id,
|
|
|
12a457 |
{
|
|
|
12a457 |
int32_t ret = -1;
|
|
|
12a457 |
uint16_t port = ceiling - 1;
|
|
|
12a457 |
- /* by default assume none of the ports are blocked and all are available */
|
|
|
12a457 |
- gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
|
|
|
12a457 |
- int i = 0;
|
|
|
12a457 |
+ gf_boolean_t ports[GF_PORT_MAX];
|
|
|
12a457 |
|
|
|
12a457 |
ret = gf_process_reserved_ports (ports, ceiling);
|
|
|
12a457 |
- if (ret != 0) {
|
|
|
12a457 |
- for (i = 0; i < GF_PORT_MAX; i++)
|
|
|
12a457 |
- ports[i] = _gf_false;
|
|
|
12a457 |
- }
|
|
|
12a457 |
|
|
|
12a457 |
while (port) {
|
|
|
12a457 |
_assign_port (sockaddr, port);
|
|
|
12a457 |
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
|
|
|
12a457 |
index 650c5a7..642e99c 100644
|
|
|
12a457 |
--- a/rpc/rpc-transport/socket/src/name.c
|
|
|
12a457 |
+++ b/rpc/rpc-transport/socket/src/name.c
|
|
|
12a457 |
@@ -44,20 +44,14 @@ af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr,
|
|
|
12a457 |
{
|
|
|
12a457 |
int32_t ret = -1;
|
|
|
12a457 |
uint16_t port = ceiling - 1;
|
|
|
12a457 |
- // by default assume none of the ports are blocked and all are available
|
|
|
12a457 |
- gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
|
|
|
12a457 |
- int i = 0;
|
|
|
12a457 |
+ gf_boolean_t ports[GF_PORT_MAX];
|
|
|
12a457 |
|
|
|
12a457 |
ret = gf_process_reserved_ports (ports, ceiling);
|
|
|
12a457 |
- if (ret != 0) {
|
|
|
12a457 |
- for (i = 0; i < GF_PORT_MAX; i++)
|
|
|
12a457 |
- ports[i] = _gf_false;
|
|
|
12a457 |
- }
|
|
|
12a457 |
|
|
|
12a457 |
while (port)
|
|
|
12a457 |
{
|
|
|
12a457 |
_assign_port (sockaddr, port);
|
|
|
12a457 |
- // ignore the reserved ports
|
|
|
12a457 |
+ /* ignore the reserved ports */
|
|
|
12a457 |
if (ports[port] == _gf_true) {
|
|
|
12a457 |
port--;
|
|
|
12a457 |
continue;
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|