1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2006 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DEBUG_SUBSYSTEM S_SEC
27 #include <libcfs/libcfs.h>
29 #include <liblustre.h>
30 #include <libcfs/list.h>
32 #include <linux/crypto.h>
36 #include <obd_class.h>
37 #include <obd_support.h>
38 #include <lustre_net.h>
39 #include <lustre_import.h>
40 #include <lustre_dlm.h>
41 #include <lustre_sec.h>
43 #include "ptlrpc_internal.h"
47 struct proc_dir_entry *sptlrpc_proc_root = NULL;
48 EXPORT_SYMBOL(sptlrpc_proc_root);
50 void sec_flags2str(unsigned long flags, char *buf, int bufsize)
54 if (flags & PTLRPC_SEC_FL_REVERSE)
55 strncat(buf, "reverse,", bufsize);
56 if (flags & PTLRPC_SEC_FL_ROOTONLY)
57 strncat(buf, "rootonly,", bufsize);
58 if (flags & PTLRPC_SEC_FL_BULK)
59 strncat(buf, "bulk,", bufsize);
60 if (flags & PTLRPC_SEC_FL_PAG)
61 strncat(buf, "pag,", bufsize);
63 strncat(buf, "-,", bufsize);
65 buf[strlen(buf) - 1] = '\0';
69 int sptlrpc_lprocfs_rd(char *page, char **start, off_t off, int count,
72 struct obd_device *obd = data;
73 struct sec_flavor_config *conf = &obd->u.cli.cl_sec_conf;
74 struct ptlrpc_sec *sec = NULL;
75 struct ptlrpc_cli_ctx *ctx;
76 struct hlist_node *pos, *next;
83 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
84 strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
85 strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) == 0);
86 LASSERT(conf->sfc_bulk_csum < BULK_CSUM_ALG_MAX);
87 LASSERT(conf->sfc_bulk_priv < BULK_PRIV_ALG_MAX);
89 if (obd->u.cli.cl_import)
90 sec = obd->u.cli.cl_import->imp_sec;
93 written = snprintf(page, count, "\n");
97 sec_flags2str(sec->ps_flags, flags_str, sizeof(flags_str));
99 written = snprintf(page, count,
100 "rpc msg flavor: %s\n"
101 "bulk checksum: %s\n"
104 "ctx cache size %u\n"
105 "ctx cache busy %d\n"
108 sptlrpc_flavor2name(sec->ps_flavor),
109 sptlrpc_bulk_csum_alg2name(conf->sfc_bulk_csum),
110 sptlrpc_bulk_priv_alg2name(conf->sfc_bulk_priv),
113 atomic_read(&sec->ps_busy),
115 sec->ps_gc_interval ?
116 sec->ps_gc_next - cfs_time_current_sec() : 0
121 if (sec->ps_policy->sp_policy != SPTLRPC_POLICY_GSS)
124 written += snprintf(page + written, count - written,
125 "GSS contexts ==>\n");
127 spin_lock(&sec->ps_lock);
128 for (i = 0; i < sec->ps_ccache_size; i++) {
129 hlist_for_each_entry_safe(ctx, pos, next,
130 &sec->ps_ccache[i], cc_hash) {
131 if (written >= count)
133 written += sptlrpc_ctx_display(ctx, page + written,
137 spin_unlock(&sec->ps_lock);
142 EXPORT_SYMBOL(sptlrpc_lprocfs_rd);
144 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
145 { "enc_pool", sptlrpc_proc_read_enc_pool, NULL, NULL },
149 int sptlrpc_lproc_init(void)
153 LASSERT(sptlrpc_proc_root == NULL);
155 sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
156 sptlrpc_lprocfs_vars, NULL);
157 if (IS_ERR(sptlrpc_proc_root)) {
158 rc = PTR_ERR(sptlrpc_proc_root);
159 sptlrpc_proc_root = NULL;
165 void sptlrpc_lproc_fini(void)
167 if (sptlrpc_proc_root) {
168 lprocfs_remove(sptlrpc_proc_root);
169 sptlrpc_proc_root = NULL;
173 #else /* !__KERNEL__ */
175 int sptlrpc_lproc_init(void)
180 void sptlrpc_lproc_fini(void)