Whamcloud - gitweb
LU-9019 sec: migrate to 64 bit time
[fs/lustre-release.git] / lustre / include / lustre_sec.h
index 5954292..bad065e 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -51,9 +47,11 @@ struct ptlrpc_request;
 struct ptlrpc_reply_state;
 struct ptlrpc_bulk_desc;
 struct brw_page;
+struct lu_env;
 /* Linux specific */
 struct key;
 struct seq_file;
+struct lustre_cfg;
 
 /*
  * forward declaration
@@ -65,6 +63,7 @@ struct ptlrpc_sec;
 struct ptlrpc_svc_ctx;
 struct ptlrpc_cli_ctx;
 struct ptlrpc_ctx_ops;
+struct req_msg_field;
 
 /**
  * \addtogroup flavor flavor
@@ -181,6 +180,10 @@ enum sptlrpc_bulk_service {
         MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_INTG)
 #define SPTLRPC_SUBFLVR_KRB5P                                           \
         MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_PRIV)
+#define SPTLRPC_SUBFLVR_SKN                                             \
+       MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_SK, SPTLRPC_SVC_NULL)
+#define SPTLRPC_SUBFLVR_SKA                                             \
+       MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_SK, SPTLRPC_SVC_AUTH)
 #define SPTLRPC_SUBFLVR_SKI                                             \
        MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_SK, SPTLRPC_SVC_INTG)
 #define SPTLRPC_SUBFLVR_SKPI                                            \
@@ -231,12 +234,24 @@ enum sptlrpc_bulk_service {
                   SPTLRPC_SVC_PRIV,                     \
                   SPTLRPC_BULK_DEFAULT,                 \
                   SPTLRPC_BULK_SVC_PRIV)
+#define SPTLRPC_FLVR_SKN                                \
+       MAKE_FLVR(SPTLRPC_POLICY_GSS,                   \
+                 SPTLRPC_MECH_GSS_SK,                  \
+                 SPTLRPC_SVC_NULL,                     \
+                 SPTLRPC_BULK_DEFAULT,                 \
+                 SPTLRPC_BULK_SVC_NULL)
+#define SPTLRPC_FLVR_SKA                                \
+       MAKE_FLVR(SPTLRPC_POLICY_GSS,                   \
+                 SPTLRPC_MECH_GSS_SK,                  \
+                 SPTLRPC_SVC_AUTH,                     \
+                 SPTLRPC_BULK_DEFAULT,                 \
+                 SPTLRPC_BULK_SVC_NULL)
 #define SPTLRPC_FLVR_SKI                                \
        MAKE_FLVR(SPTLRPC_POLICY_GSS,                   \
                  SPTLRPC_MECH_GSS_SK,                  \
                  SPTLRPC_SVC_INTG,                     \
                  SPTLRPC_BULK_DEFAULT,                 \
-                 SPTLRPC_BULK_SVC_PRIV)
+                 SPTLRPC_BULK_SVC_INTG)
 #define SPTLRPC_FLVR_SKPI                               \
        MAKE_FLVR(SPTLRPC_POLICY_GSS,                   \
                  SPTLRPC_MECH_GSS_SK,                  \
@@ -373,8 +388,7 @@ void sptlrpc_conf_log_update_begin(const char *logname);
 void sptlrpc_conf_log_update_end(const char *logname);
 void sptlrpc_conf_client_adapt(struct obd_device *obd);
 int  sptlrpc_conf_target_get_rules(struct obd_device *obd,
-                                   struct sptlrpc_rule_set *rset,
-                                   int initial);
+                                  struct sptlrpc_rule_set *rset);
 void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
                                   enum lustre_sec_part from,
                                   lnet_nid_t nid,
@@ -531,17 +545,17 @@ struct ptlrpc_ctx_ops {
                                         PTLRPC_CTX_ERROR)
 
 struct ptlrpc_cli_ctx {
-       cfs_hlist_node_t        cc_cache;      /* linked into ctx cache */
-       atomic_t                cc_refcount;
+       struct hlist_node       cc_cache;       /* linked into ctx cache */
+       atomic_t                cc_refcount;
        struct ptlrpc_sec      *cc_sec;
        struct ptlrpc_ctx_ops  *cc_ops;
