|
|
3604df |
From 60c4a19f15d806e36e8e67352349cc1c6daa0199 Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
3604df |
Date: Fri, 16 Sep 2016 13:19:48 +0530
|
|
|
3604df |
Subject: [PATCH 53/86] protocol-server: generate events
|
|
|
3604df |
|
|
|
3604df |
This patch add/generate the events seen from/in the protocol server
|
|
|
3604df |
side, which will be consumed by the new eventing framework.
|
|
|
3604df |
|
|
|
3604df |
-------------------------------------------------------------------------
|
|
|
3604df |
| event | description |
|
|
|
3604df |
|-------------------------------|---------------------------------------|
|
|
|
3604df |
| EVENT_CLIENT_CONNECT | new client connected |
|
|
|
3604df |
|-------------------------------|---------------------------------------|
|
|
|
3604df |
| EVENT_CLIENT_AUTH_REJECT | client cannot be authenticated |
|
|
|
3604df |
|-------------------------------|---------------------------------------|
|
|
|
3604df |
| EVENT_CLIENT_DISCONNECT | client had disconnected |
|
|
|
3604df |
-------------------------------------------------------------------------
|
|
|
3604df |
|
|
|
3604df |
Thanks to "Raghavendra Talur" <rtalur@redhat.com> for all the help
|
|
|
3604df |
|
|
|
3604df |
Backport of:
|
|
|
3604df |
> Change-Id: I4fda83fae7747507f64d81a7645cc3a8a2fbaeae
|
|
|
3604df |
> BUG: 1369403
|
|
|
3604df |
> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
3604df |
> Reviewed-on: http://review.gluster.org/15294
|
|
|
3604df |
> Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com>
|
|
|
3604df |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
3604df |
|
|
|
3604df |
Change-Id: I4fda83fae7747507f64d81a7645cc3a8a2fbaeae
|
|
|
3604df |
BUG: 1367382
|
|
|
3604df |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/84770
|
|
|
3604df |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
xlators/protocol/server/src/server-handshake.c | 17 +++++++
|
|
|
3604df |
xlators/protocol/server/src/server.c | 55 +++++++++++++++++++++++-
|
|
|
3604df |
2 files changed, 70 insertions(+), 2 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
|
|
|
3604df |
index 7715952..1230cdf 100644
|
|
|
3604df |
--- a/xlators/protocol/server/src/server-handshake.c
|
|
|
3604df |
+++ b/xlators/protocol/server/src/server-handshake.c
|
|
|
3604df |
@@ -18,6 +18,7 @@
|
|
|
3604df |
#include "authenticate.h"
|
|
|
3604df |
#include "server-messages.h"
|
|
|
3604df |
#include "syscall.h"
|
|
|
3604df |
+#include "events.h"
|
|
|
3604df |
|
|
|
3604df |
struct __get_xl_struct {
|
|
|
3604df |
const char *name;
|
|
|
3604df |
@@ -690,6 +691,15 @@ server_setvolume (rpcsvc_request_t *req)
|
|
|
3604df |
"accepted client from %s (version: %s)",
|
|
|
3604df |
client->client_uid,
|
|
|
3604df |
(clnt_version) ? clnt_version : "old");
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_event (EVENT_CLIENT_CONNECT, "client_uid=%s;"
|
|
|
3604df |
+ "client_identifier=%s;server_identifier=%s;"
|
|
|
3604df |
+ "brick_path=%s",
|
|
|
3604df |
+ client->client_uid,
|
|
|
3604df |
+ req->trans->peerinfo.identifier,
|
|
|
3604df |
+ req->trans->myinfo.identifier,
|
|
|
3604df |
+ name);
|
|
|
3604df |
+
|
|
|
3604df |
op_ret = 0;
|
|
|
3604df |
client->bound_xl = xl;
|
|
|
3604df |
ret = dict_set_str (reply, "ERROR", "Success");
|
|
|
3604df |
@@ -697,6 +707,13 @@ server_setvolume (rpcsvc_request_t *req)
|
|
|
3604df |
gf_msg_debug (this->name, 0, "failed to set error "
|
|
|
3604df |
"msg");
|
|
|
3604df |
} else {
|
|
|
3604df |
+ gf_event (EVENT_CLIENT_AUTH_REJECT, "client_uid=%s;"
|
|
|
3604df |
+ "client_identifier=%s;server_identifier=%s;"
|
|
|
3604df |
+ "brick_path=%s",
|
|
|
3604df |
+ client->client_uid,
|
|
|
3604df |
+ req->trans->peerinfo.identifier,
|
|
|
3604df |
+ req->trans->myinfo.identifier,
|
|
|
3604df |
+ name);
|
|
|
3604df |
gf_msg (this->name, GF_LOG_ERROR, EACCES,
|
|
|
3604df |
PS_MSG_AUTHENTICATE_ERROR, "Cannot authenticate client"
|
|
|
3604df |
" from %s %s", client->client_uid,
|
|
|
3604df |
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
|
|
|
3604df |
index 10009e2..457f3d6 100644
|
|
|
3604df |
--- a/xlators/protocol/server/src/server.c
|
|
|
3604df |
+++ b/xlators/protocol/server/src/server.c
|
|
|
3604df |
@@ -21,6 +21,7 @@
|
|
|
3604df |
#include "defaults.h"
|
|
|
3604df |
#include "authenticate.h"
|
|
|
3604df |
#include "event.h"
|
|
|
3604df |
+#include "events.h"
|
|
|
3604df |
#include "server-messages.h"
|
|
|
3604df |
|
|
|
3604df |
rpcsvc_cbk_program_t server_cbk_prog = {
|
|
|
3604df |
@@ -76,7 +77,8 @@ grace_time_handler (void *data)
|
|
|
3604df |
*/
|
|
|
3604df |
gf_client_ref (client);
|
|
|
3604df |
gf_client_put (client, &detached);
|
|
|
3604df |
- if (detached)//reconnection did not happen :-(
|
|
|
3604df |
+
|
|
|
3604df |
+ if (detached) /* reconnection did not happen :-( */
|
|
|
3604df |
server_connection_cleanup (this, client,
|
|
|
3604df |
INTERNAL_LOCKS | POSIX_LOCKS);
|
|
|
3604df |
gf_client_unref (client);
|
|
|
3604df |
@@ -488,6 +490,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
|
|
|
3604df |
client_t *client = NULL;
|
|
|
3604df |
server_ctx_t *serv_ctx = NULL;
|
|
|
3604df |
struct timespec grace_ts = {0, };
|
|
|
3604df |
+ char *auth_path = NULL;
|
|
|
3604df |
+ int ret = -1;
|
|
|
3604df |
|
|
|
3604df |
if (!xl || !data) {
|
|
|
3604df |
gf_msg_callingfn ("server", GF_LOG_WARNING, 0,
|
|
|
3604df |
@@ -547,19 +551,45 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
|
|
|
3604df |
PS_MSG_CLIENT_DISCONNECTING, "disconnecting connection"
|
|
|
3604df |
" from %s", client->client_uid);
|
|
|
3604df |
|
|
|
3604df |
+ ret = dict_get_str (this->options, "auth-path", &auth_path);
|
|
|
3604df |
+ if (ret) {
|
|
|
3604df |
+ gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
3604df |
+ PS_MSG_DICT_GET_FAILED,
|
|
|
3604df |
+ "failed to get auth-path");
|
|
|
3604df |
+ auth_path = NULL;
|
|
|
3604df |
+ }
|
|
|
3604df |
+
|
|
|
3604df |
/* If lock self heal is off, then destroy the
|
|
|
3604df |
conn object, else register a grace timer event */
|
|
|
3604df |
if (!conf->lk_heal) {
|
|
|
3604df |
gf_client_ref (client);
|
|
|
3604df |
gf_client_put (client, &detached);
|
|
|
3604df |
- if (detached)
|
|
|
3604df |
+ if (detached) {
|
|
|
3604df |
server_connection_cleanup (this, client,
|
|
|
3604df |
INTERNAL_LOCKS | POSIX_LOCKS);
|
|
|
3604df |
+
|
|
|
3604df |
+ gf_event (EVENT_CLIENT_DISCONNECT,
|
|
|
3604df |
+ "client_uid=%s;"
|
|
|
3604df |
+ "client_identifier=%s;"
|
|
|
3604df |
+ "server_identifier=%s;"
|
|
|
3604df |
+ "brick_path=%s",
|
|
|
3604df |
+ client->client_uid,
|
|
|
3604df |
+ trans->peerinfo.identifier,
|
|
|
3604df |
+ trans->myinfo.identifier,
|
|
|
3604df |
+ auth_path);
|
|
|
3604df |
+ }
|
|
|
3604df |
gf_client_unref (client);
|
|
|
3604df |
break;
|
|
|
3604df |
}
|
|
|
3604df |
trans->xl_private = NULL;
|
|
|
3604df |
server_connection_cleanup (this, client, INTERNAL_LOCKS);
|
|
|
3604df |
+ gf_event (EVENT_CLIENT_DISCONNECT, "client_uid=%s;"
|
|
|
3604df |
+ "client_identifier=%s;server_identifier=%s;"
|
|
|
3604df |
+ "brick_path=%s",
|
|
|
3604df |
+ client->client_uid,
|
|
|
3604df |
+ trans->peerinfo.identifier,
|
|
|
3604df |
+ trans->myinfo.identifier,
|
|
|
3604df |
+ auth_path);
|
|
|
3604df |
|
|
|
3604df |
serv_ctx = server_ctx_get (client, this);
|
|
|
3604df |
|
|
|
3604df |
@@ -718,6 +748,7 @@ reconfigure (xlator_t *this, dict_t *options)
|
|
|
3604df |
char *statedump_path = NULL;
|
|
|
3604df |
xlator_t *xl = NULL;
|
|
|
3604df |
int32_t new_nthread = 0;
|
|
|
3604df |
+ char *auth_path = NULL;
|
|
|
3604df |
|
|
|
3604df |
conf = this->private;
|
|
|
3604df |
|
|
|
3604df |
@@ -842,6 +873,26 @@ reconfigure (xlator_t *this, dict_t *options)
|
|
|
3604df |
"authorized client, hence we "
|
|
|
3604df |
"continue with this connection");
|
|
|
3604df |
} else {
|
|
|
3604df |
+ ret = dict_get_str (this->options,
|
|
|
3604df |
+ "auth-path",
|
|
|
3604df |
+ &auth_path);
|
|
|
3604df |
+ if (ret) {
|
|
|
3604df |
+ gf_msg (this->name,
|
|
|
3604df |
+ GF_LOG_WARNING, 0,
|
|
|
3604df |
+ PS_MSG_DICT_GET_FAILED,
|
|
|
3604df |
+ "failed to get "
|
|
|
3604df |
+ "auth-path");
|
|
|
3604df |
+ auth_path = NULL;
|
|
|
3604df |
+ }
|
|
|
3604df |
+ gf_event (EVENT_CLIENT_AUTH_REJECT,
|
|
|
3604df |
+ "client_uid=%s;"
|
|
|
3604df |
+ "client_identifier=%s;"
|
|
|
3604df |
+ "server_identifier=%s;"
|
|
|
3604df |
+ "brick_path=%s",
|
|
|
3604df |
+ xprt->xl_private->client_uid,
|
|
|
3604df |
+ xprt->peerinfo.identifier,
|
|
|
3604df |
+ xprt->myinfo.identifier,
|
|
|
3604df |
+ auth_path);
|
|
|
3604df |
gf_msg (this->name, GF_LOG_INFO,
|
|
|
3604df |
EACCES,
|
|
|
3604df |
PS_MSG_AUTHENTICATE_ERROR,
|
|
|
3604df |
--
|
|
|
3604df |
1.7.1
|
|
|
3604df |
|