Whamcloud - gitweb
LU-9795 gss: fix gss-based integrity check for multi-rail
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_svc_upcall.c
index 41737a3..4b2d927 100644 (file)
@@ -298,7 +298,6 @@ static struct cache_head *rsi_alloc(void)
 static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen)
 {
         char           *buf = mesg;
-        char           *ep;
         int             len;
         struct rsi      rsii, *rsip = NULL;
         time_t          expiry;
@@ -340,18 +339,21 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen)
         if (len <= 0)
                 goto out;
 
-        /* major */
-        rsii.major_status = simple_strtol(buf, &ep, 10);
-        if (*ep)
-                goto out;
+       /* major */
+       status = kstrtoint(buf, 10, &rsii.major_status);
+       if (status)
+               goto out;
 
-        /* minor */
-        len = qword_get(&mesg, buf, mlen);
-        if (len <= 0)
-                goto out;
-        rsii.minor_status = simple_strtol(buf, &ep, 10);
-        if (*ep)
-                goto out;
+       /* minor */
+       len = qword_get(&mesg, buf, mlen);
+       if (len <= 0) {
+               status = -EINVAL;
+               goto out;
+       }
+
+       status = kstrtoint(buf, 10, &rsii.minor_status);
+       if (status)
+               goto out;
 
         /* out_handle */
         len = qword_get(&mesg, buf, mlen);
@@ -648,8 +650,7 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen)
                /* currently the expiry time passed down from user-space
                 * is invalid, here we retrive it from mech.
                 */
-               if (lgss_inquire_context(rsci.ctx.gsc_mechctx,
-                                        (unsigned long *)&ctx_expiry)) {
+               if (lgss_inquire_context(rsci.ctx.gsc_mechctx, &ctx_expiry)) {
                        CERROR("unable to get expire time, drop it\n");
                        goto out;
                }
@@ -821,7 +822,7 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp,
                                    struct gss_cli_ctx *gctx)
 {
         struct rsc      rsci, *rscp = NULL;
-        unsigned long   ctx_expiry;
+       time64_t ctx_expiry;
         __u32           major;
         int             rc;
         ENTRY;
@@ -883,15 +884,15 @@ out:
 
 int gss_svc_upcall_expire_rvs_ctx(rawobj_t *handle)
 {
-        const cfs_time_t        expire = 20;
-        struct rsc             *rscp;
+       const time64_t expire = 20;
+       struct rsc *rscp;
 
         rscp = gss_svc_searchbyctx(handle);
         if (rscp) {
                 CDEBUG(D_SEC, "reverse svcctx %p (rsc %p) expire soon\n",
                        &rscp->ctx, rscp);
 
-                rscp->h.expiry_time = cfs_time_current_sec() + expire;
+               rscp->h.expiry_time = ktime_get_real_seconds() + expire;
                 COMPAT_RSC_PUT(&rscp->h, &rsc_cache);
         }
         return 0;
@@ -936,7 +937,7 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req,
        struct ptlrpc_reply_state *rs;
        struct rsc                *rsci = NULL;
        struct rsi                *rsip = NULL, rsikey;
-       wait_queue_t             wait;
+       wait_queue_entry_t wait;
        int                        replen = sizeof(struct ptlrpc_body);
        struct gss_rep_header     *rephdr;
        int                        first_check = 1;
@@ -945,7 +946,11 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req,
 
        memset(&rsikey, 0, sizeof(rsikey));
        rsikey.lustre_svc = lustre_svc;
-       rsikey.nid = (__u64) req->rq_peer.nid;
+       /* In case of MR, rq_peer is not the NID from which request is received,
+        * but primary NID of peer.
+        * So we need rq_source, which contains the NID actually in use.
+        */
+       rsikey.nid = (__u64) req->rq_source.nid;
        nodemap_test_nid(req->rq_peer.nid, rsikey.nm_name,
                         sizeof(rsikey.nm_name));
 
@@ -1171,13 +1176,14 @@ int __init gss_init_svc_upcall(void)
        /* FIXME this looks stupid. we intend to give lsvcgssd a chance to open
         * the init upcall channel, otherwise there's big chance that the first
         * upcall issued before the channel be opened thus nfsv4 cache code will
-        * drop the request direclty, thus lead to unnecessary recovery time.
-        * here we wait at miximum 1.5 seconds. */
+        * drop the request directly, thus lead to unnecessary recovery time.
+        * Here we wait at minimum 1.5 seconds.
+        */
        for (i = 0; i < 6; i++) {
                if (atomic_read(&rsi_cache.readers) > 0)
                        break;
                set_current_state(TASK_UNINTERRUPTIBLE);
-               LASSERT(msecs_to_jiffies(MSEC_PER_SEC) >= 4);
+               LASSERT(msecs_to_jiffies(MSEC_PER_SEC / 4) > 0);
                schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC / 4));
        }