1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef _LUSTRE_SEC_H_
38#define _LUSTRE_SEC_H_
39
40
41
42
43
44
45
46
47
48struct obd_import;
49struct obd_export;
50struct ptlrpc_request;
51struct ptlrpc_reply_state;
52struct ptlrpc_bulk_desc;
53struct brw_page;
54
55struct key;
56struct seq_file;
57
58
59
60
61struct ptlrpc_sec_policy;
62struct ptlrpc_sec_cops;
63struct ptlrpc_sec_sops;
64struct ptlrpc_sec;
65struct ptlrpc_svc_ctx;
66struct ptlrpc_cli_ctx;
67struct ptlrpc_ctx_ops;
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86enum sptlrpc_policy {
87 SPTLRPC_POLICY_NULL = 0,
88 SPTLRPC_POLICY_PLAIN = 1,
89 SPTLRPC_POLICY_GSS = 2,
90 SPTLRPC_POLICY_MAX,
91};
92
93enum sptlrpc_mech_null {
94 SPTLRPC_MECH_NULL = 0,
95 SPTLRPC_MECH_NULL_MAX,
96};
97
98enum sptlrpc_mech_plain {
99 SPTLRPC_MECH_PLAIN = 0,
100 SPTLRPC_MECH_PLAIN_MAX,
101};
102
103enum sptlrpc_mech_gss {
104 SPTLRPC_MECH_GSS_NULL = 0,
105 SPTLRPC_MECH_GSS_KRB5 = 1,
106 SPTLRPC_MECH_GSS_MAX,
107};
108
109enum sptlrpc_service_type {
110 SPTLRPC_SVC_NULL = 0,
111 SPTLRPC_SVC_AUTH = 1,
112 SPTLRPC_SVC_INTG = 2,
113 SPTLRPC_SVC_PRIV = 3,
114 SPTLRPC_SVC_MAX,
115};
116
117enum sptlrpc_bulk_type {
118 SPTLRPC_BULK_DEFAULT = 0,
119 SPTLRPC_BULK_HASH = 1,
120 SPTLRPC_BULK_MAX,
121};
122
123enum sptlrpc_bulk_service {
124 SPTLRPC_BULK_SVC_NULL = 0,
125 SPTLRPC_BULK_SVC_AUTH = 1,
126 SPTLRPC_BULK_SVC_INTG = 2,
127 SPTLRPC_BULK_SVC_PRIV = 3,
128 SPTLRPC_BULK_SVC_MAX,
129};
130
131
132
133
134#define FLVR_POLICY_OFFSET (0)
135#define FLVR_MECH_OFFSET (4)
136#define FLVR_SVC_OFFSET (8)
137#define FLVR_BULK_TYPE_OFFSET (12)
138#define FLVR_BULK_SVC_OFFSET (16)
139
140#define MAKE_FLVR(policy, mech, svc, btype, bsvc) \
141 (((__u32)(policy) << FLVR_POLICY_OFFSET) | \
142 ((__u32)(mech) << FLVR_MECH_OFFSET) | \
143 ((__u32)(svc) << FLVR_SVC_OFFSET) | \
144 ((__u32)(btype) << FLVR_BULK_TYPE_OFFSET) | \
145 ((__u32)(bsvc) << FLVR_BULK_SVC_OFFSET))
146
147
148
149
150#define SPTLRPC_FLVR_POLICY(flavor) \
151 ((((__u32)(flavor)) >> FLVR_POLICY_OFFSET) & 0xF)
152#define SPTLRPC_FLVR_MECH(flavor) \
153 ((((__u32)(flavor)) >> FLVR_MECH_OFFSET) & 0xF)
154#define SPTLRPC_FLVR_SVC(flavor) \
155 ((((__u32)(flavor)) >> FLVR_SVC_OFFSET) & 0xF)
156#define SPTLRPC_FLVR_BULK_TYPE(flavor) \
157 ((((__u32)(flavor)) >> FLVR_BULK_TYPE_OFFSET) & 0xF)
158#define SPTLRPC_FLVR_BULK_SVC(flavor) \
159 ((((__u32)(flavor)) >> FLVR_BULK_SVC_OFFSET) & 0xF)
160
161#define SPTLRPC_FLVR_BASE(flavor) \
162 ((((__u32)(flavor)) >> FLVR_POLICY_OFFSET) & 0xFFF)
163#define SPTLRPC_FLVR_BASE_SUB(flavor) \
164 ((((__u32)(flavor)) >> FLVR_MECH_OFFSET) & 0xFF)
165
166
167
168
169#define MAKE_BASE_SUBFLVR(mech, svc) \
170 ((__u32)(mech) | \
171 ((__u32)(svc) << (FLVR_SVC_OFFSET - FLVR_MECH_OFFSET)))
172
173#define SPTLRPC_SUBFLVR_KRB5N \
174 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_NULL)
175#define SPTLRPC_SUBFLVR_KRB5A \
176 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_AUTH)
177#define SPTLRPC_SUBFLVR_KRB5I \
178 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_INTG)
179#define SPTLRPC_SUBFLVR_KRB5P \
180 MAKE_BASE_SUBFLVR(SPTLRPC_MECH_GSS_KRB5, SPTLRPC_SVC_PRIV)
181
182
183
184
185#define SPTLRPC_FLVR_NULL \
186 MAKE_FLVR(SPTLRPC_POLICY_NULL, \
187 SPTLRPC_MECH_NULL, \
188 SPTLRPC_SVC_NULL, \
189 SPTLRPC_BULK_DEFAULT, \
190 SPTLRPC_BULK_SVC_NULL)
191#define SPTLRPC_FLVR_PLAIN \
192 MAKE_FLVR(SPTLRPC_POLICY_PLAIN, \
193 SPTLRPC_MECH_PLAIN, \
194 SPTLRPC_SVC_NULL, \
195 SPTLRPC_BULK_HASH, \
196 SPTLRPC_BULK_SVC_INTG)
197#define SPTLRPC_FLVR_KRB5N \
198 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
199 SPTLRPC_MECH_GSS_KRB5, \
200 SPTLRPC_SVC_NULL, \
201 SPTLRPC_BULK_DEFAULT, \
202 SPTLRPC_BULK_SVC_NULL)
203#define SPTLRPC_FLVR_KRB5A \
204 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
205 SPTLRPC_MECH_GSS_KRB5, \
206 SPTLRPC_SVC_AUTH, \
207 SPTLRPC_BULK_DEFAULT, \
208 SPTLRPC_BULK_SVC_NULL)
209#define SPTLRPC_FLVR_KRB5I \
210 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
211 SPTLRPC_MECH_GSS_KRB5, \
212 SPTLRPC_SVC_INTG, \
213 SPTLRPC_BULK_DEFAULT, \
214 SPTLRPC_BULK_SVC_INTG)
215#define SPTLRPC_FLVR_KRB5P \
216 MAKE_FLVR(SPTLRPC_POLICY_GSS, \
217 SPTLRPC_MECH_GSS_KRB5, \
218 SPTLRPC_SVC_PRIV, \
219 SPTLRPC_BULK_DEFAULT, \
220 SPTLRPC_BULK_SVC_PRIV)
221
222#define SPTLRPC_FLVR_DEFAULT SPTLRPC_FLVR_NULL
223
224#define SPTLRPC_FLVR_INVALID ((__u32) 0xFFFFFFFF)
225#define SPTLRPC_FLVR_ANY ((__u32) 0xFFF00000)
226
227
228
229
230#define WIRE_FLVR(wflvr) (((__u32) (wflvr)) & 0x000FFFFF)
231
232
233
234static inline void flvr_set_svc(__u32 *flvr, __u32 svc)
235{
236 LASSERT(svc < SPTLRPC_SVC_MAX);
237 *flvr = MAKE_FLVR(SPTLRPC_FLVR_POLICY(*flvr),
238 SPTLRPC_FLVR_MECH(*flvr),
239 svc,
240 SPTLRPC_FLVR_BULK_TYPE(*flvr),
241 SPTLRPC_FLVR_BULK_SVC(*flvr));
242}
243
244static inline void flvr_set_bulk_svc(__u32 *flvr, __u32 svc)
245{
246 LASSERT(svc < SPTLRPC_BULK_SVC_MAX);
247 *flvr = MAKE_FLVR(SPTLRPC_FLVR_POLICY(*flvr),
248 SPTLRPC_FLVR_MECH(*flvr),
249 SPTLRPC_FLVR_SVC(*flvr),
250 SPTLRPC_FLVR_BULK_TYPE(*flvr),
251 svc);
252}
253
254struct bulk_spec_hash {
255 __u8 hash_alg;
256};
257
258
259
260
261
262struct sptlrpc_flavor {
263
264
265
266 __u32 sf_rpc;
267
268
269
270 __u32 sf_flags;
271
272
273
274 union {
275
276 } u_rpc;
277
278
279
280 union {
281 struct bulk_spec_hash hash;
282 } u_bulk;
283};
284
285
286
287
288
289enum lustre_sec_part {
290 LUSTRE_SP_CLI = 0,
291 LUSTRE_SP_MDT,
292 LUSTRE_SP_OST,
293 LUSTRE_SP_MGC,
294 LUSTRE_SP_MGS,
295 LUSTRE_SP_ANY = 0xFF
296};
297
298const char *sptlrpc_part2name(enum lustre_sec_part sp);
299enum lustre_sec_part sptlrpc_target_sec_part(struct obd_device *obd);
300
301
302
303
304
305struct sptlrpc_rule {
306 __u32 sr_netid;
307 __u8 sr_from;
308 __u8 sr_to;
309 __u16 sr_padding;
310 struct sptlrpc_flavor sr_flvr;
311};
312
313
314
315
316
317
318
319struct sptlrpc_rule_set {
320 int srs_nslot;
321 int srs_nrule;
322 struct sptlrpc_rule *srs_rules;
323};
324
325int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr);
326int sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr);
327
328static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)
329{
330 memset(set, 0, sizeof(*set));
331}
332
333void sptlrpc_rule_set_free(struct sptlrpc_rule_set *set);
334int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *set);
335int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *set,
336 struct sptlrpc_rule *rule);
337int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
338 enum lustre_sec_part from,
339 enum lustre_sec_part to,
340 lnet_nid_t nid,
341 struct sptlrpc_flavor *sf);
342void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *set);
343
344int sptlrpc_process_config(struct lustre_cfg *lcfg);
345void sptlrpc_conf_log_start(const char *logname);
346void sptlrpc_conf_log_stop(const char *logname);
347void sptlrpc_conf_log_update_begin(const char *logname);
348void sptlrpc_conf_log_update_end(const char *logname);
349void sptlrpc_conf_client_adapt(struct obd_device *obd);
350int sptlrpc_conf_target_get_rules(struct obd_device *obd,
351 struct sptlrpc_rule_set *rset,
352 int initial);
353void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
354 enum lustre_sec_part from,
355 lnet_nid_t nid,
356 struct sptlrpc_flavor *flavor);
357
358
359
360
361
362#define SPTLRPC_MAX_PAYLOAD (1024)
363
364
365struct vfs_cred {
366 uint32_t vc_uid;
367 uint32_t vc_gid;
368};
369
370struct ptlrpc_ctx_ops {
371
372
373
374 int (*match) (struct ptlrpc_cli_ctx *ctx,
375 struct vfs_cred *vcred);
376
377
378
379
380 int (*refresh) (struct ptlrpc_cli_ctx *ctx);
381
382
383
384
385 int (*validate) (struct ptlrpc_cli_ctx *ctx);
386
387
388
389
390 void (*die) (struct ptlrpc_cli_ctx *ctx,
391 int grace);
392 int (*display) (struct ptlrpc_cli_ctx *ctx,
393 char *buf, int bufsize);
394
395
396
397
398
399
400
401
402
403
404
405 int (*sign) (struct ptlrpc_cli_ctx *ctx,
406 struct ptlrpc_request *req);
407
408
409
410
411
412
413
414
415
416
417
418 int (*verify) (struct ptlrpc_cli_ctx *ctx,
419 struct ptlrpc_request *req);
420
421
422
423
424
425
426
427
428
429
430
431 int (*seal) (struct ptlrpc_cli_ctx *ctx,
432 struct ptlrpc_request *req);
433
434
435
436
437
438
439
440
441
442
443
444 int (*unseal) (struct ptlrpc_cli_ctx *ctx,
445 struct ptlrpc_request *req);
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467 int (*wrap_bulk) (struct ptlrpc_cli_ctx *ctx,
468 struct ptlrpc_request *req,
469 struct ptlrpc_bulk_desc *desc);
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484 int (*unwrap_bulk) (struct ptlrpc_cli_ctx *ctx,
485 struct ptlrpc_request *req,
486 struct ptlrpc_bulk_desc *desc);
487};
488
489#define PTLRPC_CTX_NEW_BIT (0)
490#define PTLRPC_CTX_UPTODATE_BIT (1)
491#define PTLRPC_CTX_DEAD_BIT (2)
492#define PTLRPC_CTX_ERROR_BIT (3)
493#define PTLRPC_CTX_CACHED_BIT (8)
494#define PTLRPC_CTX_ETERNAL_BIT (9)
495
496#define PTLRPC_CTX_NEW (1 << PTLRPC_CTX_NEW_BIT)
497#define PTLRPC_CTX_UPTODATE (1 << PTLRPC_CTX_UPTODATE_BIT)
498#define PTLRPC_CTX_DEAD (1 << PTLRPC_CTX_DEAD_BIT)
499#define PTLRPC_CTX_ERROR (1 << PTLRPC_CTX_ERROR_BIT)
500#define PTLRPC_CTX_CACHED (1 << PTLRPC_CTX_CACHED_BIT)
501#define PTLRPC_CTX_ETERNAL (1 << PTLRPC_CTX_ETERNAL_BIT)
502
503#define PTLRPC_CTX_STATUS_MASK (PTLRPC_CTX_NEW_BIT | \
504 PTLRPC_CTX_UPTODATE | \
505 PTLRPC_CTX_DEAD | \
506 PTLRPC_CTX_ERROR)
507
508struct ptlrpc_cli_ctx {
509 struct hlist_node cc_cache;
510 atomic_t cc_refcount;
511 struct ptlrpc_sec *cc_sec;
512 struct ptlrpc_ctx_ops *cc_ops;
513 cfs_time_t cc_expire;
514 unsigned int cc_early_expire:1;
515 unsigned long cc_flags;
516 struct vfs_cred cc_vcred;
517 spinlock_t cc_lock;
518 struct list_head cc_req_list;
519 struct list_head cc_gc_chain;
520};
521
522
523
524
525struct ptlrpc_sec_cops {
526
527
528
529
530
531
532
533
534
535
536
537
538 struct ptlrpc_sec * (*create_sec) (struct obd_import *imp,
539 struct ptlrpc_svc_ctx *ctx,
540 struct sptlrpc_flavor *flavor);
541
542
543
544
545
546
547
548 void (*destroy_sec) (struct ptlrpc_sec *sec);
549
550
551
552
553
554
555
556
557 void (*kill_sec) (struct ptlrpc_sec *sec);
558
559
560
561
562
563
564
565
566
567 struct ptlrpc_cli_ctx * (*lookup_ctx) (struct ptlrpc_sec *sec,
568 struct vfs_cred *vcred,
569 int create,
570 int remove_dead);
571
572
573
574
575
576
577
578
579
580
581
582 void (*release_ctx) (struct ptlrpc_sec *sec,
583 struct ptlrpc_cli_ctx *ctx,
584 int sync);
585
586
587
588
589
590
591
592
593
594
595
596 int (*flush_ctx_cache)
597 (struct ptlrpc_sec *sec,
598 uid_t uid,
599 int grace,
600 int force);
601
602
603
604
605
606
607
608 void (*gc_ctx) (struct ptlrpc_sec *sec);
609
610
611
612
613
614
615
616 int (*install_rctx)(struct obd_import *imp,
617 struct ptlrpc_sec *sec,
618 struct ptlrpc_cli_ctx *ctx);
619
620
621
622
623
624
625
626
627
628
629
630
631 int (*alloc_reqbuf)(struct ptlrpc_sec *sec,
632 struct ptlrpc_request *req,
633 int lustre_msg_size);
634
635
636
637
638
639
640
641
642 void (*free_reqbuf) (struct ptlrpc_sec *sec,
643 struct ptlrpc_request *req);
644
645
646
647
648
649
650
651
652
653
654
655 int (*alloc_repbuf)(struct ptlrpc_sec *sec,
656 struct ptlrpc_request *req,
657 int lustre_msg_size);
658
659
660
661
662
663
664
665
666
667
668 void (*free_repbuf) (struct ptlrpc_sec *sec,
669 struct ptlrpc_request *req);
670
671
672
673
674
675
676
677
678
679
680
681 int (*enlarge_reqbuf)
682 (struct ptlrpc_sec *sec,
683 struct ptlrpc_request *req,
684 int segment, int newsize);
685
686
687
688 int (*display) (struct ptlrpc_sec *sec,
689 struct seq_file *seq);
690};
691
692
693
694
695struct ptlrpc_sec_sops {
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713 int (*accept) (struct ptlrpc_request *req);
714
715
716
717
718
719
720
721
722
723
724
725 int (*authorize) (struct ptlrpc_request *req);
726
727
728
729
730
731
732 void (*invalidate_ctx)
733 (struct ptlrpc_svc_ctx *ctx);
734
735
736
737
738
739
740
741
742
743
744
745
746
747 int (*alloc_rs) (struct ptlrpc_request *req,
748 int msgsize);
749
750
751
752
753 void (*free_rs) (struct ptlrpc_reply_state *rs);
754
755
756
757
758
759
760 void (*free_ctx) (struct ptlrpc_svc_ctx *ctx);
761
762
763
764
765
766
767 int (*install_rctx)(struct obd_import *imp,
768 struct ptlrpc_svc_ctx *ctx);
769
770
771
772
773
774
775
776
777
778 int (*prep_bulk) (struct ptlrpc_request *req,
779 struct ptlrpc_bulk_desc *desc);
780
781
782
783
784
785
786 int (*unwrap_bulk) (struct ptlrpc_request *req,
787 struct ptlrpc_bulk_desc *desc);
788
789
790
791
792
793
794 int (*wrap_bulk) (struct ptlrpc_request *req,
795 struct ptlrpc_bulk_desc *desc);
796};
797
798struct ptlrpc_sec_policy {
799 module_t *sp_owner;
800 char *sp_name;
801 __u16 sp_policy;
802 struct ptlrpc_sec_cops *sp_cops;
803 struct ptlrpc_sec_sops *sp_sops;
804};
805
806#define PTLRPC_SEC_FL_REVERSE 0x0001
807#define PTLRPC_SEC_FL_ROOTONLY 0x0002
808#define PTLRPC_SEC_FL_UDESC 0x0004
809#define PTLRPC_SEC_FL_BULK 0x0008
810#define PTLRPC_SEC_FL_PAG 0x0010
811
812
813
814
815
816
817
818
819struct ptlrpc_sec {
820 struct ptlrpc_sec_policy *ps_policy;
821 atomic_t ps_refcount;
822
823 atomic_t ps_nctx;
824
825 int ps_id;
826 struct sptlrpc_flavor ps_flvr;
827 enum lustre_sec_part ps_part;
828
829 unsigned int ps_dying:1;
830
831 struct obd_import *ps_import;
832 spinlock_t ps_lock;
833
834
835
836
837 struct list_head ps_gc_list;
838 cfs_time_t ps_gc_interval;
839 cfs_time_t ps_gc_next;
840};
841
842static inline int sec_is_reverse(struct ptlrpc_sec *sec)
843{
844 return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_REVERSE);
845}
846
847static inline int sec_is_rootonly(struct ptlrpc_sec *sec)
848{
849 return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_ROOTONLY);
850}
851
852
853struct ptlrpc_svc_ctx {
854 atomic_t sc_refcount;
855 struct ptlrpc_sec_policy *sc_policy;
856};
857
858
859
860
861#define LUSTRE_MAX_GROUPS (128)
862
863struct ptlrpc_user_desc {
864 __u32 pud_uid;
865 __u32 pud_gid;
866 __u32 pud_fsuid;
867 __u32 pud_fsgid;
868 __u32 pud_cap;
869 __u32 pud_ngroups;
870 __u32 pud_groups[0];
871};
872
873
874
875
876enum sptlrpc_bulk_hash_alg {
877 BULK_HASH_ALG_NULL = 0,
878 BULK_HASH_ALG_ADLER32,
879 BULK_HASH_ALG_CRC32,
880 BULK_HASH_ALG_MD5,
881 BULK_HASH_ALG_SHA1,
882 BULK_HASH_ALG_SHA256,
883 BULK_HASH_ALG_SHA384,
884 BULK_HASH_ALG_SHA512,
885 BULK_HASH_ALG_MAX
886};
887
888const char * sptlrpc_get_hash_name(__u8 hash_alg);
889__u8 sptlrpc_get_hash_alg(const char *algname);
890
891enum {
892 BSD_FL_ERR = 1,
893};
894
895struct ptlrpc_bulk_sec_desc {
896 __u8 bsd_version;
897 __u8 bsd_type;
898 __u8 bsd_svc;
899 __u8 bsd_flags;
900 __u32 bsd_nob;
901 __u8 bsd_data[0];
902};
903
904
905
906
907
908struct proc_dir_entry;
909extern struct proc_dir_entry *sptlrpc_proc_root;
910
911
912
913
914
915static inline int size_roundup_power2(int size)
916{
917 size--;
918 size |= size >> 1;
919 size |= size >> 2;
920 size |= size >> 4;
921 size |= size >> 8;
922 size |= size >> 16;
923 size++;
924 return size;
925}
926
927
928
929
930void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg,
931 int segment, int newsize);
932
933
934
935
936int sptlrpc_register_policy(struct ptlrpc_sec_policy *policy);
937int sptlrpc_unregister_policy(struct ptlrpc_sec_policy *policy);
938
939__u32 sptlrpc_name2flavor_base(const char *name);
940const char *sptlrpc_flavor2name_base(__u32 flvr);
941char *sptlrpc_flavor2name_bulk(struct sptlrpc_flavor *sf,
942 char *buf, int bufsize);
943char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize);
944char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize);
945
946static inline
947struct ptlrpc_sec_policy *sptlrpc_policy_get(struct ptlrpc_sec_policy *policy)
948{
949 __module_get(policy->sp_owner);
950 return policy;
951}
952
953static inline
954void sptlrpc_policy_put(struct ptlrpc_sec_policy *policy)
955{
956 module_put(policy->sp_owner);
957}
958
959
960
961
962static inline
963unsigned long cli_ctx_status(struct ptlrpc_cli_ctx *ctx)
964{
965 return (ctx->cc_flags & PTLRPC_CTX_STATUS_MASK);
966}
967
968static inline
969int cli_ctx_is_ready(struct ptlrpc_cli_ctx *ctx)
970{
971 return (cli_ctx_status(ctx) == PTLRPC_CTX_UPTODATE);
972}
973
974static inline
975int cli_ctx_is_refreshed(struct ptlrpc_cli_ctx *ctx)
976{
977 return (cli_ctx_status(ctx) != 0);
978}
979
980static inline
981int cli_ctx_is_uptodate(struct ptlrpc_cli_ctx *ctx)
982{
983 return ((ctx->cc_flags & PTLRPC_CTX_UPTODATE) != 0);
984}
985
986static inline
987int cli_ctx_is_error(struct ptlrpc_cli_ctx *ctx)
988{
989 return ((ctx->cc_flags & PTLRPC_CTX_ERROR) != 0);
990}
991
992static inline
993int cli_ctx_is_dead(struct ptlrpc_cli_ctx *ctx)
994{
995 return ((ctx->cc_flags & (PTLRPC_CTX_DEAD | PTLRPC_CTX_ERROR)) != 0);
996}
997
998static inline
999int cli_ctx_is_eternal(struct ptlrpc_cli_ctx *ctx)
1000{
1001 return ((ctx->cc_flags & PTLRPC_CTX_ETERNAL) != 0);
1002}
1003
1004
1005
1006
1007struct ptlrpc_sec *sptlrpc_sec_get(struct ptlrpc_sec *sec);
1008void sptlrpc_sec_put(struct ptlrpc_sec *sec);
1009
1010
1011
1012
1013int sptlrpc_get_next_secid(void);
1014void sptlrpc_sec_destroy(struct ptlrpc_sec *sec);
1015
1016
1017
1018
1019struct ptlrpc_cli_ctx *sptlrpc_cli_ctx_get(struct ptlrpc_cli_ctx *ctx);
1020void sptlrpc_cli_ctx_put(struct ptlrpc_cli_ctx *ctx, int sync);
1021void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx);
1022void sptlrpc_cli_ctx_wakeup(struct ptlrpc_cli_ctx *ctx);
1023int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize);
1024
1025
1026
1027
1028int sptlrpc_cli_wrap_request(struct ptlrpc_request *req);
1029int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req);
1030int sptlrpc_cli_alloc_reqbuf(struct ptlrpc_request *req, int msgsize);
1031void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req);
1032int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
1033void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req);
1034int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
1035 int segment, int newsize);
1036int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
1037 struct ptlrpc_request **req_ret);
1038void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req);
1039
1040void sptlrpc_request_out_callback(struct ptlrpc_request *req);
1041
1042
1043
1044
1045int sptlrpc_import_sec_adapt(struct obd_import *imp,
1046 struct ptlrpc_svc_ctx *ctx,
1047 struct sptlrpc_flavor *flvr);
1048struct ptlrpc_sec *sptlrpc_import_sec_ref(struct obd_import *imp);
1049void sptlrpc_import_sec_put(struct obd_import *imp);
1050
1051int sptlrpc_import_check_ctx(struct obd_import *imp);
1052void sptlrpc_import_flush_root_ctx(struct obd_import *imp);
1053void sptlrpc_import_flush_my_ctx(struct obd_import *imp);
1054void sptlrpc_import_flush_all_ctx(struct obd_import *imp);
1055int sptlrpc_req_get_ctx(struct ptlrpc_request *req);
1056void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync);
1057int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout);
1058int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req);
1059void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode);
1060
1061int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule);
1062
1063
1064void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec);
1065void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec);
1066void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx);
1067
1068
1069const char * sec2target_str(struct ptlrpc_sec *sec);
1070int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev);
1071
1072
1073
1074
1075enum secsvc_accept_res {
1076 SECSVC_OK = 0,
1077 SECSVC_COMPLETE,
1078 SECSVC_DROP,
1079};
1080
1081int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req);
1082int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen);
1083int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req);
1084void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs);
1085void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req);
1086void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req);
1087void sptlrpc_svc_ctx_invalidate(struct ptlrpc_request *req);
1088
1089int sptlrpc_target_export_check(struct obd_export *exp,
1090 struct ptlrpc_request *req);
1091void sptlrpc_target_update_exp_flavor(struct obd_device *obd,
1092 struct sptlrpc_rule_set *rset);
1093
1094
1095
1096
1097int sptlrpc_svc_install_rvs_ctx(struct obd_import *imp,
1098 struct ptlrpc_svc_ctx *ctx);
1099int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp,
1100 struct ptlrpc_cli_ctx *ctx);
1101
1102
1103int sptlrpc_enc_pool_add_user(void);
1104int sptlrpc_enc_pool_del_user(void);
1105int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc);
1106void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc);
1107
1108int sptlrpc_cli_wrap_bulk(struct ptlrpc_request *req,
1109 struct ptlrpc_bulk_desc *desc);
1110int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req,
1111 struct ptlrpc_bulk_desc *desc,
1112 int nob);
1113int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
1114 struct ptlrpc_bulk_desc *desc);
1115
1116
1117int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
1118 void *buf, int buflen);
1119
1120int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed);
1121
1122
1123static inline int sptlrpc_user_desc_size(int ngroups)
1124{
1125 return sizeof(struct ptlrpc_user_desc) + ngroups * sizeof(__u32);
1126}
1127
1128int sptlrpc_current_user_desc_size(void);
1129int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset);
1130int sptlrpc_unpack_user_desc(struct lustre_msg *req, int offset, int swabbed);
1131
1132
1133#define CFS_CAP_CHOWN_MASK (1 << CFS_CAP_CHOWN)
1134#define CFS_CAP_SYS_RESOURCE_MASK (1 << CFS_CAP_SYS_RESOURCE)
1135
1136enum {
1137 LUSTRE_SEC_NONE = 0,
1138 LUSTRE_SEC_REMOTE = 1,
1139 LUSTRE_SEC_SPECIFY = 2,
1140 LUSTRE_SEC_ALL = 3
1141};
1142
1143
1144
1145#endif
1146