sysctl.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* sysctls for configuring RxRPC operating parameters
  2. *
  3. * Copyright (C) 2014 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 Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/sysctl.h>
  12. #include <net/sock.h>
  13. #include <net/af_rxrpc.h>
  14. #include "ar-internal.h"
  15. static struct ctl_table_header *rxrpc_sysctl_reg_table;
  16. static const unsigned int zero = 0;
  17. static const unsigned int one = 1;
  18. static const unsigned int four = 4;
  19. static const unsigned int thirtytwo = 32;
  20. static const unsigned int n_65535 = 65535;
  21. static const unsigned int n_max_acks = RXRPC_RXTX_BUFF_SIZE - 1;
  22. static const unsigned long one_jiffy = 1;
  23. static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
  24. /*
  25. * RxRPC operating parameters.
  26. *
  27. * See Documentation/networking/rxrpc.txt and the variable definitions for more
  28. * information on the individual parameters.
  29. */
  30. static struct ctl_table rxrpc_sysctl_table[] = {
  31. /* Values measured in milliseconds but used in jiffies */
  32. {
  33. .procname = "req_ack_delay",
  34. .data = &rxrpc_requested_ack_delay,
  35. .maxlen = sizeof(unsigned long),
  36. .mode = 0644,
  37. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  38. .extra1 = (void *)&one_jiffy,
  39. .extra2 = (void *)&max_jiffies,
  40. },
  41. {
  42. .procname = "soft_ack_delay",
  43. .data = &rxrpc_soft_ack_delay,
  44. .maxlen = sizeof(unsigned long),
  45. .mode = 0644,
  46. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  47. .extra1 = (void *)&one_jiffy,
  48. .extra2 = (void *)&max_jiffies,
  49. },
  50. {
  51. .procname = "idle_ack_delay",
  52. .data = &rxrpc_idle_ack_delay,
  53. .maxlen = sizeof(unsigned long),
  54. .mode = 0644,
  55. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  56. .extra1 = (void *)&one_jiffy,
  57. .extra2 = (void *)&max_jiffies,
  58. },
  59. {
  60. .procname = "idle_conn_expiry",
  61. .data = &rxrpc_conn_idle_client_expiry,
  62. .maxlen = sizeof(unsigned long),
  63. .mode = 0644,
  64. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  65. .extra1 = (void *)&one_jiffy,
  66. .extra2 = (void *)&max_jiffies,
  67. },
  68. {
  69. .procname = "idle_conn_fast_expiry",
  70. .data = &rxrpc_conn_idle_client_fast_expiry,
  71. .maxlen = sizeof(unsigned long),
  72. .mode = 0644,
  73. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  74. .extra1 = (void *)&one_jiffy,
  75. .extra2 = (void *)&max_jiffies,
  76. },
  77. {
  78. .procname = "resend_timeout",
  79. .data = &rxrpc_resend_timeout,
  80. .maxlen = sizeof(unsigned long),
  81. .mode = 0644,
  82. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  83. .extra1 = (void *)&one_jiffy,
  84. .extra2 = (void *)&max_jiffies,
  85. },
  86. /* Non-time values */
  87. {
  88. .procname = "max_client_conns",
  89. .data = &rxrpc_max_client_connections,
  90. .maxlen = sizeof(unsigned int),
  91. .mode = 0644,
  92. .proc_handler = proc_dointvec_minmax,
  93. .extra1 = (void *)&rxrpc_reap_client_connections,
  94. },
  95. {
  96. .procname = "reap_client_conns",
  97. .data = &rxrpc_reap_client_connections,
  98. .maxlen = sizeof(unsigned int),
  99. .mode = 0644,
  100. .proc_handler = proc_dointvec_minmax,
  101. .extra1 = (void *)&one,
  102. .extra2 = (void *)&rxrpc_max_client_connections,
  103. },
  104. {
  105. .procname = "max_backlog",
  106. .data = &rxrpc_max_backlog,
  107. .maxlen = sizeof(unsigned int),
  108. .mode = 0644,
  109. .proc_handler = proc_dointvec_minmax,
  110. .extra1 = (void *)&four,
  111. .extra2 = (void *)&thirtytwo,
  112. },
  113. {
  114. .procname = "rx_window_size",
  115. .data = &rxrpc_rx_window_size,
  116. .maxlen = sizeof(unsigned int),
  117. .mode = 0644,
  118. .proc_handler = proc_dointvec_minmax,
  119. .extra1 = (void *)&one,
  120. .extra2 = (void *)&n_max_acks,
  121. },
  122. {
  123. .procname = "rx_mtu",
  124. .data = &rxrpc_rx_mtu,
  125. .maxlen = sizeof(unsigned int),
  126. .mode = 0644,
  127. .proc_handler = proc_dointvec_minmax,
  128. .extra1 = (void *)&one,
  129. .extra2 = (void *)&n_65535,
  130. },
  131. {
  132. .procname = "rx_jumbo_max",
  133. .data = &rxrpc_rx_jumbo_max,
  134. .maxlen = sizeof(unsigned int),
  135. .mode = 0644,
  136. .proc_handler = proc_dointvec_minmax,
  137. .extra1 = (void *)&one,
  138. .extra2 = (void *)&four,
  139. },
  140. { }
  141. };
  142. int __init rxrpc_sysctl_init(void)
  143. {
  144. rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
  145. rxrpc_sysctl_table);
  146. if (!rxrpc_sysctl_reg_table)
  147. return -ENOMEM;
  148. return 0;
  149. }
  150. void rxrpc_sysctl_exit(void)
  151. {
  152. if (rxrpc_sysctl_reg_table)
  153. unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
  154. }