diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 35 |
1 files changed, 35 insertions, 0 deletions
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) { |