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);
61 strncat(buf, "-,", bufsize);
63 buf[strlen(buf) - 1] = '\0';
67 int sptlrpc_lprocfs_rd(char *page, char **start, off_t off, int count,
70 struct obd_device *obd = data;
71 struct sec_flavor_config *conf = &obd->u.cli.cl_sec_conf;
72 struct ptlrpc_sec *sec = NULL;
79 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
80 strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
81 strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) == 0);
82 LASSERT(conf->sfc_bulk_csum < BULK_CSUM_ALG_MAX);
83 LASSERT(conf->sfc_bulk_priv < BULK_PRIV_ALG_MAX);
85 if (obd->u.cli.cl_import)
86 sec = obd->u.cli.cl_import->imp_sec;
89 written = snprintf(page, count, "\n");
93 sec_flags2str(sec->ps_flags, flags_str, sizeof(flags_str));
95 written = snprintf(page, count,
96 "rpc msg flavor: %s\n"
100 "ctx cache busy %d\n"
103 sptlrpc_flavor2name(sec->ps_flavor),
104 sptlrpc_bulk_csum_alg2name(conf->sfc_bulk_csum),
105 sptlrpc_bulk_priv_alg2name(conf->sfc_bulk_priv),
107 atomic_read(&sec->ps_busy),
109 sec->ps_gc_interval ?
110 sec->ps_gc_next - cfs_time_current_sec() : 0
113 if (sec->ps_policy->sp_cops->display) {
114 written += sec->ps_policy->sp_cops->display(
115 sec, page + written, count - written);
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_cli_ctx_display(ctx, page + written,
137 spin_unlock(&sec->ps_lock);
143 EXPORT_SYMBOL(sptlrpc_lprocfs_rd);
145 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
146 { "enc_pool", sptlrpc_proc_read_enc_pool, NULL, NULL },
150 int sptlrpc_lproc_init(void)
154 LASSERT(sptlrpc_proc_root == NULL);
156 sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
157 sptlrpc_lprocfs_vars, NULL);
158 if (IS_ERR(sptlrpc_proc_root)) {
159 rc = PTR_ERR(sptlrpc_proc_root);
160 sptlrpc_proc_root = NULL;
166 void sptlrpc_lproc_fini(void)
168 if (sptlrpc_proc_root) {
169 lprocfs_remove(&sptlrpc_proc_root);
170 sptlrpc_proc_root = NULL;
174 #else /* !__KERNEL__ */
176 int sptlrpc_lproc_init(void)
181 void sptlrpc_lproc_fini(void)