diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2016-08-30 13:40:41 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2016-09-06 02:30:05 -0700 |
commit | db3286184a1ab89d3edb9cf4d645a2db724fada0 (patch) | |
tree | d21e510517962e23c099fa249f632e12a54b1dc0 /xlators/protocol | |
parent | c67386e1e8edcbdf2f8dca06fc7984df2adb1f06 (diff) |
protocol-server: generate events
This patch add/generate the events seen from/in the protocol server
side, which will be consumed by the new eventing framework.
-------------------------------------------------------------------------
| event | description |
|-------------------------------|---------------------------------------|
| EVENT_CLIENT_CONNECT | new client connected |
|-------------------------------|---------------------------------------|
| EVENT_CLIENT_AUTH_REJECT | client cannot be authenticated |
|-------------------------------|---------------------------------------|
| EVENT_CLIENT_DISCONNECT | client had disconnected |
-------------------------------------------------------------------------
Thanks to "Raghavendra Talur" <rtalur@redhat.com> for all the help
Change-Id: I4fda83fae7747507f64d81a7645cc3a8a2fbaeae
BUG: 1369403
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-on: http://review.gluster.org/15294
Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 17 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 55 |
2 files changed, 70 insertions, 2 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 771595228eb..1230cdf7ab5 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -18,6 +18,7 @@ #include "authenticate.h" #include "server-messages.h" #include "syscall.h" +#include "events.h" struct __get_xl_struct { const char *name; @@ -690,6 +691,15 @@ server_setvolume (rpcsvc_request_t *req) "accepted client from %s (version: %s)", client->client_uid, (clnt_version) ? clnt_version : "old"); + + gf_event (EVENT_CLIENT_CONNECT, "client_uid=%s;" + "client_identifier=%s;server_identifier=%s;" + "brick_path=%s", + client->client_uid, + req->trans->peerinfo.identifier, + req->trans->myinfo.identifier, + name); + op_ret = 0; client->bound_xl = xl; ret = dict_set_str (reply, "ERROR", "Success"); @@ -697,6 +707,13 @@ server_setvolume (rpcsvc_request_t *req) gf_msg_debug (this->name, 0, "failed to set error " "msg"); } else { + gf_event (EVENT_CLIENT_AUTH_REJECT, "client_uid=%s;" + "client_identifier=%s;server_identifier=%s;" + "brick_path=%s", + client->client_uid, + req->trans->peerinfo.identifier, + req->trans->myinfo.identifier, + name); gf_msg (this->name, GF_LOG_ERROR, EACCES, PS_MSG_AUTHENTICATE_ERROR, "Cannot authenticate client" " from %s %s", client->client_uid, diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index f04dd67f61d..a99c1470276 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -21,6 +21,7 @@ #include "defaults.h" #include "authenticate.h" #include "event.h" +#include "events.h" #include "server-messages.h" rpcsvc_cbk_program_t server_cbk_prog = { @@ -76,7 +77,8 @@ grace_time_handler (void *data) */ gf_client_ref (client); gf_client_put (client, &detached); - if (detached)//reconnection did not happen :-( + + if (detached) /* reconnection did not happen :-( */ server_connection_cleanup (this, client, INTERNAL_LOCKS | POSIX_LOCKS); gf_client_unref (client); @@ -487,6 +489,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, client_t *client = NULL; server_ctx_t *serv_ctx = NULL; struct timespec grace_ts = {0, }; + char *auth_path = NULL; + int ret = -1; if (!xl || !data) { gf_msg_callingfn ("server", GF_LOG_WARNING, 0, @@ -546,19 +550,45 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, PS_MSG_CLIENT_DISCONNECTING, "disconnecting connection" " from %s", client->client_uid); + ret = dict_get_str (this->options, "auth-path", &auth_path); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + PS_MSG_DICT_GET_FAILED, + "failed to get auth-path"); + auth_path = NULL; + } + /* If lock self heal is off, then destroy the conn object, else register a grace timer event */ if (!conf->lk_heal) { gf_client_ref (client); gf_client_put (client, &detached); - if (detached) + if (detached) { server_connection_cleanup (this, client, INTERNAL_LOCKS | POSIX_LOCKS); + + gf_event (EVENT_CLIENT_DISCONNECT, + "client_uid=%s;" + "client_identifier=%s;" + "server_identifier=%s;" + "brick_path=%s", + client->client_uid, + trans->peerinfo.identifier, + trans->myinfo.identifier, + auth_path); + } gf_client_unref (client); break; } trans->xl_private = NULL; server_connection_cleanup (this, client, INTERNAL_LOCKS); + gf_event (EVENT_CLIENT_DISCONNECT, "client_uid=%s;" + "client_identifier=%s;server_identifier=%s;" + "brick_path=%s", + client->client_uid, + trans->peerinfo.identifier, + trans->myinfo.identifier, + auth_path); serv_ctx = server_ctx_get (client, this); @@ -716,6 +746,7 @@ reconfigure (xlator_t *this, dict_t *options) int ret = 0; char *statedump_path = NULL; int32_t new_nthread = 0; + char *auth_path = NULL; conf = this->private; @@ -840,6 +871,26 @@ reconfigure (xlator_t *this, dict_t *options) "authorized client, hence we " "continue with this connection"); } else { + ret = dict_get_str (this->options, + "auth-path", + &auth_path); + if (ret) { + gf_msg (this->name, + GF_LOG_WARNING, 0, + PS_MSG_DICT_GET_FAILED, + "failed to get " + "auth-path"); + auth_path = NULL; + } + gf_event (EVENT_CLIENT_AUTH_REJECT, + "client_uid=%s;" + "client_identifier=%s;" + "server_identifier=%s;" + "brick_path=%s", + xprt->xl_private->client_uid, + xprt->peerinfo.identifier, + xprt->myinfo.identifier, + auth_path); gf_msg (this->name, GF_LOG_INFO, EACCES, PS_MSG_AUTHENTICATE_ERROR, |