From 60c4a19f15d806e36e8e67352349cc1c6daa0199 Mon Sep 17 00:00:00 2001
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Date: Fri, 16 Sep 2016 13:19:48 +0530
Subject: [PATCH 53/86] 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
Backport of:
> 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>
Change-Id: I4fda83fae7747507f64d81a7645cc3a8a2fbaeae
BUG: 1367382
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/84770
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/protocol/server/src/server-handshake.c | 17 +++++++
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 7715952..1230cdf 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 10009e2..457f3d6 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);
@@ -488,6 +490,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,
@@ -547,19 +551,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);
@@ -718,6 +748,7 @@ reconfigure (xlator_t *this, dict_t *options)
char *statedump_path = NULL;
xlator_t *xl = NULL;
int32_t new_nthread = 0;
+ char *auth_path = NULL;
conf = this->private;
@@ -842,6 +873,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,
--
1.7.1