static int secinit_compose_request(struct obd_import *imp,
char *buf, int bufsize,
+ int lustre_srv,
uid_t uid, gid_t gid,
long token_size,
char __user *token)
hdr->flavor = cpu_to_le32(PTLRPC_SEC_GSS);
hdr->sectype = cpu_to_le32(PTLRPC_SEC_TYPE_NONE);
hdr->msg_len = cpu_to_le32(lmsg_size);
- hdr->sec_len = cpu_to_le32(7 * 4 + token_size);
+ hdr->sec_len = cpu_to_le32(8 * 4 + token_size);
/* lustre message & secdesc */
lmsg = buf_to_lustre_msg(buf);
*p++ = cpu_to_le32(PTLRPC_GSS_SVC_NONE); /* service */
*p++ = cpu_to_le32(0); /* context handle */
+ /* plus lustre svc type */
+ *p++ = cpu_to_le32(lustre_srv);
+
/* now the token part */
*p++ = cpu_to_le32((__u32) token_size);
LASSERT(((char *)p - buf) + token_size <= bufsize);
struct lgssd_ioctl_param {
int version; /* in */
char *uuid; /* in */
+ int lustre_svc; /* in */
uid_t uid; /* in */
gid_t gid; /* in */
long send_token_size;/* in */
static int gss_send_secinit_rpc(__user char *buffer, unsigned long count)
{
struct obd_import *imp;
+ struct ptlrpc_request *request = NULL;
struct lgssd_ioctl_param param;
const int reqbuf_size = 1024;
const int repbuf_size = 1024;
int rc, reqlen, replen;
if (count != sizeof(param)) {
- CERROR("partial write\n");
+ CERROR("ioctl size %lu, expect %d, please check lgssd version\n",
+ count, sizeof(param));
RETURN(-EINVAL);
}
- if (copy_from_user(¶m, buffer, sizeof(param)))
+ if (copy_from_user(¶m, buffer, sizeof(param))) {
+ CERROR("failed copy data from lgssd\n");
RETURN(-EFAULT);
+ }
if (param.version != GSSD_INTERFACE_VERSION) {
CERROR("gssd interface version %d (expect %d)\n",
CERROR("no such obd %s\n", obdname);
RETURN(-EINVAL);
}
- if (strcmp(obd->obd_type->typ_name, "mdc") &&
- strcmp(obd->obd_type->typ_name, "osc")) {
- CERROR("%s not a mdc/osc device\n", obdname);
- RETURN(-EINVAL);
- }
imp = class_import_get(obd->u.cli.cl_import);
/* get token */
reqlen = secinit_compose_request(imp, reqbuf, reqbuf_size,
+ param.lustre_svc,
param.uid, param.gid,
param.send_token_size,
param.send_token);
goto out_copy;
}
- replen = repbuf_size;
- rc = ptlrpc_do_rawrpc(imp, reqbuf, reqlen,
- repbuf, &replen, SECINIT_RPC_TIMEOUT);
- if (rc) {
+ request = ptl_do_rawrpc(imp, reqbuf, reqbuf_size, reqlen,
+ repbuf, repbuf_size, &replen,
+ SECINIT_RPC_TIMEOUT, &rc);
+ if (request == NULL || rc) {
param.status = rc;
goto out_copy;
}
rc = 0;
class_import_put(imp);
- if (repbuf)
- OBD_FREE(repbuf, repbuf_size);
- if (reqbuf)
- OBD_FREE(reqbuf, reqbuf_size);
- RETURN(rc);
-}
-
-static int gss_send_secfini_rpc(struct obd_import *imp,
- char *reqbuf, int reqlen)
-{
- const int repbuf_size = 1024;
- char *repbuf;
- int replen = repbuf_size;
- int rc;
-
- OBD_ALLOC(repbuf, repbuf_size);
- if (!repbuf) {
- CERROR("Out of memory\n");
- return -ENOMEM;
+ if (request == NULL) {
+ if (repbuf)
+ OBD_FREE(repbuf, repbuf_size);
+ if (reqbuf)
+ OBD_FREE(reqbuf, reqbuf_size);
+ } else {
+ rawrpc_req_finished(request);
}
-
- rc = ptlrpc_do_rawrpc(imp, reqbuf, reqlen, repbuf, &replen,
- SECFINI_RPC_TIMEOUT);
-
- OBD_FREE(repbuf, repbuf_size);
- return rc;
+ RETURN(rc);
}
/**********************************************
obdtype = import->imp_obd->obd_type->typ_name;
if (!strcmp(obdtype, "mdc"))
- gmd.gum_svc = 0;
+ gmd.gum_svc = LUSTRE_GSS_SVC_MDS;
else if (!strcmp(obdtype, "osc"))
- gmd.gum_svc = 1;
+ gmd.gum_svc = LUSTRE_GSS_SVC_OSS;
else {
CERROR("gss on %s?\n", obdtype);
RETURN(-EINVAL);
struct ptlrpc_request req;
struct obd_import *imp;
__u32 *vp, lmsg_size;
+ struct ptlrpc_request *raw_req = NULL;
+ const int repbuf_len = 256;
+ char *repbuf;
+ int replen, rc;
ENTRY;
/* cred's refcount is 0, steal one */
}
atomic_dec(&cred->pc_refcount);
- /* send out */
- gss_send_secfini_rpc(imp, req.rq_reqbuf, req.rq_reqdata_len);
+ OBD_ALLOC(repbuf, repbuf_len);
+ if (!repbuf)
+ goto exit;
+
+ raw_req = ptl_do_rawrpc(imp, req.rq_reqbuf, req.rq_reqbuf_len,
+ req.rq_reqdata_len, repbuf, repbuf_len, &replen,
+ SECFINI_RPC_TIMEOUT, &rc);
+ if (!raw_req)
+ OBD_FREE(repbuf, repbuf_len);
+
exit:
- OBD_FREE(req.rq_reqbuf, req.rq_reqbuf_len);
+ if (raw_req == NULL)
+ OBD_FREE(req.rq_reqbuf, req.rq_reqbuf_len);
+ else
+ rawrpc_req_finished(raw_req);
EXIT;
}