sysctl.c 3.9 KB

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