1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef _LUSTRE_SEC_H_
38 #define _LUSTRE_SEC_H_
51 struct ptlrpc_request;
52 struct ptlrpc_reply_state;
53 struct ptlrpc_bulk_desc;
60 struct ptlrpc_sec_policy;
61 struct ptlrpc_sec_cops;
62 struct ptlrpc_sec_sops;
64 struct ptlrpc_svc_ctx;
65 struct ptlrpc_cli_ctx;
66 struct ptlrpc_ctx_ops;
72 SPTLRPC_POLICY_NULL = 0,
73 SPTLRPC_POLICY_PLAIN = 1,
74 SPTLRPC_POLICY_GSS = 2,
78 enum sptlrpc_mech_null {
79 SPTLRPC_MECH_NULL = 0,
80 SPTLRPC_MECH_NULL_MAX,
83 enum sptlrpc_mech_plain {
84 SPTLRPC_MECH_PLAIN = 0,
85 SPTLRPC_MECH_PLAIN_MAX,
88 enum sptlrpc_mech_gss {
89 SPTLRPC_MECH_GSS_NULL = 0,
90 SPTLRPC_MECH_GSS_KRB5 = 1,
94 enum sptlrpc_service_type {
95 SPTLRPC_SVC_NULL = 0, /* no security */
96 SPTLRPC_SVC_AUTH = 1, /* auth only */
97 SPTLRPC_SVC_INTG = 2, /* integrity */
98 SPTLRPC_SVC_PRIV = 3, /* privacy */
102 enum sptlrpc_bulk_type {
103 SPTLRPC_BULK_DEFAULT = 0, /* follow rpc flavor */
104 SPTLRPC_BULK_HASH = 1, /* hash integrity */
108 enum sptlrpc_bulk_service {
109 SPTLRPC_BULK_SVC_NULL = 0,
110 SPTLRPC_BULK_SVC_AUTH = 1,
111 SPTLRPC_BULK_SVC_INTG = 2,
112 SPTLRPC_BULK_SVC_PRIV = 3,
113 SPTLRPC_BULK_SVC_MAX,
117 * rpc flavor compose/extract, represented as 32 bits. currently the
118 * high 12 bits are unused, must be set as 0.
120 * 4b (bulk svc) | 4b (bulk type) | 4b (svc) | 4b (mech) | 4b (policy)
122 #define FLVR_POLICY_OFFSET (0)
123 #define FLVR_MECH_OFFSET (4)
124 #define FLVR_SVC_OFFSET (8)
125 #define FLVR_BULK_TYPE_OFFSET (12)
126 #define FLVR_BULK_SVC_OFFSET (16)
128 #define MAKE_FLVR(policy, mech, svc, btype, bsvc) \
129 (((__u32)(policy) << FLVR_POLICY_OFFSET) | \
130 ((__u32)(mech) << FLVR_MECH_OFFSET) | \
131 ((__u32)(svc) << FLVR_SVC_OFFSET) | \
132 ((__u32)(btype) << FLVR_BULK_TYPE_OFFSET) | \
133 ((__u32)(bsvc) << FLVR_BULK_SVC_OFFSET))
138 #define SPTLRPC_FLVR_POLICY(flavor) \
139 ((((__u32)(flavor)) >> FLVR_POLICY_OFFSET) & 0xF)
140 #define SPTLRPC_FLVR_MECH(flavor) \
141 ((((__u32)(flavor)) >> FLVR_MECH_OFFSET) & 0xF)
142 #define SPTLRPC_FLVR_SVC(flavor) \
143 ((((__u32)(flavor)) >> FLVR_SVC_OFFSET) & 0xF)
144 #define SPTLRPC_FLVR_BULK_TYPE(flavor) \
145 ((((__u32)(flavor)) >> FLVR_BULK_TYPE_OFFSET) & 0xF)
146 #define SPTLRPC_FLVR_BULK_SVC(flavor) \
147 ((((__u32)(flavor)) >> FLVR_BULK_SVC_OFFSET) & 0xF)
149 #define SPTLRPC_FLVR_BASE(flavor) \
150 ((((__u32)(flavor)) >> FLVR_POLICY_OFFSET) & 0xFFF)
151 #define SPTLRPC_FLVR_BASE_SUB(flavor) \
152 ((((__u32)(flavor)) >> FLVR_MECH_OFFSET) & 0xFF)
157 #define MAKE_BASE_SUBFLVR(mech, svc) \
159 ((__u32)(svc) << (FLVR_SVC_OFFSET - FLVR_MECH_OFFSET)))
161 #define SPTLRPC_SUBFLVR_KRB5N \
162 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_NULL)
163 #define SPTLRPC_SUBFLVR_KRB5A \
164 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_AUTH)
165 #define SPTLRPC_SUBFLVR_KRB5I \
166 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_INTG)
167 #define SPTLRPC_SUBFLVR_KRB5P \
168 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_PRIV)
173 #define SPTLRPC_FLVR_NULL \
174 MAKE_FLVR(SPTLRPC_POLICY_NULL, \
177 SPTLRPC_BULK_DEFAULT, \
178 SPTLRPC_BULK_SVC_NULL)
179 #define SPTLRPC_FLVR_PLAIN \
180 MAKE_FLVR(SPTLRPC_POLICY_PLAIN, \
181 SPTLRPC_MECH_PLAIN, \
184 SPTLRPC_BULK_SVC_INTG)
185 #define SPTLRPC_FLVR_KRB5N \
186 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
187 SPTLRPC_MECH_GSS_KRB5, \
189 SPTLRPC_BULK_DEFAULT, \
190 SPTLRPC_BULK_SVC_NULL)
191 #define SPTLRPC_FLVR_KRB5A \
192 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
193 SPTLRPC_MECH_GSS_KRB5, \
195 SPTLRPC_BULK_DEFAULT, \
196 SPTLRPC_BULK_SVC_NULL)
197 #define SPTLRPC_FLVR_KRB5I \
198 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
199 SPTLRPC_MECH_GSS_KRB5, \
201 SPTLRPC_BULK_DEFAULT, \
202 SPTLRPC_BULK_SVC_INTG)
203 #define SPTLRPC_FLVR_KRB5P \
204 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
205 SPTLRPC_MECH_GSS_KRB5, \
207 SPTLRPC_BULK_DEFAULT, \
208 SPTLRPC_BULK_SVC_PRIV)
210 #define SPTLRPC_FLVR_DEFAULT SPTLRPC_FLVR_NULL
212 #define SPTLRPC_FLVR_INVALID ((__u32) 0xFFFFFFFF)
213 #define SPTLRPC_FLVR_ANY ((__u32) 0xFFF00000)
216 * extract the useful part from wire flavor
218 #define WIRE_FLVR(wflvr) (((__u32) (wflvr)) & 0x000FFFFF)
220 static inline void flvr_set_svc(__u32 *flvr, __u32 svc)
222 LASSERT(svc < SPTLRPC_SVC_MAX);
223 *flvr = MAKE_FLVR(SPTLRPC_FLVR_POLICY(*flvr),
224 SPTLRPC_FLVR_MECH(*flvr),
226 SPTLRPC_FLVR_BULK_TYPE(*flvr),
227 SPTLRPC_FLVR_BULK_SVC(*flvr));
230 static inline void flvr_set_bulk_svc(__u32 *flvr, __u32 svc)
232 LASSERT(svc < SPTLRPC_BULK_SVC_MAX);
233 *flvr = MAKE_FLVR(SPTLRPC_FLVR_POLICY(*flvr),
234 SPTLRPC_FLVR_MECH(*flvr),
235 SPTLRPC_FLVR_SVC(*flvr),
236 SPTLRPC_FLVR_BULK_TYPE(*flvr),
240 struct bulk_spec_hash {
244 struct sptlrpc_flavor {
245 __u32 sf_rpc; /* wire flavor - should be renamed to sf_wire */
246 __u32 sf_flags; /* general flags */
248 * rpc flavor specification
251 /* nothing for now */
254 * bulk flavor specification
257 struct bulk_spec_hash hash;
261 enum lustre_sec_part {
270 const char *sptlrpc_part2name(enum lustre_sec_part sp);
271 enum lustre_sec_part sptlrpc_target_sec_part(struct obd_device *obd);
273 struct sptlrpc_rule {
274 __u32 sr_netid; /* LNET network ID */
275 __u8 sr_from; /* sec_part */
276 __u8 sr_to; /* sec_part */
278 struct sptlrpc_flavor sr_flvr;
281 struct sptlrpc_rule_set {
284 struct sptlrpc_rule *srs_rules;
287 int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr);
288 int sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr);
290 static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)
292 memset(set, 0, sizeof(*set));
295 void sptlrpc_rule_set_free(struct sptlrpc_rule_set *set);
296 int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *set);
297 int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *set,
298 struct sptlrpc_rule *rule);
299 int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
300 enum lustre_sec_part from,
301 enum lustre_sec_part to,
303 struct sptlrpc_flavor *sf);
304 void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *set);
306 int sptlrpc_process_config(struct lustre_cfg *lcfg);
307 void sptlrpc_conf_log_start(const char *logname);
308 void sptlrpc_conf_log_stop(const char *logname);
309 void sptlrpc_conf_log_update_begin(const char *logname);
310 void sptlrpc_conf_log_update_end(const char *logname);
311 void sptlrpc_conf_client_adapt(struct obd_device *obd);
312 int sptlrpc_conf_target_get_rules(struct obd_device *obd,
313 struct sptlrpc_rule_set *rset,
315 void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
316 enum lustre_sec_part from,
318 struct sptlrpc_flavor *flavor);
320 /* The maximum length of security payload. 1024 is enough for Kerberos 5,
321 * and should be enough for other future mechanisms but not sure.
322 * Only used by pre-allocated request/reply pool.
324 #define SPTLRPC_MAX_PAYLOAD (1024)
332 struct ptlrpc_ctx_ops {
333 int (*match) (struct ptlrpc_cli_ctx *ctx,
334 struct vfs_cred *vcred);
335 int (*refresh) (struct ptlrpc_cli_ctx *ctx);
336 int (*validate) (struct ptlrpc_cli_ctx *ctx);
337 void (*die) (struct ptlrpc_cli_ctx *ctx,
339 int (*display) (struct ptlrpc_cli_ctx *ctx,
340 char *buf, int bufsize);
344 int (*sign) (struct ptlrpc_cli_ctx *ctx,
345 struct ptlrpc_request *req);
346 int (*verify) (struct ptlrpc_cli_ctx *ctx,
347 struct ptlrpc_request *req);
348 int (*seal) (struct ptlrpc_cli_ctx *ctx,
349 struct ptlrpc_request *req);
350 int (*unseal) (struct ptlrpc_cli_ctx *ctx,
351 struct ptlrpc_request *req);
355 int (*wrap_bulk) (struct ptlrpc_cli_ctx *ctx,
356 struct ptlrpc_request *req,
357 struct ptlrpc_bulk_desc *desc);
358 int (*unwrap_bulk) (struct ptlrpc_cli_ctx *ctx,
359 struct ptlrpc_request *req,
360 struct ptlrpc_bulk_desc *desc);
363 #define PTLRPC_CTX_NEW_BIT (0) /* newly created */
364 #define PTLRPC_CTX_UPTODATE_BIT (1) /* uptodate */
365 #define PTLRPC_CTX_DEAD_BIT (2) /* mark expired gracefully */
366 #define PTLRPC_CTX_ERROR_BIT (3) /* fatal error (refresh, etc.) */
367 #define PTLRPC_CTX_CACHED_BIT (8) /* in ctx cache (hash etc.) */
368 #define PTLRPC_CTX_ETERNAL_BIT (9) /* always valid */
370 #define PTLRPC_CTX_NEW (1 << PTLRPC_CTX_NEW_BIT)
371 #define PTLRPC_CTX_UPTODATE (1 << PTLRPC_CTX_UPTODATE_BIT)
372 #define PTLRPC_CTX_DEAD (1 << PTLRPC_CTX_DEAD_BIT)
373 #define PTLRPC_CTX_ERROR (1 << PTLRPC_CTX_ERROR_BIT)
374 #define PTLRPC_CTX_CACHED (1 << PTLRPC_CTX_CACHED_BIT)
375 #define PTLRPC_CTX_ETERNAL (1 << PTLRPC_CTX_ETERNAL_BIT)
377 #define PTLRPC_CTX_STATUS_MASK (PTLRPC_CTX_NEW_BIT | \
378 PTLRPC_CTX_UPTODATE | \
382 struct ptlrpc_cli_ctx {
383 cfs_hlist_node_t cc_cache; /* linked into ctx cache */
384 cfs_atomic_t cc_refcount;
385 struct ptlrpc_sec *cc_sec;
386 struct ptlrpc_ctx_ops *cc_ops;
387 cfs_time_t cc_expire; /* in seconds */
388 unsigned int cc_early_expire:1;
389 unsigned long cc_flags;
390 struct vfs_cred cc_vcred;
391 cfs_spinlock_t cc_lock;
392 cfs_list_t cc_req_list; /* waiting reqs linked here */
393 cfs_list_t cc_gc_chain; /* linked to gc chain */
396 struct ptlrpc_sec_cops {
398 * ptlrpc_sec constructor/destructor
400 struct ptlrpc_sec * (*create_sec) (struct obd_import *imp,
401 struct ptlrpc_svc_ctx *ctx,
402 struct sptlrpc_flavor *flavor);
403 void (*destroy_sec) (struct ptlrpc_sec *sec);
408 void (*kill_sec) (struct ptlrpc_sec *sec);
413 struct ptlrpc_cli_ctx * (*lookup_ctx) (struct ptlrpc_sec *sec,
414 struct vfs_cred *vcred,
417 void (*release_ctx) (struct ptlrpc_sec *sec,
418 struct ptlrpc_cli_ctx *ctx,
420 int (*flush_ctx_cache)
421 (struct ptlrpc_sec *sec,
425 void (*gc_ctx) (struct ptlrpc_sec *sec);
430 int (*install_rctx)(struct obd_import *imp,
431 struct ptlrpc_sec *sec,
432 struct ptlrpc_cli_ctx *ctx);
435 * request/reply buffer manipulation
437 int (*alloc_reqbuf)(struct ptlrpc_sec *sec,
438 struct ptlrpc_request *req,
439 int lustre_msg_size);
440 void (*free_reqbuf) (struct ptlrpc_sec *sec,
441 struct ptlrpc_request *req);
442 int (*alloc_repbuf)(struct ptlrpc_sec *sec,
443 struct ptlrpc_request *req,
444 int lustre_msg_size);
445 void (*free_repbuf) (struct ptlrpc_sec *sec,
446 struct ptlrpc_request *req);
447 int (*enlarge_reqbuf)
448 (struct ptlrpc_sec *sec,
449 struct ptlrpc_request *req,
450 int segment, int newsize);
454 int (*display) (struct ptlrpc_sec *sec,
455 struct seq_file *seq);
458 struct ptlrpc_sec_sops {
459 int (*accept) (struct ptlrpc_request *req);
460 int (*authorize) (struct ptlrpc_request *req);
461 void (*invalidate_ctx)
462 (struct ptlrpc_svc_ctx *ctx);
463 /* buffer manipulation */
464 int (*alloc_rs) (struct ptlrpc_request *req,
466 void (*free_rs) (struct ptlrpc_reply_state *rs);
467 void (*free_ctx) (struct ptlrpc_svc_ctx *ctx);
468 /* reverse context */
469 int (*install_rctx)(struct obd_import *imp,
470 struct ptlrpc_svc_ctx *ctx);
472 int (*prep_bulk) (struct ptlrpc_request *req,
473 struct ptlrpc_bulk_desc *desc);
474 int (*unwrap_bulk) (struct ptlrpc_request *req,
475 struct ptlrpc_bulk_desc *desc);
476 int (*wrap_bulk) (struct ptlrpc_request *req,
477 struct ptlrpc_bulk_desc *desc);
480 struct ptlrpc_sec_policy {
481 cfs_module_t *sp_owner;
483 __u16 sp_policy; /* policy number */
484 struct ptlrpc_sec_cops *sp_cops; /* client ops */
485 struct ptlrpc_sec_sops *sp_sops; /* server ops */
488 #define PTLRPC_SEC_FL_REVERSE 0x0001 /* reverse sec */
489 #define PTLRPC_SEC_FL_ROOTONLY 0x0002 /* treat everyone as root */
490 #define PTLRPC_SEC_FL_UDESC 0x0004 /* ship udesc */
491 #define PTLRPC_SEC_FL_BULK 0x0008 /* intensive bulk i/o expected */
492 #define PTLRPC_SEC_FL_PAG 0x0010 /* PAG mode */
495 struct ptlrpc_sec_policy *ps_policy;
496 cfs_atomic_t ps_refcount;
497 cfs_atomic_t ps_nctx; /* statistic only */
498 int ps_id; /* unique identifier */
499 struct sptlrpc_flavor ps_flvr; /* flavor */
500 enum lustre_sec_part ps_part;
501 unsigned int ps_dying:1;
502 struct obd_import *ps_import; /* owning import */
503 cfs_spinlock_t ps_lock; /* protect ccache */
507 cfs_list_t ps_gc_list;
508 cfs_time_t ps_gc_interval; /* in seconds */
509 cfs_time_t ps_gc_next; /* in seconds */
512 static inline int sec_is_reverse(struct ptlrpc_sec *sec)
514 return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_REVERSE);
517 static inline int sec_is_rootonly(struct ptlrpc_sec *sec)
519 return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_ROOTONLY);
523 struct ptlrpc_svc_ctx {
524 cfs_atomic_t sc_refcount;
525 struct ptlrpc_sec_policy *sc_policy;
529 * user identity descriptor
531 #define LUSTRE_MAX_GROUPS (128)
533 struct ptlrpc_user_desc {
546 enum sptlrpc_bulk_hash_alg {
547 BULK_HASH_ALG_NULL = 0,
548 BULK_HASH_ALG_ADLER32,
552 BULK_HASH_ALG_SHA256,
553 BULK_HASH_ALG_SHA384,
554 BULK_HASH_ALG_SHA512,
558 struct sptlrpc_hash_type {
561 unsigned int sht_size;
564 const struct sptlrpc_hash_type *sptlrpc_get_hash_type(__u8 hash_alg);
565 const char * sptlrpc_get_hash_name(__u8 hash_alg);
566 __u8 sptlrpc_get_hash_alg(const char *algname);
572 struct ptlrpc_bulk_sec_desc {
573 __u8 bsd_version; /* 0 */
574 __u8 bsd_type; /* SPTLRPC_BULK_XXX */
575 __u8 bsd_svc; /* SPTLRPC_BULK_SVC_XXXX */
576 __u8 bsd_flags; /* flags */
577 __u32 bsd_nob; /* nob of bulk data */
578 __u8 bsd_data[0]; /* policy-specific token */
585 struct proc_dir_entry;
586 extern struct proc_dir_entry *sptlrpc_proc_root;
589 * round size up to next power of 2, for slab allocation.
590 * @size must be sane (can't overflow after round up)
592 static inline int size_roundup_power2(int size)
605 * internal support libraries
607 void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg,
608 int segment, int newsize);
613 int sptlrpc_register_policy(struct ptlrpc_sec_policy *policy);
614 int sptlrpc_unregister_policy(struct ptlrpc_sec_policy *policy);
616 __u32 sptlrpc_name2flavor_base(const char *name);
617 const char *sptlrpc_flavor2name_base(__u32 flvr);
618 char *sptlrpc_flavor2name_bulk(struct sptlrpc_flavor *sf,
619 char *buf, int bufsize);
620 char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize);
621 char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize);
624 struct ptlrpc_sec_policy *sptlrpc_policy_get(struct ptlrpc_sec_policy *policy)
626 __cfs_module_get(policy->sp_owner);
631 void sptlrpc_policy_put(struct ptlrpc_sec_policy *policy)
633 cfs_module_put(policy->sp_owner);
640 unsigned long cli_ctx_status(struct ptlrpc_cli_ctx *ctx)
642 return (ctx->cc_flags & PTLRPC_CTX_STATUS_MASK);
646 int cli_ctx_is_ready(struct ptlrpc_cli_ctx *ctx)
648 return (cli_ctx_status(ctx) == PTLRPC_CTX_UPTODATE);
652 int cli_ctx_is_refreshed(struct ptlrpc_cli_ctx *ctx)
654 return (cli_ctx_status(ctx) != 0);
658 int cli_ctx_is_uptodate(struct ptlrpc_cli_ctx *ctx)
660 return ((ctx->cc_flags & PTLRPC_CTX_UPTODATE) != 0);
664 int cli_ctx_is_error(struct ptlrpc_cli_ctx *ctx)
666 return ((ctx->cc_flags & PTLRPC_CTX_ERROR) != 0);
670 int cli_ctx_is_dead(struct ptlrpc_cli_ctx *ctx)
672 return ((ctx->cc_flags & (PTLRPC_CTX_DEAD | PTLRPC_CTX_ERROR)) != 0);
676 int cli_ctx_is_eternal(struct ptlrpc_cli_ctx *ctx)
678 return ((ctx->cc_flags & PTLRPC_CTX_ETERNAL) != 0);
684 struct ptlrpc_sec *sptlrpc_sec_get(struct ptlrpc_sec *sec);
685 void sptlrpc_sec_put(struct ptlrpc_sec *sec);
688 * internal apis which only used by policy impelentation
690 int sptlrpc_get_next_secid(void);
691 void sptlrpc_sec_destroy(struct ptlrpc_sec *sec);
694 * exported client context api
696 struct ptlrpc_cli_ctx *sptlrpc_cli_ctx_get(struct ptlrpc_cli_ctx *ctx);
697 void sptlrpc_cli_ctx_put(struct ptlrpc_cli_ctx *ctx, int sync);
698 void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx);
699 void sptlrpc_cli_ctx_wakeup(struct ptlrpc_cli_ctx *ctx);
700 int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize);
703 * exported client context wrap/buffers
705 int sptlrpc_cli_wrap_request(struct ptlrpc_request *req);
706 int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req);
707 int sptlrpc_cli_alloc_reqbuf(struct ptlrpc_request *req, int msgsize);
708 void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req);
709 int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
710 void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req);
711 int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
712 int segment, int newsize);
713 int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
714 struct ptlrpc_request **req_ret);
715 void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req);
717 void sptlrpc_request_out_callback(struct ptlrpc_request *req);
720 * exported higher interface of import & request
722 int sptlrpc_import_sec_adapt(struct obd_import *imp,
723 struct ptlrpc_svc_ctx *ctx,
724 struct sptlrpc_flavor *flvr);
725 struct ptlrpc_sec *sptlrpc_import_sec_ref(struct obd_import *imp);
726 void sptlrpc_import_sec_put(struct obd_import *imp);
728 int sptlrpc_import_check_ctx(struct obd_import *imp);
729 void sptlrpc_import_flush_root_ctx(struct obd_import *imp);
730 void sptlrpc_import_flush_my_ctx(struct obd_import *imp);
731 void sptlrpc_import_flush_all_ctx(struct obd_import *imp);
732 int sptlrpc_req_get_ctx(struct ptlrpc_request *req);
733 void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync);
734 int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout);
735 int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req);
736 void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode);
738 int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule);
741 void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec);
742 void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec);
743 void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx);
746 const char * sec2target_str(struct ptlrpc_sec *sec);
747 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev);
752 enum secsvc_accept_res {
758 int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req);
759 int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen);
760 int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req);
761 void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs);
762 void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req);
763 void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req);
764 void sptlrpc_svc_ctx_invalidate(struct ptlrpc_request *req);
766 int sptlrpc_target_export_check(struct obd_export *exp,
767 struct ptlrpc_request *req);
768 void sptlrpc_target_update_exp_flavor(struct obd_device *obd,
769 struct sptlrpc_rule_set *rset);
774 int sptlrpc_svc_install_rvs_ctx(struct obd_import *imp,
775 struct ptlrpc_svc_ctx *ctx);
776 int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp,
777 struct ptlrpc_cli_ctx *ctx);
779 /* bulk security api */
780 int sptlrpc_enc_pool_add_user(void);
781 int sptlrpc_enc_pool_del_user(void);
782 int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc);
783 void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc);
785 int sptlrpc_cli_wrap_bulk(struct ptlrpc_request *req,
786 struct ptlrpc_bulk_desc *desc);
787 int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req,
788 struct ptlrpc_bulk_desc *desc,
790 int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
791 struct ptlrpc_bulk_desc *desc);
792 int sptlrpc_svc_prep_bulk(struct ptlrpc_request *req,
793 struct ptlrpc_bulk_desc *desc);
794 int sptlrpc_svc_wrap_bulk(struct ptlrpc_request *req,
795 struct ptlrpc_bulk_desc *desc);
796 int sptlrpc_svc_unwrap_bulk(struct ptlrpc_request *req,
797 struct ptlrpc_bulk_desc *desc);
799 /* bulk helpers (internal use only by policies) */
800 int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
801 void *buf, int buflen);
803 int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed);
805 /* user descriptor helpers */
806 static inline int sptlrpc_user_desc_size(int ngroups)
808 return sizeof(struct ptlrpc_user_desc) + ngroups * sizeof(__u32);
811 int sptlrpc_current_user_desc_size(void);
812 int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset);
813 int sptlrpc_unpack_user_desc(struct lustre_msg *req, int offset, int swabbed);
816 #define CFS_CAP_CHOWN_MASK (1 << CFS_CAP_CHOWN)
817 #define CFS_CAP_SYS_RESOURCE_MASK (1 << CFS_CAP_SYS_RESOURCE)
821 LUSTRE_SEC_REMOTE = 1,
822 LUSTRE_SEC_SPECIFY = 2,
828 #endif /* _LUSTRE_SEC_H_ */