sysctl.c 2.7 KB

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