sysctl_net_ax25.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
  8. */
  9. #include <linux/mm.h>
  10. #include <linux/slab.h>
  11. #include <linux/sysctl.h>
  12. #include <linux/spinlock.h>
  13. #include <net/ax25.h>
  14. static int min_ipdefmode[1], max_ipdefmode[] = {1};
  15. static int min_axdefmode[1], max_axdefmode[] = {1};
  16. static int min_backoff[1], max_backoff[] = {2};
  17. static int min_conmode[1], max_conmode[] = {2};
  18. static int min_window[] = {1}, max_window[] = {7};
  19. static int min_ewindow[] = {1}, max_ewindow[] = {63};
  20. static int min_t1[] = {1}, max_t1[] = {30000};
  21. static int min_t2[] = {1}, max_t2[] = {20000};
  22. static int min_t3[1], max_t3[] = {3600000};
  23. static int min_idle[1], max_idle[] = {65535000};
  24. static int min_n2[] = {1}, max_n2[] = {31};
  25. static int min_paclen[] = {1}, max_paclen[] = {512};
  26. static int min_proto[1], max_proto[] = { AX25_PROTO_MAX };
  27. #ifdef CONFIG_AX25_DAMA_SLAVE
  28. static int min_ds_timeout[1], max_ds_timeout[] = {65535000};
  29. #endif
  30. static struct ctl_table_header *ax25_table_header;
  31. static ctl_table *ax25_table;
  32. static int ax25_table_size;
  33. static struct ctl_path ax25_path[] = {
  34. { .procname = "net", },
  35. { .procname = "ax25", },
  36. { }
  37. };
  38. static const ctl_table ax25_param_table[] = {
  39. {
  40. .procname = "ip_default_mode",
  41. .maxlen = sizeof(int),
  42. .mode = 0644,
  43. .proc_handler = proc_dointvec_minmax,
  44. .extra1 = &min_ipdefmode,
  45. .extra2 = &max_ipdefmode
  46. },
  47. {
  48. .procname = "ax25_default_mode",
  49. .maxlen = sizeof(int),
  50. .mode = 0644,
  51. .proc_handler = proc_dointvec_minmax,
  52. .extra1 = &min_axdefmode,
  53. .extra2 = &max_axdefmode
  54. },
  55. {
  56. .procname = "backoff_type",
  57. .maxlen = sizeof(int),
  58. .mode = 0644,
  59. .proc_handler = proc_dointvec_minmax,
  60. .extra1 = &min_backoff,
  61. .extra2 = &max_backoff
  62. },
  63. {
  64. .procname = "connect_mode",
  65. .maxlen = sizeof(int),
  66. .mode = 0644,
  67. .proc_handler = proc_dointvec_minmax,
  68. .extra1 = &min_conmode,
  69. .extra2 = &max_conmode
  70. },
  71. {
  72. .procname = "standard_window_size",
  73. .maxlen = sizeof(int),
  74. .mode = 0644,
  75. .proc_handler = proc_dointvec_minmax,
  76. .extra1 = &min_window,
  77. .extra2 = &max_window
  78. },
  79. {
  80. .procname = "extended_window_size",
  81. .maxlen = sizeof(int),
  82. .mode = 0644,
  83. .proc_handler = proc_dointvec_minmax,
  84. .extra1 = &min_ewindow,
  85. .extra2 = &max_ewindow
  86. },
  87. {
  88. .procname = "t1_timeout",
  89. .maxlen = sizeof(int),
  90. .mode = 0644,
  91. .proc_handler = proc_dointvec_minmax,
  92. .extra1 = &min_t1,
  93. .extra2 = &max_t1
  94. },
  95. {
  96. .procname = "t2_timeout",
  97. .maxlen = sizeof(int),
  98. .mode = 0644,
  99. .proc_handler = proc_dointvec_minmax,
  100. .extra1 = &min_t2,
  101. .extra2 = &max_t2
  102. },
  103. {
  104. .procname = "t3_timeout",
  105. .maxlen = sizeof(int),
  106. .mode = 0644,
  107. .proc_handler = proc_dointvec_minmax,
  108. .extra1 = &min_t3,
  109. .extra2 = &max_t3
  110. },
  111. {
  112. .procname = "idle_timeout",
  113. .maxlen = sizeof(int),
  114. .mode = 0644,
  115. .proc_handler = proc_dointvec_minmax,
  116. .extra1 = &min_idle,
  117. .extra2 = &max_idle
  118. },
  119. {
  120. .procname = "maximum_retry_count",
  121. .maxlen = sizeof(int),
  122. .mode = 0644,
  123. .proc_handler = proc_dointvec_minmax,
  124. .extra1 = &min_n2,
  125. .extra2 = &max_n2
  126. },
  127. {
  128. .procname = "maximum_packet_length",
  129. .maxlen = sizeof(int),
  130. .mode = 0644,
  131. .proc_handler = proc_dointvec_minmax,
  132. .extra1 = &min_paclen,
  133. .extra2 = &max_paclen
  134. },
  135. {
  136. .procname = "protocol",
  137. .maxlen = sizeof(int),
  138. .mode = 0644,
  139. .proc_handler = proc_dointvec_minmax,
  140. .extra1 = &min_proto,
  141. .extra2 = &max_proto
  142. },
  143. #ifdef CONFIG_AX25_DAMA_SLAVE
  144. {
  145. .procname = "dama_slave_timeout",
  146. .maxlen = sizeof(int),
  147. .mode = 0644,
  148. .proc_handler = proc_dointvec_minmax,
  149. .extra1 = &min_ds_timeout,
  150. .extra2 = &max_ds_timeout
  151. },
  152. #endif
  153. { } /* that's all, folks! */
  154. };
  155. void ax25_register_sysctl(void)
  156. {
  157. ax25_dev *ax25_dev;
  158. int n, k;
  159. spin_lock_bh(&ax25_dev_lock);
  160. for (ax25_table_size = sizeof(ctl_table), ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
  161. ax25_table_size += sizeof(ctl_table);
  162. if ((ax25_table = kzalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
  163. spin_unlock_bh(&ax25_dev_lock);
  164. return;
  165. }
  166. for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
  167. struct ctl_table *child = kmemdup(ax25_param_table,
  168. sizeof(ax25_param_table),
  169. GFP_ATOMIC);
  170. if (!child) {
  171. while (n--)
  172. kfree(ax25_table[n].child);
  173. kfree(ax25_table);
  174. spin_unlock_bh(&ax25_dev_lock);
  175. return;
  176. }
  177. ax25_table[n].child = ax25_dev->systable = child;
  178. ax25_table[n].procname = ax25_dev->dev->name;
  179. ax25_table[n].mode = 0555;
  180. for (k = 0; k < AX25_MAX_VALUES; k++)
  181. child[k].data = &ax25_dev->values[k];
  182. n++;
  183. }
  184. spin_unlock_bh(&ax25_dev_lock);
  185. ax25_table_header = register_sysctl_paths(ax25_path, ax25_table);
  186. }
  187. void ax25_unregister_sysctl(void)
  188. {
  189. ctl_table *p;
  190. unregister_sysctl_table(ax25_table_header);
  191. for (p = ax25_table; p->procname; p++)
  192. kfree(p->child);
  193. kfree(ax25_table);
  194. }