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.
5 * Author Eric Mei <ericm@clusterfs.com>
7 * This file is part of the Lustre file system, http://www.lustre.org
8 * Lustre is a trademark of Cluster File Systems, Inc.
10 * You may have signed or agreed to another license before downloading
11 * this software. If so, you are bound by the terms and conditions
12 * of that agreement, and the following does not apply to you. See the
13 * LICENSE file included with this distribution for more information.
15 * If you did not agree to a different license, then this copy of Lustre
16 * is open source software; you can redistribute it and/or modify it
17 * under the terms of version 2 of the GNU General Public License as
18 * published by the Free Software Foundation.
20 * In either case, Lustre is distributed in the hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
22 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * license text for more details.
28 # define EXPORT_SYMTAB
30 #define DEBUG_SUBSYSTEM S_SEC
32 #include <linux/init.h>
33 #include <linux/module.h>
34 #include <linux/slab.h>
35 #include <linux/dcache.h>
37 #include <linux/random.h>
38 #include <linux/mutex.h>
40 #include <liblustre.h>
44 #include <obd_class.h>
45 #include <obd_support.h>
46 #include <lustre/lustre_idl.h>
47 #include <lustre_net.h>
48 #include <lustre_import.h>
49 #include <lprocfs_status.h>
50 #include <lustre_sec.h>
53 #include "gss_internal.h"
56 static struct proc_dir_entry *gss_proc_root = NULL;
59 * statistic of "out-of-sequence-window"
63 atomic_t oos_cli_count; /* client occurrence */
64 int oos_cli_behind; /* client max seqs behind */
65 atomic_t oos_svc_replay[3]; /* server replay detected */
66 atomic_t oos_svc_pass[3]; /* server verified ok */
68 .oos_lock = SPIN_LOCK_UNLOCKED,
69 .oos_cli_count = ATOMIC_INIT(0),
71 .oos_svc_replay = { ATOMIC_INIT(0), },
72 .oos_svc_pass = { ATOMIC_INIT(0), },
75 void gss_stat_oos_record_cli(int behind)
77 atomic_inc(&gss_stat_oos.oos_cli_count);
79 spin_lock(&gss_stat_oos.oos_lock);
80 if (behind > gss_stat_oos.oos_cli_behind)
81 gss_stat_oos.oos_cli_behind = behind;
82 spin_unlock(&gss_stat_oos.oos_lock);
85 void gss_stat_oos_record_svc(int phase, int replay)
87 LASSERT(phase >= 0 && phase <= 2);
90 atomic_inc(&gss_stat_oos.oos_svc_replay[phase]);
92 atomic_inc(&gss_stat_oos.oos_svc_pass[phase]);
95 static int gss_proc_read_oos(char *page, char **start, off_t off, int count,
100 written = snprintf(page, count,
103 "client fall behind seqwin\n"
105 " max seq behind: %d\n"
106 "server replay detected:\n"
110 "server verify ok:\n"
114 atomic_read(&gss_stat_oos.oos_cli_count),
115 gss_stat_oos.oos_cli_behind,
116 atomic_read(&gss_stat_oos.oos_svc_replay[0]),
117 atomic_read(&gss_stat_oos.oos_svc_replay[1]),
118 atomic_read(&gss_stat_oos.oos_svc_replay[2]),
119 atomic_read(&gss_stat_oos.oos_svc_pass[2]));
124 static int gss_proc_write_secinit(struct file *file, const char *buffer,
125 unsigned long count, void *data)
129 rc = gss_do_ctx_init_rpc((char *) buffer, count);
135 return ((int) count);
138 static struct lprocfs_vars gss_lprocfs_vars[] = {
139 { "replays", gss_proc_read_oos, NULL },
140 { "init_channel", NULL, gss_proc_write_secinit, NULL },
144 int gss_init_lproc(void)
146 struct proc_dir_entry *ent;
149 gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root,
150 gss_lprocfs_vars, NULL);
152 if (IS_ERR(gss_proc_root)) {
153 rc = PTR_ERR(gss_proc_root);
154 gss_proc_root = NULL;
155 CERROR("failed to initialize lproc entries: %d\n", rc);
160 * here we should hold proc_subdir_lock which is not exported
162 ent = gss_proc_root->subdir;
163 while (ent != NULL) {
164 if (strcmp(ent->name, "init_channel") == 0) {
173 void gss_exit_lproc(void)
176 lprocfs_remove(&gss_proc_root);
177 gss_proc_root = NULL;