Whamcloud - gitweb
LU-9859 lustre: remove current_pid() and current_comm()
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_internal.h
index 1bf23ed..39c2e8d 100644 (file)
@@ -12,6 +12,7 @@
 #define __PTLRPC_GSS_GSS_INTERNAL_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;
 }
 
 /*
@@ -117,25 +117,32 @@ enum ptlrpc_gss_tgt {
 };
 
 enum ptlrpc_gss_header_flags {
-        LUSTRE_GSS_PACK_BULK            = 1,
-        LUSTRE_GSS_PACK_USER            = 2,
+       LUSTRE_GSS_PACK_BULK            = 1,
+       LUSTRE_GSS_PACK_USER            = 2,
+       LUSTRE_GSS_PACK_KCSUM           = 4,
 };
 
 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;
+       }
 }
 
 /*
@@ -280,9 +287,9 @@ struct gss_cli_ctx {
 };
 
 struct gss_cli_ctx_keyring {
-        struct gss_cli_ctx      gck_base;
-        struct key             *gck_key;
-        struct timer_list      *gck_timer;
+       struct gss_cli_ctx      gck_base;
+       struct key             *gck_key;
+       struct timer_list       gck_timer;
 };
 
 struct gss_sec {
@@ -351,6 +358,14 @@ static inline struct gss_sec_keyring *sec2gsec_keyring(struct ptlrpc_sec *sec)
         return container_of(sec2gsec(sec), struct gss_sec_keyring, gsk_base);
 }
 
+#ifdef HAVE_CACHE_HASH_SPINLOCK
+# define sunrpc_cache_lookup(c, i, h) sunrpc_cache_lookup_rcu((c), (i), (h))
+# define cache_read_lock(cdetail)   spin_lock(&((cdetail)->hash_lock))
+# define cache_read_unlock(cdetail) spin_unlock(&((cdetail)->hash_lock))
+#else /* ! HAVE_CACHE_HASH_SPINLOCK */
+# define cache_read_lock(cdetail)   read_lock(&((cdetail)->hash_lock))
+# define cache_read_unlock(cdetail) read_unlock(&((cdetail)->hash_lock))
+#endif
 
 #define GSS_CTX_INIT_MAX_LEN            (1024)
 
@@ -503,13 +518,14 @@ void gss_svc_upcall_destroy_ctx(struct gss_svc_ctx *ctx);
 
 int  __init gss_init_svc_upcall(void);
 void gss_exit_svc_upcall(void);
+extern unsigned int krb5_allow_old_client_csum;
 
 /* lproc_gss.c */
 void gss_stat_oos_record_cli(int behind);
 void gss_stat_oos_record_svc(int phase, int replay);
 
-int  __init gss_init_lproc(void);
-void gss_exit_lproc(void);
+int  __init gss_init_tunables(void);
+void gss_exit_tunables(void);
 
 /* gss_null_mech.c */
 int __init init_null_module(void);
@@ -548,4 +564,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_ */