summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-01-14 17:00:14 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-01-14 17:00:14 +0000
commit455791f265e6e581fa4ebddd5dc4642b2201f8ce (patch)
treeebd5cad9534291822f8c47dbbc8162525f8fe92e /rpc/rpc-lib
parent92eaa72ea4cd0d06c2161842c548008db0eee01c (diff)
parent7d89ec77763dc5076379753c736f7fce2bedd9ec (diff)
Merge branch 'upstream' into merge
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/auth-glusterfs.c12
-rw-r--r--rpc/rpc-lib/src/auth-null.c9
-rw-r--r--rpc/rpc-lib/src/auth-unix.c6
-rw-r--r--rpc/rpc-lib/src/protocol-common.h17
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c9
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.h3
-rw-r--r--rpc/rpc-lib/src/rpc-drc.c42
-rw-r--r--rpc/rpc-lib/src/rpcsvc-auth.c50
-rw-r--r--rpc/rpc-lib/src/rpcsvc-common.h2
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c10
-rw-r--r--rpc/rpc-lib/src/rpcsvc.h8
11 files changed, 90 insertions, 78 deletions
diff --git a/rpc/rpc-lib/src/auth-glusterfs.c b/rpc/rpc-lib/src/auth-glusterfs.c
index db488434c..48871ffb3 100644
--- a/rpc/rpc-lib/src/auth-glusterfs.c
+++ b/rpc/rpc-lib/src/auth-glusterfs.c
@@ -50,12 +50,6 @@ ret:
int
auth_glusterfs_request_init (rpcsvc_request_t *req, void *priv)
{
- if (!req)
- return -1;
- memset (req->verf.authdata, 0, GF_MAX_AUTH_BYTES);
- req->verf.datalen = 0;
- req->verf.flavour = AUTH_NULL;
-
return 0;
}
@@ -172,12 +166,6 @@ ret:
int
auth_glusterfs_v2_request_init (rpcsvc_request_t *req, void *priv)
{
- if (!req)
- return -1;
- memset (req->verf.authdata, 0, GF_MAX_AUTH_BYTES);
- req->verf.datalen = 0;
- req->verf.flavour = AUTH_NULL;
-
return 0;
}
diff --git a/rpc/rpc-lib/src/auth-null.c b/rpc/rpc-lib/src/auth-null.c
index ebdcc8ff8..b030341ab 100644
--- a/rpc/rpc-lib/src/auth-null.c
+++ b/rpc/rpc-lib/src/auth-null.c
@@ -22,15 +22,6 @@
int
auth_null_request_init (rpcsvc_request_t *req, void *priv)
{
- if (!req)
- return -1;
-
- memset (req->cred.authdata, 0, GF_MAX_AUTH_BYTES);
- req->cred.datalen = 0;
-
- memset (req->verf.authdata, 0, GF_MAX_AUTH_BYTES);
- req->verf.datalen = 0;
-
return 0;
}
diff --git a/rpc/rpc-lib/src/auth-unix.c b/rpc/rpc-lib/src/auth-unix.c
index fa5f0576e..27351f669 100644
--- a/rpc/rpc-lib/src/auth-unix.c
+++ b/rpc/rpc-lib/src/auth-unix.c
@@ -24,12 +24,6 @@
int
auth_unix_request_init (rpcsvc_request_t *req, void *priv)
{
- if (!req)
- return -1;
- memset (req->verf.authdata, 0, GF_MAX_AUTH_BYTES);
- req->verf.datalen = 0;
- req->verf.flavour = AUTH_NULL;
-
return 0;
}
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index d64f280cf..5876a500b 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -221,6 +221,23 @@ typedef enum {
GF_AFR_OP_STATISTICS_HEAL_COUNT_PER_REPLICA,
} gf_xl_afr_op_t ;
+struct gf_gsync_detailed_status_ {
+ char node[NAME_MAX];
+ char master[NAME_MAX];
+ char brick[NAME_MAX];
+ char slave_node[NAME_MAX];
+ char worker_status[NAME_MAX];
+ char checkpoint_status[NAME_MAX];
+ char crawl_status[NAME_MAX];
+ char files_syncd[NAME_MAX];
+ char files_remaining[NAME_MAX];
+ char bytes_remaining[NAME_MAX];
+ char purges_remaining[NAME_MAX];
+ char total_files_skipped[NAME_MAX];
+};
+
+typedef struct gf_gsync_detailed_status_ gf_gsync_status_t;
+
#define GLUSTER_HNDSK_PROGRAM 14398633 /* Completely random */
#define GLUSTER_HNDSK_VERSION 2 /* 0.0.2 */
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index ac98a5c91..1e9f307be 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -416,7 +416,7 @@ rpc_clnt_reconnect (void *trans_ptr)
conn->reconnect);
conn->reconnect = 0;
- if (conn->connected == 0) {
+ if ((conn->connected == 0) && !clnt->disabled) {
ts.tv_sec = 3;
ts.tv_nsec = 0;
@@ -834,6 +834,7 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
rpc_request_info_t *req_info = NULL;
rpc_transport_pollin_t *pollin = NULL;
struct timespec ts = {0, };
+ void *clnt_mydata = NULL;
conn = mydata;
if (conn == NULL) {
@@ -870,6 +871,12 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
}
case RPC_TRANSPORT_CLEANUP:
+ if (clnt->notifyfn) {
+ clnt_mydata = clnt->mydata;
+ clnt->mydata = NULL;
+ ret = clnt->notifyfn (clnt, clnt_mydata,
+ RPC_CLNT_DESTROY, NULL);
+ }
rpc_clnt_destroy (clnt);
ret = 0;
break;
diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h
index 584963ad0..2596c3508 100644
--- a/rpc/rpc-lib/src/rpc-clnt.h
+++ b/rpc/rpc-lib/src/rpc-clnt.h
@@ -19,7 +19,8 @@
typedef enum {
RPC_CLNT_CONNECT,
RPC_CLNT_DISCONNECT,
- RPC_CLNT_MSG
+ RPC_CLNT_MSG,
+ RPC_CLNT_DESTROY
} rpc_clnt_event_t;
diff --git a/rpc/rpc-lib/src/rpc-drc.c b/rpc/rpc-lib/src/rpc-drc.c
index e7ba114dd..7e77e038e 100644
--- a/rpc/rpc-lib/src/rpc-drc.c
+++ b/rpc/rpc-lib/src/rpc-drc.c
@@ -712,38 +712,30 @@ rpcsvc_drc_init (rpcsvc_t *svc, dict_t *options)
GF_ASSERT (svc);
GF_ASSERT (options);
- if (!svc->drc) {
- drc = GF_CALLOC (1, sizeof (rpcsvc_drc_globals_t),
- gf_common_mt_drc_globals_t);
- if (!drc)
- return -1;
-
- svc->drc = drc;
- LOCK_INIT (&drc->lock);
- } else {
- drc = svc->drc;
- }
-
- LOCK (&drc->lock);
- if (drc->type != DRC_TYPE_NONE) {
- ret = 0;
- goto out;
- }
-
/* Toggle DRC on/off, when more drc types(persistent/cluster)
are added, we shouldn't treat this as boolean */
ret = dict_get_str_boolean (options, "nfs.drc", _gf_true);
if (ret == -1) {
- gf_log (GF_RPCSVC, GF_LOG_INFO, "drc user options need second look");
+ gf_log (GF_RPCSVC, GF_LOG_INFO,
+ "drc user options need second look");
ret = _gf_true;
}
- if (ret == _gf_false) {
- /* drc off */
- gf_log (GF_RPCSVC, GF_LOG_INFO, "DRC is manually turned OFF");
- ret = 0;
- goto out;
- }
+ gf_log (GF_RPCSVC, GF_LOG_INFO, "DRC is turned %s", (ret?"ON":"OFF"));
+
+ /*DRC off, nothing to do */
+ if (ret == _gf_false)
+ return (0);
+
+ drc = GF_CALLOC (1, sizeof (rpcsvc_drc_globals_t),
+ gf_common_mt_drc_globals_t);
+ if (!drc)
+ return (-1);
+
+ LOCK_INIT (&drc->lock);
+ svc->drc = drc;
+
+ LOCK (&drc->lock);
/* Specify type of DRC to be used */
ret = dict_get_uint32 (options, "nfs.drc-type", &drc_type);
diff --git a/rpc/rpc-lib/src/rpcsvc-auth.c b/rpc/rpc-lib/src/rpcsvc-auth.c
index 4cb86a758..384e4a75d 100644
--- a/rpc/rpc-lib/src/rpcsvc-auth.c
+++ b/rpc/rpc-lib/src/rpcsvc-auth.c
@@ -230,6 +230,8 @@ int
rpcsvc_set_root_squash (rpcsvc_t *svc, dict_t *options)
{
int ret = -1;
+ uid_t anonuid = -1;
+ gid_t anongid = -1;
GF_ASSERT (svc);
GF_ASSERT (options);
@@ -240,8 +242,21 @@ rpcsvc_set_root_squash (rpcsvc_t *svc, dict_t *options)
else
svc->root_squash = _gf_false;
+ ret = dict_get_uint32 (options, "anonuid", &anonuid);
+ if (!ret)
+ svc->anonuid = anonuid;
+ else
+ svc->anonuid = RPC_NOBODY_UID;
+
+ ret = dict_get_uint32 (options, "anongid", &anongid);
+ if (!ret)
+ svc->anongid = anongid;
+ else
+ svc->anongid = RPC_NOBODY_GID;
+
if (svc->root_squash)
- gf_log (GF_RPCSVC, GF_LOG_DEBUG, "root squashing enabled ");
+ gf_log (GF_RPCSVC, GF_LOG_DEBUG, "root squashing enabled "
+ "(uid=%d, gid=%d)", svc->anonuid, svc->anongid);
return 0;
}
@@ -354,25 +369,36 @@ ret:
int
-rpcsvc_auth_request_init (rpcsvc_request_t *req)
+rpcsvc_auth_request_init (rpcsvc_request_t *req, struct rpc_msg *callmsg)
{
- int ret = -1;
+ int32_t ret = 0;
rpcsvc_auth_t *auth = NULL;
- if (!req)
- return -1;
+ if (!req || !callmsg) {
+ ret = -1;
+ goto err;
+ }
+
+ req->cred.flavour = rpc_call_cred_flavour (callmsg);
+ req->cred.datalen = rpc_call_cred_len (callmsg);
+ req->verf.flavour = rpc_call_verf_flavour (callmsg);
+ req->verf.datalen = rpc_call_verf_len (callmsg);
auth = rpcsvc_auth_get_handler (req);
- if (!auth)
+ if (!auth) {
+ ret = -1;
goto err;
- ret = 0;
+ }
+
gf_log (GF_RPCSVC, GF_LOG_TRACE, "Auth handler: %s", auth->authname);
- if (!auth->authops->request_init)
- ret = auth->authops->request_init (req, auth->authprivate);
- req->auxgids = req->auxgidsmall; /* reset to auxgidlarge during
- unsersialize if necessary */
- req->auxgidlarge = NULL;
+ if (auth->authops->request_init)
+ ret = auth->authops->request_init (req, auth->authprivate);
+
+ /* reset to auxgidlarge during
+ unsersialize if necessary */
+ req->auxgids = req->auxgidsmall;
+ req->auxgidlarge = NULL;
err:
return ret;
}
diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h
index aed55e039..3c16abeb7 100644
--- a/rpc/rpc-lib/src/rpcsvc-common.h
+++ b/rpc/rpc-lib/src/rpcsvc-common.h
@@ -55,6 +55,8 @@ typedef struct rpcsvc_state {
gf_boolean_t allow_insecure;
gf_boolean_t register_portmap;
gf_boolean_t root_squash;
+ uid_t anonuid;
+ gid_t anongid;
glusterfs_ctx_t *ctx;
/* list of connections which will listen for incoming connections */
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 037c157f2..69db8b70b 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -367,13 +367,7 @@ rpcsvc_request_init (rpcsvc_t *svc, rpc_transport_t *trans,
* been copied into the required sections of the req structure,
* we just need to fill in the meta-data about it now.
*/
- req->cred.flavour = rpc_call_cred_flavour (callmsg);
- req->cred.datalen = rpc_call_cred_len (callmsg);
- req->verf.flavour = rpc_call_verf_flavour (callmsg);
- req->verf.datalen = rpc_call_verf_len (callmsg);
-
- /* AUTH */
- rpcsvc_auth_request_init (req);
+ rpcsvc_auth_request_init (req, callmsg);
return req;
}
@@ -1183,7 +1177,7 @@ rpcsvc_submit_generic (rpcsvc_request_t *req, struct iovec *proghdr,
iobref_add (iobref, replyiob);
/* cache the request in the duplicate request cache for appropriate ops */
- if (req->reply) {
+ if ((req->reply) && (rpcsvc_need_drc (req))) {
drc = req->svc->drc;
LOCK (&drc->lock);
diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h
index cbc1f4226..30a969b11 100644
--- a/rpc/rpc-lib/src/rpcsvc.h
+++ b/rpc/rpc-lib/src/rpcsvc.h
@@ -282,14 +282,14 @@ struct rpcsvc_request {
int gidcount = 0; \
if (req->svc->root_squash) { \
if (req->uid == RPC_ROOT_UID) \
- req->uid = RPC_NOBODY_UID; \
+ req->uid = req->svc->anonuid; \
if (req->gid == RPC_ROOT_GID) \
- req->gid = RPC_NOBODY_GID; \
+ req->gid = req->svc->anongid; \
for (gidcount = 0; gidcount < req->auxgidcount; \
++gidcount) { \
if (!req->auxgids[gidcount]) \
req->auxgids[gidcount] = \
- RPC_NOBODY_GID; \
+ req->svc->anongid; \
} \
} \
} while (0);
@@ -553,7 +553,7 @@ struct rpcsvc_auth_list {
};
extern int
-rpcsvc_auth_request_init (rpcsvc_request_t *req);
+rpcsvc_auth_request_init (rpcsvc_request_t *req, struct rpc_msg *callmsg);
extern int
rpcsvc_auth_init (rpcsvc_t *svc, dict_t *options);