-        cfs_time_t              cc_expire;     /* in seconds */
-        unsigned int            cc_early_expire:1;
-        unsigned long           cc_flags;
-        struct vfs_cred         cc_vcred;
+       time64_t                cc_expire;      /* in seconds */
+       unsigned int            cc_early_expire:1;
+       unsigned long           cc_flags;
+       struct vfs_cred         cc_vcred;
        spinlock_t              cc_lock;
-        cfs_list_t              cc_req_list;   /* waiting reqs linked here */
-        cfs_list_t              cc_gc_chain;   /* linked to gc chain */
+       struct list_head        cc_req_list;    /* waiting reqs linked here */
+       struct list_head        cc_gc_chain;    /* linked to gc chain */
 };
 
 /**
@@ -856,14 +870,28 @@ struct ptlrpc_sec {
         struct obd_import              *ps_import;
        spinlock_t                      ps_lock;
 
-        /*
-         * garbage collection
-         */
-        cfs_list_t                      ps_gc_list;
-        cfs_time_t                      ps_gc_interval; /* in seconds */
-        cfs_time_t                      ps_gc_next;     /* in seconds */
+       /*
+        * garbage collection
+        */
+       struct list_head                ps_gc_list;
+       time64_t                        ps_gc_interval; /* in seconds */
+       time64_t                        ps_gc_next;     /* in seconds */
 };
 
+static inline int flvr_is_rootonly(__u32 flavor)
+{
+       return (SPTLRPC_FLVR_POLICY(flavor) == SPTLRPC_POLICY_GSS &&
+               (SPTLRPC_FLVR_MECH(flavor) == SPTLRPC_MECH_GSS_NULL ||
+                SPTLRPC_FLVR_MECH(flavor) == SPTLRPC_MECH_GSS_SK));
+}
+
+static inline int flvr_allows_user_desc(__u32 flavor)
+{
+       return (SPTLRPC_FLVR_POLICY(flavor) == SPTLRPC_POLICY_GSS &&
+               (SPTLRPC_FLVR_MECH(flavor) == SPTLRPC_MECH_GSS_NULL ||
+                SPTLRPC_FLVR_MECH(flavor) == SPTLRPC_MECH_GSS_SK));
+}
+
 static inline int sec_is_reverse(struct ptlrpc_sec *sec)
 {
         return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_REVERSE);
@@ -1057,7 +1085,8 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req);
 int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
 void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req);
 int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
-                               int segment, int newsize);
+                              const struct req_msg_field *field,
+                              int newsize);
 int  sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
                                     struct ptlrpc_request **req_ret);
 void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req);
@@ -1129,6 +1158,8 @@ int sptlrpc_enc_pool_add_user(void);
 int sptlrpc_enc_pool_del_user(void);
 int  sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc);
 void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc);
+int get_free_pages_in_pool(void);
+int pool_is_at_full_capacity(void);
 
 int sptlrpc_cli_wrap_bulk(struct ptlrpc_request *req,
                           struct ptlrpc_bulk_desc *desc);
@@ -1166,13 +1197,6 @@ int sptlrpc_unpack_user_desc(struct lustre_msg *req, int offset, int swabbed);
 #define CFS_CAP_CHOWN_MASK (1 << CFS_CAP_CHOWN)
 #define CFS_CAP_SYS_RESOURCE_MASK (1 << CFS_CAP_SYS_RESOURCE)
 
-enum {
-        LUSTRE_SEC_NONE         = 0,
-        LUSTRE_SEC_REMOTE       = 1,
-        LUSTRE_SEC_SPECIFY      = 2,
-        LUSTRE_SEC_ALL          = 3
-};
-
 /** @} sptlrpc */
 
 #endif /* _LUSTRE_SEC_H_ */