sysctl.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* sysctls for configuring RxRPC operating parameters
  3. *
  4. * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells (dhowells@redhat.com)
  6. */
  7. #include <linux/sysctl.h>
  8. #include <net/sock.h>
  9. #include <net/af_rxrpc.h>
  10. #include "ar-internal.h"
  11. static struct ctl_table_header *rxrpc_sysctl_reg_table;
  12. static const unsigned int four = 4;
  13. static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
  14. static const unsigned int n_65535 = 65535;
  15. static const unsigned int n_max_acks = 255;
  16. static const unsigned long one_ms = 1;
  17. static const unsigned long max_ms = 1000;
  18. static const unsigned long one_jiffy = 1;
  19. static const unsigned long max_jiffies = MAX_JIFFY_OFFSET;
  20. #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
  21. static const unsigned long max_500 = 500;
  22. #endif
  23. /*
  24. * RxRPC operating parameters.
  25. *
  26. * See Documentation/networking/rxrpc.rst and the variable definitions for more
  27. * information on the individual parameters.
  28. */
  29. static struct ctl_table rxrpc_sysctl_table[] = {
  30. /* Values measured in milliseconds */
  31. {
  32. .procname = "soft_ack_delay",
  33. .data = &rxrpc_soft_ack_delay,
  34. .maxlen = sizeof(unsigned long),
  35. .mode = 0644,
  36. .proc_handler = proc_doulongvec_minmax,
  37. .extra1 = (void *)&one_ms,
  38. .extra2 = (void *)&max_ms,
  39. },
  40. {
  41. .procname = "idle_ack_delay",
  42. .data = &rxrpc_idle_ack_delay,
  43. .maxlen = sizeof(unsigned long),
  44. .mode = 0644,
  45. .proc_handler = proc_doulongvec_minmax,
  46. .extra1 = (void *)&one_ms,
  47. .extra2 = (void *)&max_ms,
  48. },
  49. {
  50. .procname = "idle_conn_expiry",
  51. .data = &rxrpc_conn_idle_client_expiry,
  52. .maxlen = sizeof(unsigned long),
  53. .mode = 0644,
  54. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  55. .extra1 = (void *)&one_jiffy,
  56. .extra2 = (void *)&max_jiffies,
  57. },
  58. {
  59. .procname = "idle_conn_fast_expiry",
  60. .data = &rxrpc_conn_idle_client_fast_expiry,
  61. .maxlen = sizeof(unsigned long),
  62. .mode = 0644,
  63. .proc_handler = proc_doulongvec_ms_jiffies_minmax,
  64. .extra1 = (void *)&one_jiffy,
  65. .extra2 = (void *)&max_jiffies,
  66. },
  67. /* Values used in milliseconds */
  68. #ifdef CONFIG_AF_RXRPC_INJECT_RX_DELAY
  69. {
  70. .procname = "inject_rx_delay",
  71. .data = &rxrpc_inject_rx_delay,
  72. .maxlen = sizeof(unsigned long),
  73. .mode = 0644,
  74. .proc_handler = proc_doulongvec_minmax,
  75. .extra1 = (void *)SYSCTL_LONG_ZERO,
  76. .extra2 = (void *)&max_500,
  77. },
  78. #endif
  79. /* Non-time values */
  80. {
  81. .procname = "reap_client_conns",
  82. .data = &rxrpc_reap_client_connections,
  83. .maxlen = sizeof(unsigned int),
  84. .mode = 0644,
  85. .proc_handler = proc_dointvec_minmax,
  86. .extra1 = (void *)SYSCTL_ONE,
  87. .extra2 = (void *)&n_65535,
  88. },
  89. {
  90. .procname = "max_backlog",
  91. .data = &rxrpc_max_backlog,
  92. .maxlen = sizeof(unsigned int),
  93. .mode = 0644,
  94. .proc_handler = proc_dointvec_minmax,
  95. .extra1 = (void *)&four,
  96. .extra2 = (void *)&max_backlog,
  97. },
  98. {
  99. .procname = "rx_window_size",
  100. .data = &rxrpc_rx_window_size,
  101. .maxlen = sizeof(unsigned int),
  102. .mode = 0644,
  103. .proc_handler = proc_dointvec_minmax,
  104. .extra1 = (void *)SYSCTL_ONE,
  105. .extra2 = (void *)&n_max_acks,
  106. },
  107. {
  108. .procname = "rx_mtu",
  109. .data = &rxrpc_rx_mtu,
  110. .maxlen = sizeof(unsigned int),
  111. .mode = 0644,
  112. .proc_handler = proc_dointvec_minmax,
  113. .extra1 = (void *)SYSCTL_ONE,
  114. .extra2 = (void *)&n_65535,
  115. },
  116. {
  117. .procname = "rx_jumbo_max",
  118. .data = &rxrpc_rx_jumbo_max,
  119. .maxlen = sizeof(unsigned int),
  120. .mode = 0644,
  121. .proc_handler = proc_dointvec_minmax,
  122. .extra1 = (void *)SYSCTL_ONE,
  123. .extra2 = (void *)&four,
  124. },
  125. };
  126. int __init rxrpc_sysctl_init(void)
  127. {
  128. rxrpc_sysctl_reg_table = register_net_sysctl(&init_net, "net/rxrpc",
  129. rxrpc_sysctl_table);
  130. if (!rxrpc_sysctl_reg_table)
  131. return -ENOMEM;
  132. return 0;
  133. }
  134. void rxrpc_sysctl_exit(void)
  135. {
  136. if (rxrpc_sysctl_reg_table)
  137. unregister_net_sysctl_table(rxrpc_sysctl_reg_table);
  138. }