Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* sysctl.c: Rx RPC control |
| 2 | * |
| 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/sched.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/sysctl.h> |
| 16 | #include <rxrpc/types.h> |
| 17 | #include <rxrpc/rxrpc.h> |
| 18 | #include <asm/errno.h> |
| 19 | #include "internal.h" |
| 20 | |
| 21 | int rxrpc_ktrace; |
| 22 | int rxrpc_kdebug; |
| 23 | int rxrpc_kproto; |
| 24 | int rxrpc_knet; |
| 25 | |
| 26 | #ifdef CONFIG_SYSCTL |
| 27 | static struct ctl_table_header *rxrpc_sysctl = NULL; |
| 28 | |
| 29 | static ctl_table rxrpc_sysctl_table[] = { |
| 30 | { |
| 31 | .ctl_name = 1, |
| 32 | .procname = "kdebug", |
| 33 | .data = &rxrpc_kdebug, |
| 34 | .maxlen = sizeof(int), |
| 35 | .mode = 0644, |
| 36 | .proc_handler = &proc_dointvec |
| 37 | }, |
| 38 | { |
| 39 | .ctl_name = 2, |
| 40 | .procname = "ktrace", |
| 41 | .data = &rxrpc_ktrace, |
| 42 | .maxlen = sizeof(int), |
| 43 | .mode = 0644, |
| 44 | .proc_handler = &proc_dointvec |
| 45 | }, |
| 46 | { |
| 47 | .ctl_name = 3, |
| 48 | .procname = "kproto", |
| 49 | .data = &rxrpc_kproto, |
| 50 | .maxlen = sizeof(int), |
| 51 | .mode = 0644, |
| 52 | .proc_handler = &proc_dointvec |
| 53 | }, |
| 54 | { |
| 55 | .ctl_name = 4, |
| 56 | .procname = "knet", |
| 57 | .data = &rxrpc_knet, |
| 58 | .maxlen = sizeof(int), |
| 59 | .mode = 0644, |
| 60 | .proc_handler = &proc_dointvec |
| 61 | }, |
| 62 | { |
| 63 | .ctl_name = 5, |
| 64 | .procname = "peertimo", |
| 65 | .data = &rxrpc_peer_timeout, |
| 66 | .maxlen = sizeof(unsigned long), |
| 67 | .mode = 0644, |
| 68 | .proc_handler = &proc_doulongvec_minmax |
| 69 | }, |
| 70 | { |
| 71 | .ctl_name = 6, |
| 72 | .procname = "conntimo", |
| 73 | .data = &rxrpc_conn_timeout, |
| 74 | .maxlen = sizeof(unsigned long), |
| 75 | .mode = 0644, |
| 76 | .proc_handler = &proc_doulongvec_minmax |
| 77 | }, |
| 78 | { .ctl_name = 0 } |
| 79 | }; |
| 80 | |
| 81 | static ctl_table rxrpc_dir_sysctl_table[] = { |
| 82 | { |
| 83 | .ctl_name = 1, |
| 84 | .procname = "rxrpc", |
| 85 | .maxlen = 0, |
| 86 | .mode = 0555, |
| 87 | .child = rxrpc_sysctl_table |
| 88 | }, |
| 89 | { .ctl_name = 0 } |
| 90 | }; |
| 91 | #endif /* CONFIG_SYSCTL */ |
| 92 | |
| 93 | /*****************************************************************************/ |
| 94 | /* |
| 95 | * initialise the sysctl stuff for Rx RPC |
| 96 | */ |
| 97 | int rxrpc_sysctl_init(void) |
| 98 | { |
| 99 | #ifdef CONFIG_SYSCTL |
| 100 | rxrpc_sysctl = register_sysctl_table(rxrpc_dir_sysctl_table, 0); |
| 101 | if (!rxrpc_sysctl) |
| 102 | return -ENOMEM; |
| 103 | #endif /* CONFIG_SYSCTL */ |
| 104 | |
| 105 | return 0; |
| 106 | } /* end rxrpc_sysctl_init() */ |
| 107 | |
| 108 | /*****************************************************************************/ |
| 109 | /* |
| 110 | * clean up the sysctl stuff for Rx RPC |
| 111 | */ |
| 112 | void rxrpc_sysctl_cleanup(void) |
| 113 | { |
| 114 | #ifdef CONFIG_SYSCTL |
| 115 | if (rxrpc_sysctl) { |
| 116 | unregister_sysctl_table(rxrpc_sysctl); |
| 117 | rxrpc_sysctl = NULL; |
| 118 | } |
| 119 | #endif /* CONFIG_SYSCTL */ |
| 120 | |
| 121 | } /* end rxrpc_sysctl_cleanup() */ |