sysctl.c 3.6 KB

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