sysctl.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #include <linux/sched.h>
  12. #include <linux/slab.h>
  13. #include <linux/module.h>
  14. #include <linux/sysctl.h>
  15. #include <rxrpc/types.h>
  16. #include <rxrpc/rxrpc.h>
  17. #include <asm/errno.h>
  18. #include "internal.h"
  19. int rxrpc_ktrace;
  20. int rxrpc_kdebug;
  21. int rxrpc_kproto;
  22. int rxrpc_knet;
  23. #ifdef CONFIG_SYSCTL
  24. static struct ctl_table_header *rxrpc_sysctl = NULL;
  25. static ctl_table rxrpc_sysctl_table[] = {
  26. {
  27. .ctl_name = 1,
  28. .procname = "kdebug",
  29. .data = &rxrpc_kdebug,
  30. .maxlen = sizeof(int),
  31. .mode = 0644,
  32. .proc_handler = &proc_dointvec
  33. },
  34. {
  35. .ctl_name = 2,
  36. .procname = "ktrace",
  37. .data = &rxrpc_ktrace,
  38. .maxlen = sizeof(int),
  39. .mode = 0644,
  40. .proc_handler = &proc_dointvec
  41. },
  42. {
  43. .ctl_name = 3,
  44. .procname = "kproto",
  45. .data = &rxrpc_kproto,
  46. .maxlen = sizeof(int),
  47. .mode = 0644,
  48. .proc_handler = &proc_dointvec
  49. },
  50. {
  51. .ctl_name = 4,
  52. .procname = "knet",
  53. .data = &rxrpc_knet,
  54. .maxlen = sizeof(int),
  55. .mode = 0644,
  56. .proc_handler = &proc_dointvec
  57. },
  58. {
  59. .ctl_name = 5,
  60. .procname = "peertimo",
  61. .data = &rxrpc_peer_timeout,
  62. .maxlen = sizeof(unsigned long),
  63. .mode = 0644,
  64. .proc_handler = &proc_doulongvec_minmax
  65. },
  66. {
  67. .ctl_name = 6,
  68. .procname = "conntimo",
  69. .data = &rxrpc_conn_timeout,
  70. .maxlen = sizeof(unsigned long),
  71. .mode = 0644,
  72. .proc_handler = &proc_doulongvec_minmax
  73. },
  74. { .ctl_name = 0 }
  75. };
  76. static ctl_table rxrpc_dir_sysctl_table[] = {
  77. {
  78. .ctl_name = 1,
  79. .procname = "rxrpc",
  80. .maxlen = 0,
  81. .mode = 0555,
  82. .child = rxrpc_sysctl_table
  83. },
  84. { .ctl_name = 0 }
  85. };
  86. #endif /* CONFIG_SYSCTL */
  87. /*****************************************************************************/
  88. /*
  89. * initialise the sysctl stuff for Rx RPC
  90. */
  91. int rxrpc_sysctl_init(void)
  92. {
  93. #ifdef CONFIG_SYSCTL
  94. rxrpc_sysctl = register_sysctl_table(rxrpc_dir_sysctl_table);
  95. if (!rxrpc_sysctl)
  96. return -ENOMEM;
  97. #endif /* CONFIG_SYSCTL */
  98. return 0;
  99. } /* end rxrpc_sysctl_init() */
  100. /*****************************************************************************/
  101. /*
  102. * clean up the sysctl stuff for Rx RPC
  103. */
  104. void rxrpc_sysctl_cleanup(void)
  105. {
  106. #ifdef CONFIG_SYSCTL
  107. if (rxrpc_sysctl) {
  108. unregister_sysctl_table(rxrpc_sysctl);
  109. rxrpc_sysctl = NULL;
  110. }
  111. #endif /* CONFIG_SYSCTL */
  112. } /* end rxrpc_sysctl_cleanup() */