From 3a0fe71cebd59c1204c60a7d20b2fe2b94f07665 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Wed, 14 Dec 2011 14:46:09 +0530 Subject: glusterd: Fail 'requests' from non-peers. glusterd should not honour "volume op requests" from peers who are not part of the cluster. Change-Id: I6cb6d630a9da02ab060650f21edb46db8deb70e8 BUG: 767559 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/787 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-handler.c | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 1d311649c1e..a331bfbb2f5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -463,6 +463,7 @@ glusterd_handle_cluster_lock (rpcsvc_request_t *req) gd1_mgmt_cluster_lock_req lock_req = {{0},}; int32_t ret = -1; glusterd_op_lock_ctx_t *ctx = NULL; + glusterd_peerinfo_t *peerinfo = NULL; GF_ASSERT (req); @@ -475,6 +476,13 @@ glusterd_handle_cluster_lock (rpcsvc_request_t *req) gf_log ("glusterd", GF_LOG_INFO, "Received LOCK from uuid: %s", uuid_utoa (lock_req.uuid)); + if (glusterd_friend_find_by_uuid (lock_req.uuid, &peerinfo)) { + gf_log (THIS->name, GF_LOG_WARNING, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (lock_req.uuid)); + ret = -1; + goto out; + } ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t); @@ -551,6 +559,7 @@ glusterd_handle_stage_op (rpcsvc_request_t *req) int32_t ret = -1; glusterd_req_ctx_t *req_ctx = NULL; gd1_mgmt_stage_op_req op_req = {{0},}; + glusterd_peerinfo_t *peerinfo = NULL; GF_ASSERT (req); if (!xdr_to_generic (req->msg[0], &op_req, (xdrproc_t)xdr_gd1_mgmt_stage_op_req)) { @@ -559,6 +568,14 @@ glusterd_handle_stage_op (rpcsvc_request_t *req) goto out; } + if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) { + gf_log (THIS->name, GF_LOG_WARNING, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (op_req.uuid)); + ret = -1; + goto out; + } + ret = glusterd_req_ctx_create (req, op_req.op, op_req.uuid, op_req.buf.buf_val, op_req.buf.buf_len, gf_gld_mt_op_stage_ctx_t, &req_ctx); @@ -581,6 +598,7 @@ glusterd_handle_commit_op (rpcsvc_request_t *req) int32_t ret = -1; glusterd_req_ctx_t *req_ctx = NULL; gd1_mgmt_commit_op_req op_req = {{0},}; + glusterd_peerinfo_t *peerinfo = NULL; GF_ASSERT (req); @@ -590,6 +608,14 @@ glusterd_handle_commit_op (rpcsvc_request_t *req) goto out; } + if (glusterd_friend_find_by_uuid (op_req.uuid, &peerinfo)) { + gf_log (THIS->name, GF_LOG_WARNING, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (op_req.uuid)); + ret = -1; + goto out; + } + //the structures should always be equal GF_ASSERT (sizeof (gd1_mgmt_commit_op_req) == sizeof (gd1_mgmt_stage_op_req)); ret = glusterd_req_ctx_create (req, op_req.op, op_req.uuid, @@ -1239,6 +1265,7 @@ glusterd_handle_cluster_unlock (rpcsvc_request_t *req) gd1_mgmt_cluster_unlock_req unlock_req = {{0}, }; int32_t ret = -1; glusterd_op_lock_ctx_t *ctx = NULL; + glusterd_peerinfo_t *peerinfo = NULL; GF_ASSERT (req); @@ -1253,6 +1280,14 @@ glusterd_handle_cluster_unlock (rpcsvc_request_t *req) gf_log ("glusterd", GF_LOG_INFO, "Received UNLOCK from uuid: %s", uuid_utoa (unlock_req.uuid)); + if (glusterd_friend_find_by_uuid (unlock_req.uuid, &peerinfo)) { + gf_log (THIS->name, GF_LOG_WARNING, "%s doesn't " + "belong to the cluster. Ignoring request.", + uuid_utoa (unlock_req.uuid)); + ret = -1; + goto out; + } + ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_op_lock_ctx_t); if (!ctx) { -- cgit