Whamcloud - gitweb
LU-8602 gss: Properly port gss to newer crypto api.
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_internal.h
index 65fc5f8..f0b9d28 100644 (file)
@@ -11,7 +11,8 @@
 #ifndef __PTLRPC_GSS_GSS_INTERNAL_H_
 #define __PTLRPC_GSS_GSS_INTERNAL_H_
 
-#include <linux/crypto.h>
+#include <crypto/hash.h>
+#include <libcfs/libcfs_crypto.h>
 #include <lustre_sec.h>
 
 /*
@@ -72,17 +73,16 @@ int buffer_extract_bytes(const void **buf, __u32 *buflen,
  */
 #define GSS_GC_INTERVAL                 (60 * 60) /* 60 minutes */
 
-static inline
-unsigned long gss_round_ctx_expiry(unsigned long expiry,
-                                   unsigned long sec_flags)
+static inline time64_t gss_round_ctx_expiry(time64_t expiry,
+                                           unsigned long sec_flags)
 {
-        if (sec_flags & PTLRPC_SEC_FL_REVERSE)
-                return expiry;
+       if (sec_flags & PTLRPC_SEC_FL_REVERSE)
+               return expiry;
 
-        if (get_seconds() + __TIMEOUT_DELTA <= expiry)
-                return expiry - __TIMEOUT_DELTA;
+       if (ktime_get_real_seconds() + __TIMEOUT_DELTA <= expiry)
+               return expiry - __TIMEOUT_DELTA;
 
-        return expiry;
+       return expiry;
 }
 
 /*
@@ -124,18 +124,24 @@ enum ptlrpc_gss_header_flags {
 static inline
 __u32 import_to_gss_svc(struct obd_import *imp)
 {
-       const char *name = imp->imp_obd->obd_type->typ_name;
+       int cl_sp_to = LUSTRE_SP_ANY;
 
-       if (!strcmp(name, LUSTRE_MGC_NAME))
-               return LUSTRE_GSS_TGT_MGS;
-       if (!strcmp(name, LUSTRE_MDC_NAME) ||
-           !strcmp(name, LUSTRE_LWP_NAME))
+       if (imp->imp_obd)
+               cl_sp_to = imp->imp_obd->u.cli.cl_sp_to;
+
+       switch (cl_sp_to) {
+       case LUSTRE_SP_MDT:
                return LUSTRE_GSS_TGT_MDS;
-       if (!strcmp(name, LUSTRE_OSC_NAME) ||
-           !strcmp(name, LUSTRE_OSP_NAME))
+       case LUSTRE_SP_OST:
                return LUSTRE_GSS_TGT_OSS;
-
-       return 0;
+       case LUSTRE_SP_MGC:
+       case LUSTRE_SP_MGS:
+               return LUSTRE_GSS_TGT_MGS;
+       case LUSTRE_SP_CLI:
+       case LUSTRE_SP_ANY:
+       default:
+               return 0;
+       }
 }
 
 /*
@@ -548,4 +554,13 @@ void __dbg_memdump(char *name, void *ptr, int size)
         OBD_FREE(buf, bufsize);
 }
 
+static inline unsigned int ll_read_key_usage(struct key *key)
+{
+#ifdef HAVE_KEY_USAGE_REFCOUNT
+       return refcount_read(&key->usage);
+#else
+       return atomic_read(&key->usage);
+#endif
+}
+
 #endif /* __PTLRPC_GSS_GSS_INTERNAL_H_ */