summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-pmap.c
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2017-08-10 18:31:55 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-08-17 04:02:20 +0000
commit3998c28324c8907b9b3ade75c98a6a0e4591f23b (patch)
tree0f8dd704dabdac15c03fcc383f44171c167ae807 /xlators/mgmt/glusterd/src/glusterd-pmap.c
parent204d52a4b6c13d16132f67ee94f823fa23c11538 (diff)
glusterd: introduce max-port range
glusterd.vol file always had an option (commented out) to indicate the base-port to start the portmapper allocation. This patch brings in the max-port configuration where one can limit the range of ports which gluster can be allowed to bind. Fixes: #305 Change-Id: Id7a864f818227b9530a07e13d605138edacd9aa9 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: https://review.gluster.org/18016 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Gaurav Yadav <gyadav@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-pmap.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
index 2a754769c95..6d8cf3f894f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
@@ -61,8 +61,8 @@ pmap_registry_new (xlator_t *this)
pmap->base_port = pmap->last_alloc =
((glusterd_conf_t *)(this->private))->base_port;
-
- for (i = pmap->base_port; i <= GF_PORT_MAX; i++) {
+ pmap->max_port = ((glusterd_conf_t *)(this->private))->max_port;
+ for (i = pmap->base_port; i <= pmap->max_port; i++) {
if (pmap_port_isfree (i))
pmap->ports[i].type = GF_PMAP_PORT_FREE;
else
@@ -184,10 +184,12 @@ pmap_registry_search_by_xprt (xlator_t *this, void *xprt,
static char *
pmap_registry_search_by_port (xlator_t *this, int port)
{
- struct pmap_registry *pmap = NULL;
- char *brickname = NULL;
+ struct pmap_registry *pmap = NULL;
+ char *brickname = NULL;
+ int max_port = 0;
- if (port > GF_PORT_MAX)
+ max_port = ((glusterd_conf_t *)(this->private))->max_port;
+ if (port > max_port)
goto out;
pmap = pmap_registry_get (this);
@@ -209,7 +211,7 @@ pmap_registry_alloc (xlator_t *this)
pmap = pmap_registry_get (this);
- for (p = pmap->base_port; p <= GF_PORT_MAX; p++) {
+ for (p = pmap->base_port; p <= pmap->max_port; p++) {
/* GF_PMAP_PORT_FOREIGN may be freed up ? */
if ((pmap->ports[p].type == GF_PMAP_PORT_FREE) ||
(pmap->ports[p].type == GF_PMAP_PORT_FOREIGN)) {
@@ -260,7 +262,7 @@ pmap_registry_bind (xlator_t *this, int port, const char *brickname,
pmap = pmap_registry_get (this);
- if (port > GF_PORT_MAX)
+ if (port > pmap->max_port)
goto out;
p = port;
@@ -296,7 +298,7 @@ pmap_registry_extend (xlator_t *this, int port, const char *brickname)
pmap = pmap_registry_get (this);
- if (port > GF_PORT_MAX) {
+ if (port > pmap->max_port) {
return -1;
}
@@ -355,7 +357,7 @@ pmap_registry_remove (xlator_t *this, int port, const char *brickname,
goto out;
if (port) {
- if (port > GF_PORT_MAX)
+ if (port > pmap->max_port)
goto out;
p = port;