sysctl.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2006 Oracle. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/sysctl.h>
  35. #include <linux/proc_fs.h>
  36. #include "rds.h"
  37. static struct ctl_table_header *rds_sysctl_reg_table;
  38. static unsigned long rds_sysctl_reconnect_min = 1;
  39. static unsigned long rds_sysctl_reconnect_max = ~0UL;
  40. unsigned long rds_sysctl_reconnect_min_jiffies;
  41. unsigned long rds_sysctl_reconnect_max_jiffies = HZ;
  42. unsigned int rds_sysctl_max_unacked_packets = 8;
  43. unsigned int rds_sysctl_max_unacked_bytes = (16 << 20);
  44. unsigned int rds_sysctl_ping_enable = 1;
  45. static ctl_table rds_sysctl_rds_table[] = {
  46. {
  47. .ctl_name = CTL_UNNUMBERED,
  48. .procname = "reconnect_min_delay_ms",
  49. .data = &rds_sysctl_reconnect_min_jiffies,
  50. .maxlen = sizeof(unsigned long),
  51. .mode = 0644,
  52. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  53. .extra1 = &rds_sysctl_reconnect_min,
  54. .extra2 = &rds_sysctl_reconnect_max_jiffies,
  55. },
  56. {
  57. .ctl_name = CTL_UNNUMBERED,
  58. .procname = "reconnect_max_delay_ms",
  59. .data = &rds_sysctl_reconnect_max_jiffies,
  60. .maxlen = sizeof(unsigned long),
  61. .mode = 0644,
  62. .proc_handler = &proc_doulongvec_ms_jiffies_minmax,
  63. .extra1 = &rds_sysctl_reconnect_min_jiffies,
  64. .extra2 = &rds_sysctl_reconnect_max,
  65. },
  66. {
  67. .ctl_name = CTL_UNNUMBERED,
  68. .procname = "max_unacked_packets",
  69. .data = &rds_sysctl_max_unacked_packets,
  70. .maxlen = sizeof(unsigned long),
  71. .mode = 0644,
  72. .proc_handler = &proc_dointvec,
  73. },
  74. {
  75. .ctl_name = CTL_UNNUMBERED,
  76. .procname = "max_unacked_bytes",
  77. .data = &rds_sysctl_max_unacked_bytes,
  78. .maxlen = sizeof(unsigned long),
  79. .mode = 0644,
  80. .proc_handler = &proc_dointvec,
  81. },
  82. {
  83. .ctl_name = CTL_UNNUMBERED,
  84. .procname = "ping_enable",
  85. .data = &rds_sysctl_ping_enable,
  86. .maxlen = sizeof(int),
  87. .mode = 0644,
  88. .proc_handler = &proc_dointvec,
  89. },
  90. { .ctl_name = 0}
  91. };
  92. static struct ctl_path rds_sysctl_path[] = {
  93. { .procname = "net", .ctl_name = CTL_NET, },
  94. { .procname = "rds", .ctl_name = CTL_UNNUMBERED, },
  95. { }
  96. };
  97. void rds_sysctl_exit(void)
  98. {
  99. if (rds_sysctl_reg_table)
  100. unregister_sysctl_table(rds_sysctl_reg_table);
  101. }
  102. int __init rds_sysctl_init(void)
  103. {
  104. rds_sysctl_reconnect_min = msecs_to_jiffies(1);
  105. rds_sysctl_reconnect_min_jiffies = rds_sysctl_reconnect_min;
  106. rds_sysctl_reg_table = register_sysctl_paths(rds_sysctl_path, rds_sysctl_rds_table);
  107. if (rds_sysctl_reg_table == NULL)
  108. return -ENOMEM;
  109. return 0;
  110. }