1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
5 * Author Peter Braam <braam@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>
39 #include <liblustre.h>
43 #include <obd_class.h>
44 #include <obd_support.h>
45 #include <lustre/lustre_idl.h>
46 #include <lustre_net.h>
47 #include <lustre_import.h>
48 #include <lprocfs_status.h>
49 #include <lustre_sec.h>
52 #include "gss_internal.h"
55 static struct proc_dir_entry *gss_proc_root = NULL;
58 * statistic of "out-of-sequence-window"
62 atomic_t oos_cli_count; /* client occurrence */
63 int oos_cli_behind; /* client max seqs behind */
64 atomic_t oos_svc_replay[3]; /* server replay detected */
65 atomic_t oos_svc_pass[3]; /* server verified ok */
67 .oos_lock = SPIN_LOCK_UNLOCKED,
68 .oos_cli_count = ATOMIC_INIT(0),
70 .oos_svc_replay = { ATOMIC_INIT(0), },
71 .oos_svc_pass = { ATOMIC_INIT(0), },
74 void gss_stat_oos_record_cli(int behind)
76 atomic_inc(&gss_stat_oos.oos_cli_count);
78 spin_lock(&gss_stat_oos.oos_lock);
79 if (behind > gss_stat_oos.oos_cli_behind)
80 gss_stat_oos.oos_cli_behind = behind;
81 spin_unlock(&gss_stat_oos.oos_lock);
84 void gss_stat_oos_record_svc(int phase, int replay)
86 LASSERT(phase >= 0 && phase <= 2);
89 atomic_inc(&gss_stat_oos.oos_svc_replay[phase]);
91 atomic_inc(&gss_stat_oos.oos_svc_pass[phase]);
94 static int gss_proc_read_oos(char *page, char **start, off_t off, int count,
99 written = snprintf(page, count,
102 "client fall behind seqwin\n"
104 " max seq behind: %d\n"
105 "server replay detected:\n"
109 "server verify ok:\n"
113 atomic_read(&gss_stat_oos.oos_cli_count),
114 gss_stat_oos.oos_cli_behind,
115 atomic_read(&gss_stat_oos.oos_svc_replay[0]),
116 atomic_read(&gss_stat_oos.oos_svc_replay[1]),
117 atomic_read(&gss_stat_oos.oos_svc_replay[2]),
118 atomic_read(&gss_stat_oos.oos_svc_pass[2]));
123 static int gss_proc_write_secinit(struct file *file, const char *buffer,
124 unsigned long count, void *data)
128 rc = gss_do_ctx_init_rpc((char *) buffer, count);
134 return ((int) count);
137 static struct lprocfs_vars gss_lprocfs_vars[] = {
138 { "replays", gss_proc_read_oos, NULL },
139 { "init_channel", NULL, gss_proc_write_secinit, NULL },
143 int gss_init_lproc(void)
146 gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root,
147 gss_lprocfs_vars, NULL);
149 if (IS_ERR(gss_proc_root)) {
150 rc = PTR_ERR(gss_proc_root);
151 gss_proc_root = NULL;
152 CERROR("failed to initialize lproc entries: %d\n", rc);
159 void gss_exit_lproc(void)
162 lprocfs_remove(&gss_proc_root);
163 gss_proc_root = NULL;