From 077e9cf177618e77f91aca382fb857287df9099f Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 9 Nov 2009 10:16:04 -0800 Subject: [PATCH] auth: distribute global instance id to client --- src/mon/AuthMonitor.cc | 5 +++-- src/mon/MonClient.cc | 9 ++++++++- src/mon/MonClient.h | 4 +++- src/mon/Session.h | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 7e4b51dadeca7..2ff7d4ccfecf0 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -370,8 +370,8 @@ bool AuthMonitor::preprocess_auth(MAuth *m) EntityName entity_name; if (!s->auth_handler) { - uint64_t global_id = assign_global_id(m); - if (!global_id) + s->global_id = assign_global_id(m); + if (!s->global_id) goto done; set<__u32> supported; @@ -389,6 +389,7 @@ bool AuthMonitor::preprocess_auth(MAuth *m) if (!s->auth_handler) ret = -EPERM; else { + ::encode(s->global_id, response_bl); proto = s->auth_handler->start_session(entity_name, indata, response_bl); if (proto == CEPH_AUTH_NONE) { s->caps.set_allow_all(true); diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index bf18760e93b55..387ff28017371 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -319,6 +319,7 @@ void MonClient::handle_mount_ack(MClientMountAck* m) void MonClient::handle_auth(MAuthReply *m) { + bufferlist::iterator p = m->result_bl.begin(); if (state == MC_STATE_NEGOTIATING) { if (!auth || (int)m->protocol != auth->get_protocol()) { delete auth; @@ -332,11 +333,17 @@ void MonClient::handle_auth(MAuthReply *m) } else { auth->reset(); } + try { + ::decode(global_id, p); + dout(0) << "decoded global_id=" << global_id << dendl; + } catch (buffer::error *err) { + delete m; + return; + } state = MC_STATE_AUTHENTICATING; } assert(auth); - bufferlist::iterator p = m->result_bl.begin(); int ret = auth->handle_response(m->result, p); delete m; diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 1ba4019c02730..e2e8df6a7f617 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -89,6 +89,8 @@ private: uint32_t want_keys; + uint64_t global_id; + // mount private: client_t clientid; @@ -175,7 +177,7 @@ public: timer(monc_lock), hunting(false), want_monmap(false), - want_keys(0), + want_keys(0), global_id(0), mounting(0), mount_err(0), auth(NULL) { } ~MonClient() { diff --git a/src/mon/Session.h b/src/mon/Session.h index bddb4eef2e073..e7356114f5c1c 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -41,13 +41,14 @@ struct Session : public RefCountedObject { xlist::item item; set<__u64> routed_request_tids; MonCaps caps; + uint64_t global_id; map sub_map; AuthServiceHandler *auth_handler; Session(entity_inst_t i) : inst(i), closed(false), item(this), - auth_handler(NULL) {} + global_id(0), auth_handler(NULL) {} ~Session() { generic_dout(0) << "~Session " << this << dendl; // we should have been removed before we get destructed; see SessionMap::remove_session() -- 2.39.5