sysctl_net_ipv4.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
  4. *
  5. * Begun April 1, 1996, Mike Shaver.
  6. * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
  7. */
  8. #include <linux/sysctl.h>
  9. #include <linux/seqlock.h>
  10. #include <linux/init.h>
  11. #include <linux/slab.h>
  12. #include <net/icmp.h>
  13. #include <net/ip.h>
  14. #include <net/ip_fib.h>
  15. #include <net/tcp.h>
  16. #include <net/udp.h>
  17. #include <net/cipso_ipv4.h>
  18. #include <net/ping.h>
  19. #include <net/protocol.h>
  20. #include <net/netevent.h>
  21. static int tcp_retr1_max = 255;
  22. static int ip_local_port_range_min[] = { 1, 1 };
  23. static int ip_local_port_range_max[] = { 65535, 65535 };
  24. static int tcp_adv_win_scale_min = -31;
  25. static int tcp_adv_win_scale_max = 31;
  26. static int tcp_app_win_max = 31;
  27. static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
  28. static int tcp_min_snd_mss_max = 65535;
  29. static int ip_privileged_port_min;
  30. static int ip_privileged_port_max = 65535;
  31. static int ip_ttl_min = 1;
  32. static int ip_ttl_max = 255;
  33. static int tcp_syn_retries_min = 1;
  34. static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
  35. static unsigned long ip_ping_group_range_min[] = { 0, 0 };
  36. static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
  37. static u32 u32_max_div_HZ = UINT_MAX / HZ;
  38. static int one_day_secs = 24 * 3600;
  39. static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
  40. FIB_MULTIPATH_HASH_FIELD_ALL_MASK;
  41. static unsigned int tcp_child_ehash_entries_max = 16 * 1024 * 1024;
  42. /* obsolete */
  43. static int sysctl_tcp_low_latency __read_mostly;
  44. /* Update system visible IP port range */
  45. static void set_local_port_range(struct net *net, int range[2])
  46. {
  47. bool same_parity = !((range[0] ^ range[1]) & 1);
  48. write_seqlock_bh(&net->ipv4.ip_local_ports.lock);
  49. if (same_parity && !net->ipv4.ip_local_ports.warned) {
  50. net->ipv4.ip_local_ports.warned = true;
  51. pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
  52. }
  53. net->ipv4.ip_local_ports.range[0] = range[0];
  54. net->ipv4.ip_local_ports.range[1] = range[1];
  55. write_sequnlock_bh(&net->ipv4.ip_local_ports.lock);
  56. }
  57. /* Validate changes from /proc interface. */
  58. static int ipv4_local_port_range(struct ctl_table *table, int write,
  59. void *buffer, size_t *lenp, loff_t *ppos)
  60. {
  61. struct net *net =
  62. container_of(table->data, struct net, ipv4.ip_local_ports.range);
  63. int ret;
  64. int range[2];
  65. struct ctl_table tmp = {
  66. .data = &range,
  67. .maxlen = sizeof(range),
  68. .mode = table->mode,
  69. .extra1 = &ip_local_port_range_min,
  70. .extra2 = &ip_local_port_range_max,
  71. };
  72. inet_get_local_port_range(net, &range[0], &range[1]);
  73. ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
  74. if (write && ret == 0) {
  75. /* Ensure that the upper limit is not smaller than the lower,
  76. * and that the lower does not encroach upon the privileged
  77. * port limit.
  78. */
  79. if ((range[1] < range[0]) ||
  80. (range[0] < READ_ONCE(net->ipv4.sysctl_ip_prot_sock)))
  81. ret = -EINVAL;
  82. else
  83. set_local_port_range(net, range);
  84. }
  85. return ret;
  86. }
  87. /* Validate changes from /proc interface. */
  88. static int ipv4_privileged_ports(struct ctl_table *table, int write,
  89. void *buffer, size_t *lenp, loff_t *ppos)
  90. {
  91. struct net *net = container_of(table->data, struct net,
  92. ipv4.sysctl_ip_prot_sock);
  93. int ret;
  94. int pports;
  95. int range[2];
  96. struct ctl_table tmp = {
  97. .data = &pports,
  98. .maxlen = sizeof(pports),
  99. .mode = table->mode,
  100. .extra1 = &ip_privileged_port_min,
  101. .extra2 = &ip_privileged_port_max,
  102. };
  103. pports = READ_ONCE(net->ipv4.sysctl_ip_prot_sock);
  104. ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
  105. if (write && ret == 0) {
  106. inet_get_local_port_range(net, &range[0], &range[1]);
  107. /* Ensure that the local port range doesn't overlap with the
  108. * privileged port range.
  109. */
  110. if (range[0] < pports)
  111. ret = -EINVAL;
  112. else
  113. WRITE_ONCE(net->ipv4.sysctl_ip_prot_sock, pports);
  114. }
  115. return ret;
  116. }
  117. static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
  118. {
  119. kgid_t *data = table->data;
  120. struct net *net =
  121. container_of(table->data, struct net, ipv4.ping_group_range.range);
  122. unsigned int seq;
  123. do {
  124. seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
  125. *low = data[0];
  126. *high = data[1];
  127. } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
  128. }
  129. /* Update system visible IP port range */
  130. static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
  131. {
  132. kgid_t *data = table->data;
  133. struct net *net =
  134. container_of(table->data, struct net, ipv4.ping_group_range.range);
  135. write_seqlock(&net->ipv4.ping_group_range.lock);
  136. data[0] = low;
  137. data[1] = high;
  138. write_sequnlock(&net->ipv4.ping_group_range.lock);
  139. }
  140. /* Validate changes from /proc interface. */
  141. static int ipv4_ping_group_range(struct ctl_table *table, int write,
  142. void *buffer, size_t *lenp, loff_t *ppos)
  143. {
  144. struct user_namespace *user_ns = current_user_ns();
  145. int ret;
  146. unsigned long urange[2];
  147. kgid_t low, high;
  148. struct ctl_table tmp = {
  149. .data = &urange,
  150. .maxlen = sizeof(urange),
  151. .mode = table->mode,
  152. .extra1 = &ip_ping_group_range_min,
  153. .extra2 = &ip_ping_group_range_max,
  154. };
  155. inet_get_ping_group_range_table(table, &low, &high);
  156. urange[0] = from_kgid_munged(user_ns, low);
  157. urange[1] = from_kgid_munged(user_ns, high);
  158. ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
  159. if (write && ret == 0) {
  160. low = make_kgid(user_ns, urange[0]);
  161. high = make_kgid(user_ns, urange[1]);
  162. if (!gid_valid(low) || !gid_valid(high))
  163. return -EINVAL;
  164. if (urange[1] < urange[0] || gid_lt(high, low)) {
  165. low = make_kgid(&init_user_ns, 1);
  166. high = make_kgid(&init_user_ns, 0);
  167. }
  168. set_ping_group_range(table, low, high);
  169. }
  170. return ret;
  171. }
  172. static int ipv4_fwd_update_priority(struct ctl_table *table, int write,
  173. void *buffer, size_t *lenp, loff_t *ppos)
  174. {
  175. struct net *net;
  176. int ret;
  177. net = container_of(table->data, struct net,
  178. ipv4.sysctl_ip_fwd_update_priority);
  179. ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
  180. if (write && ret == 0)
  181. call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
  182. net);
  183. return ret;
  184. }
  185. static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
  186. void *buffer, size_t *lenp, loff_t *ppos)
  187. {
  188. struct net *net = container_of(ctl->data, struct net,
  189. ipv4.tcp_congestion_control);
  190. char val[TCP_CA_NAME_MAX];
  191. struct ctl_table tbl = {
  192. .data = val,
  193. .maxlen = TCP_CA_NAME_MAX,
  194. };
  195. int ret;
  196. tcp_get_default_congestion_control(net, val);
  197. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  198. if (write && ret == 0)
  199. ret = tcp_set_default_congestion_control(net, val);
  200. return ret;
  201. }
  202. static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
  203. int write, void *buffer,
  204. size_t *lenp, loff_t *ppos)
  205. {
  206. struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
  207. int ret;
  208. tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  209. if (!tbl.data)
  210. return -ENOMEM;
  211. tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
  212. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  213. kfree(tbl.data);
  214. return ret;
  215. }
  216. static int proc_allowed_congestion_control(struct ctl_table *ctl,
  217. int write, void *buffer,
  218. size_t *lenp, loff_t *ppos)
  219. {
  220. struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
  221. int ret;
  222. tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  223. if (!tbl.data)
  224. return -ENOMEM;
  225. tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
  226. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  227. if (write && ret == 0)
  228. ret = tcp_set_allowed_congestion_control(tbl.data);
  229. kfree(tbl.data);
  230. return ret;
  231. }
  232. static int sscanf_key(char *buf, __le32 *key)
  233. {
  234. u32 user_key[4];
  235. int i, ret = 0;
  236. if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
  237. user_key + 2, user_key + 3) != 4) {
  238. ret = -EINVAL;
  239. } else {
  240. for (i = 0; i < ARRAY_SIZE(user_key); i++)
  241. key[i] = cpu_to_le32(user_key[i]);
  242. }
  243. pr_debug("proc TFO key set 0x%x-%x-%x-%x <- 0x%s: %u\n",
  244. user_key[0], user_key[1], user_key[2], user_key[3], buf, ret);
  245. return ret;
  246. }
  247. static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
  248. void *buffer, size_t *lenp, loff_t *ppos)
  249. {
  250. struct net *net = container_of(table->data, struct net,
  251. ipv4.sysctl_tcp_fastopen);
  252. /* maxlen to print the list of keys in hex (*2), with dashes
  253. * separating doublewords and a comma in between keys.
  254. */
  255. struct ctl_table tbl = { .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
  256. 2 * TCP_FASTOPEN_KEY_MAX) +
  257. (TCP_FASTOPEN_KEY_MAX * 5)) };
  258. u32 user_key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(u32)];
  259. __le32 key[TCP_FASTOPEN_KEY_BUF_LENGTH / sizeof(__le32)];
  260. char *backup_data;
  261. int ret, i = 0, off = 0, n_keys;
  262. tbl.data = kmalloc(tbl.maxlen, GFP_KERNEL);
  263. if (!tbl.data)
  264. return -ENOMEM;
  265. n_keys = tcp_fastopen_get_cipher(net, NULL, (u64 *)key);
  266. if (!n_keys) {
  267. memset(&key[0], 0, TCP_FASTOPEN_KEY_LENGTH);
  268. n_keys = 1;
  269. }
  270. for (i = 0; i < n_keys * 4; i++)
  271. user_key[i] = le32_to_cpu(key[i]);
  272. for (i = 0; i < n_keys; i++) {
  273. off += snprintf(tbl.data + off, tbl.maxlen - off,
  274. "%08x-%08x-%08x-%08x",
  275. user_key[i * 4],
  276. user_key[i * 4 + 1],
  277. user_key[i * 4 + 2],
  278. user_key[i * 4 + 3]);
  279. if (WARN_ON_ONCE(off >= tbl.maxlen - 1))
  280. break;
  281. if (i + 1 < n_keys)
  282. off += snprintf(tbl.data + off, tbl.maxlen - off, ",");
  283. }
  284. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  285. if (write && ret == 0) {
  286. backup_data = strchr(tbl.data, ',');
  287. if (backup_data) {
  288. *backup_data = '\0';
  289. backup_data++;
  290. }
  291. if (sscanf_key(tbl.data, key)) {
  292. ret = -EINVAL;
  293. goto bad_key;
  294. }
  295. if (backup_data) {
  296. if (sscanf_key(backup_data, key + 4)) {
  297. ret = -EINVAL;
  298. goto bad_key;
  299. }
  300. }
  301. tcp_fastopen_reset_cipher(net, NULL, key,
  302. backup_data ? key + 4 : NULL);
  303. }
  304. bad_key:
  305. kfree(tbl.data);
  306. return ret;
  307. }
  308. static int proc_tfo_blackhole_detect_timeout(struct ctl_table *table,
  309. int write, void *buffer,
  310. size_t *lenp, loff_t *ppos)
  311. {
  312. struct net *net = container_of(table->data, struct net,
  313. ipv4.sysctl_tcp_fastopen_blackhole_timeout);
  314. int ret;
  315. ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
  316. if (write && ret == 0)
  317. atomic_set(&net->ipv4.tfo_active_disable_times, 0);
  318. return ret;
  319. }
  320. static int proc_tcp_available_ulp(struct ctl_table *ctl,
  321. int write, void *buffer, size_t *lenp,
  322. loff_t *ppos)
  323. {
  324. struct ctl_table tbl = { .maxlen = TCP_ULP_BUF_MAX, };
  325. int ret;
  326. tbl.data = kmalloc(tbl.maxlen, GFP_USER);
  327. if (!tbl.data)
  328. return -ENOMEM;
  329. tcp_get_available_ulp(tbl.data, TCP_ULP_BUF_MAX);
  330. ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
  331. kfree(tbl.data);
  332. return ret;
  333. }
  334. static int proc_tcp_ehash_entries(struct ctl_table *table, int write,
  335. void *buffer, size_t *lenp, loff_t *ppos)
  336. {
  337. struct net *net = container_of(table->data, struct net,
  338. ipv4.sysctl_tcp_child_ehash_entries);
  339. struct inet_hashinfo *hinfo = net->ipv4.tcp_death_row.hashinfo;
  340. int tcp_ehash_entries;
  341. struct ctl_table tbl;
  342. tcp_ehash_entries = hinfo->ehash_mask + 1;
  343. /* A negative number indicates that the child netns
  344. * shares the global ehash.
  345. */
  346. if (!net_eq(net, &init_net) && !hinfo->pernet)
  347. tcp_ehash_entries *= -1;
  348. tbl.data = &tcp_ehash_entries;
  349. tbl.maxlen = sizeof(int);
  350. return proc_dointvec(&tbl, write, buffer, lenp, ppos);
  351. }
  352. #ifdef CONFIG_IP_ROUTE_MULTIPATH
  353. static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
  354. void *buffer, size_t *lenp,
  355. loff_t *ppos)
  356. {
  357. struct net *net = container_of(table->data, struct net,
  358. ipv4.sysctl_fib_multipath_hash_policy);
  359. int ret;
  360. ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
  361. if (write && ret == 0)
  362. call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
  363. return ret;
  364. }
  365. static int proc_fib_multipath_hash_fields(struct ctl_table *table, int write,
  366. void *buffer, size_t *lenp,
  367. loff_t *ppos)
  368. {
  369. struct net *net;
  370. int ret;
  371. net = container_of(table->data, struct net,
  372. ipv4.sysctl_fib_multipath_hash_fields);
  373. ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
  374. if (write && ret == 0)
  375. call_netevent_notifiers(NETEVENT_IPV4_MPATH_HASH_UPDATE, net);
  376. return ret;
  377. }
  378. #endif
  379. static struct ctl_table ipv4_table[] = {
  380. {
  381. .procname = "tcp_max_orphans",
  382. .data = &sysctl_tcp_max_orphans,
  383. .maxlen = sizeof(int),
  384. .mode = 0644,
  385. .proc_handler = proc_dointvec
  386. },
  387. {
  388. .procname = "inet_peer_threshold",
  389. .data = &inet_peer_threshold,
  390. .maxlen = sizeof(int),
  391. .mode = 0644,
  392. .proc_handler = proc_dointvec
  393. },
  394. {
  395. .procname = "inet_peer_minttl",
  396. .data = &inet_peer_minttl,
  397. .maxlen = sizeof(int),
  398. .mode = 0644,
  399. .proc_handler = proc_dointvec_jiffies,
  400. },
  401. {
  402. .procname = "inet_peer_maxttl",
  403. .data = &inet_peer_maxttl,
  404. .maxlen = sizeof(int),
  405. .mode = 0644,
  406. .proc_handler = proc_dointvec_jiffies,
  407. },
  408. {
  409. .procname = "tcp_mem",
  410. .maxlen = sizeof(sysctl_tcp_mem),
  411. .data = &sysctl_tcp_mem,
  412. .mode = 0644,
  413. .proc_handler = proc_doulongvec_minmax,
  414. },
  415. {
  416. .procname = "tcp_low_latency",
  417. .data = &sysctl_tcp_low_latency,
  418. .maxlen = sizeof(int),
  419. .mode = 0644,
  420. .proc_handler = proc_dointvec
  421. },
  422. #ifdef CONFIG_NETLABEL
  423. {
  424. .procname = "cipso_cache_enable",
  425. .data = &cipso_v4_cache_enabled,
  426. .maxlen = sizeof(int),
  427. .mode = 0644,
  428. .proc_handler = proc_dointvec,
  429. },
  430. {
  431. .procname = "cipso_cache_bucket_size",
  432. .data = &cipso_v4_cache_bucketsize,
  433. .maxlen = sizeof(int),
  434. .mode = 0644,
  435. .proc_handler = proc_dointvec,
  436. },
  437. {
  438. .procname = "cipso_rbm_optfmt",
  439. .data = &cipso_v4_rbm_optfmt,
  440. .maxlen = sizeof(int),
  441. .mode = 0644,
  442. .proc_handler = proc_dointvec,
  443. },
  444. {
  445. .procname = "cipso_rbm_strictvalid",
  446. .data = &cipso_v4_rbm_strictvalid,
  447. .maxlen = sizeof(int),
  448. .mode = 0644,
  449. .proc_handler = proc_dointvec,
  450. },
  451. #endif /* CONFIG_NETLABEL */
  452. {
  453. .procname = "tcp_available_ulp",
  454. .maxlen = TCP_ULP_BUF_MAX,
  455. .mode = 0444,
  456. .proc_handler = proc_tcp_available_ulp,
  457. },
  458. {
  459. .procname = "icmp_msgs_per_sec",
  460. .data = &sysctl_icmp_msgs_per_sec,
  461. .maxlen = sizeof(int),
  462. .mode = 0644,
  463. .proc_handler = proc_dointvec_minmax,
  464. .extra1 = SYSCTL_ZERO,
  465. },
  466. {
  467. .procname = "icmp_msgs_burst",
  468. .data = &sysctl_icmp_msgs_burst,
  469. .maxlen = sizeof(int),
  470. .mode = 0644,
  471. .proc_handler = proc_dointvec_minmax,
  472. .extra1 = SYSCTL_ZERO,
  473. },
  474. {
  475. .procname = "udp_mem",
  476. .data = &sysctl_udp_mem,
  477. .maxlen = sizeof(sysctl_udp_mem),
  478. .mode = 0644,
  479. .proc_handler = proc_doulongvec_minmax,
  480. },
  481. {
  482. .procname = "fib_sync_mem",
  483. .data = &sysctl_fib_sync_mem,
  484. .maxlen = sizeof(sysctl_fib_sync_mem),
  485. .mode = 0644,
  486. .proc_handler = proc_douintvec_minmax,
  487. .extra1 = &sysctl_fib_sync_mem_min,
  488. .extra2 = &sysctl_fib_sync_mem_max,
  489. },
  490. { }
  491. };
  492. static struct ctl_table ipv4_net_table[] = {
  493. {
  494. .procname = "tcp_max_tw_buckets",
  495. .data = &init_net.ipv4.tcp_death_row.sysctl_max_tw_buckets,
  496. .maxlen = sizeof(int),
  497. .mode = 0644,
  498. .proc_handler = proc_dointvec
  499. },
  500. {
  501. .procname = "icmp_echo_ignore_all",
  502. .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all,
  503. .maxlen = sizeof(u8),
  504. .mode = 0644,
  505. .proc_handler = proc_dou8vec_minmax,
  506. .extra1 = SYSCTL_ZERO,
  507. .extra2 = SYSCTL_ONE
  508. },
  509. {
  510. .procname = "icmp_echo_enable_probe",
  511. .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe,
  512. .maxlen = sizeof(u8),
  513. .mode = 0644,
  514. .proc_handler = proc_dou8vec_minmax,
  515. .extra1 = SYSCTL_ZERO,
  516. .extra2 = SYSCTL_ONE
  517. },
  518. {
  519. .procname = "icmp_echo_ignore_broadcasts",
  520. .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts,
  521. .maxlen = sizeof(u8),
  522. .mode = 0644,
  523. .proc_handler = proc_dou8vec_minmax,
  524. .extra1 = SYSCTL_ZERO,
  525. .extra2 = SYSCTL_ONE
  526. },
  527. {
  528. .procname = "icmp_ignore_bogus_error_responses",
  529. .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses,
  530. .maxlen = sizeof(u8),
  531. .mode = 0644,
  532. .proc_handler = proc_dou8vec_minmax,
  533. .extra1 = SYSCTL_ZERO,
  534. .extra2 = SYSCTL_ONE
  535. },
  536. {
  537. .procname = "icmp_errors_use_inbound_ifaddr",
  538. .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr,
  539. .maxlen = sizeof(u8),
  540. .mode = 0644,
  541. .proc_handler = proc_dou8vec_minmax,
  542. .extra1 = SYSCTL_ZERO,
  543. .extra2 = SYSCTL_ONE
  544. },
  545. {
  546. .procname = "icmp_ratelimit",
  547. .data = &init_net.ipv4.sysctl_icmp_ratelimit,
  548. .maxlen = sizeof(int),
  549. .mode = 0644,
  550. .proc_handler = proc_dointvec_ms_jiffies,
  551. },
  552. {
  553. .procname = "icmp_ratemask",
  554. .data = &init_net.ipv4.sysctl_icmp_ratemask,
  555. .maxlen = sizeof(int),
  556. .mode = 0644,
  557. .proc_handler = proc_dointvec
  558. },
  559. {
  560. .procname = "ping_group_range",
  561. .data = &init_net.ipv4.ping_group_range.range,
  562. .maxlen = sizeof(gid_t)*2,
  563. .mode = 0644,
  564. .proc_handler = ipv4_ping_group_range,
  565. },
  566. #ifdef CONFIG_NET_L3_MASTER_DEV
  567. {
  568. .procname = "raw_l3mdev_accept",
  569. .data = &init_net.ipv4.sysctl_raw_l3mdev_accept,
  570. .maxlen = sizeof(u8),
  571. .mode = 0644,
  572. .proc_handler = proc_dou8vec_minmax,
  573. .extra1 = SYSCTL_ZERO,
  574. .extra2 = SYSCTL_ONE,
  575. },
  576. #endif
  577. {
  578. .procname = "tcp_ecn",
  579. .data = &init_net.ipv4.sysctl_tcp_ecn,
  580. .maxlen = sizeof(u8),
  581. .mode = 0644,
  582. .proc_handler = proc_dou8vec_minmax,
  583. .extra1 = SYSCTL_ZERO,
  584. .extra2 = SYSCTL_TWO,
  585. },
  586. {
  587. .procname = "tcp_ecn_fallback",
  588. .data = &init_net.ipv4.sysctl_tcp_ecn_fallback,
  589. .maxlen = sizeof(u8),
  590. .mode = 0644,
  591. .proc_handler = proc_dou8vec_minmax,
  592. .extra1 = SYSCTL_ZERO,
  593. .extra2 = SYSCTL_ONE,
  594. },
  595. {
  596. .procname = "ip_dynaddr",
  597. .data = &init_net.ipv4.sysctl_ip_dynaddr,
  598. .maxlen = sizeof(u8),
  599. .mode = 0644,
  600. .proc_handler = proc_dou8vec_minmax,
  601. },
  602. {
  603. .procname = "ip_early_demux",
  604. .data = &init_net.ipv4.sysctl_ip_early_demux,
  605. .maxlen = sizeof(u8),
  606. .mode = 0644,
  607. .proc_handler = proc_dou8vec_minmax,
  608. },
  609. {
  610. .procname = "udp_early_demux",
  611. .data = &init_net.ipv4.sysctl_udp_early_demux,
  612. .maxlen = sizeof(u8),
  613. .mode = 0644,
  614. .proc_handler = proc_dou8vec_minmax,
  615. },
  616. {
  617. .procname = "tcp_early_demux",
  618. .data = &init_net.ipv4.sysctl_tcp_early_demux,
  619. .maxlen = sizeof(u8),
  620. .mode = 0644,
  621. .proc_handler = proc_dou8vec_minmax,
  622. },
  623. {
  624. .procname = "nexthop_compat_mode",
  625. .data = &init_net.ipv4.sysctl_nexthop_compat_mode,
  626. .maxlen = sizeof(u8),
  627. .mode = 0644,
  628. .proc_handler = proc_dou8vec_minmax,
  629. .extra1 = SYSCTL_ZERO,
  630. .extra2 = SYSCTL_ONE,
  631. },
  632. {
  633. .procname = "ip_default_ttl",
  634. .data = &init_net.ipv4.sysctl_ip_default_ttl,
  635. .maxlen = sizeof(u8),
  636. .mode = 0644,
  637. .proc_handler = proc_dou8vec_minmax,
  638. .extra1 = &ip_ttl_min,
  639. .extra2 = &ip_ttl_max,
  640. },
  641. {
  642. .procname = "ip_local_port_range",
  643. .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
  644. .data = &init_net.ipv4.ip_local_ports.range,
  645. .mode = 0644,
  646. .proc_handler = ipv4_local_port_range,
  647. },
  648. {
  649. .procname = "ip_local_reserved_ports",
  650. .data = &init_net.ipv4.sysctl_local_reserved_ports,
  651. .maxlen = 65536,
  652. .mode = 0644,
  653. .proc_handler = proc_do_large_bitmap,
  654. },
  655. {
  656. .procname = "ip_no_pmtu_disc",
  657. .data = &init_net.ipv4.sysctl_ip_no_pmtu_disc,
  658. .maxlen = sizeof(u8),
  659. .mode = 0644,
  660. .proc_handler = proc_dou8vec_minmax,
  661. },
  662. {
  663. .procname = "ip_forward_use_pmtu",
  664. .data = &init_net.ipv4.sysctl_ip_fwd_use_pmtu,
  665. .maxlen = sizeof(u8),
  666. .mode = 0644,
  667. .proc_handler = proc_dou8vec_minmax,
  668. },
  669. {
  670. .procname = "ip_forward_update_priority",
  671. .data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
  672. .maxlen = sizeof(u8),
  673. .mode = 0644,
  674. .proc_handler = ipv4_fwd_update_priority,
  675. .extra1 = SYSCTL_ZERO,
  676. .extra2 = SYSCTL_ONE,
  677. },
  678. {
  679. .procname = "ip_nonlocal_bind",
  680. .data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
  681. .maxlen = sizeof(u8),
  682. .mode = 0644,
  683. .proc_handler = proc_dou8vec_minmax,
  684. },
  685. {
  686. .procname = "ip_autobind_reuse",
  687. .data = &init_net.ipv4.sysctl_ip_autobind_reuse,
  688. .maxlen = sizeof(u8),
  689. .mode = 0644,
  690. .proc_handler = proc_dou8vec_minmax,
  691. .extra1 = SYSCTL_ZERO,
  692. .extra2 = SYSCTL_ONE,
  693. },
  694. {
  695. .procname = "fwmark_reflect",
  696. .data = &init_net.ipv4.sysctl_fwmark_reflect,
  697. .maxlen = sizeof(u8),
  698. .mode = 0644,
  699. .proc_handler = proc_dou8vec_minmax,
  700. },
  701. {
  702. .procname = "tcp_fwmark_accept",
  703. .data = &init_net.ipv4.sysctl_tcp_fwmark_accept,
  704. .maxlen = sizeof(u8),
  705. .mode = 0644,
  706. .proc_handler = proc_dou8vec_minmax,
  707. },
  708. #ifdef CONFIG_NET_L3_MASTER_DEV
  709. {
  710. .procname = "tcp_l3mdev_accept",
  711. .data = &init_net.ipv4.sysctl_tcp_l3mdev_accept,
  712. .maxlen = sizeof(u8),
  713. .mode = 0644,
  714. .proc_handler = proc_dou8vec_minmax,
  715. .extra1 = SYSCTL_ZERO,
  716. .extra2 = SYSCTL_ONE,
  717. },
  718. #endif
  719. {
  720. .procname = "tcp_mtu_probing",
  721. .data = &init_net.ipv4.sysctl_tcp_mtu_probing,
  722. .maxlen = sizeof(u8),
  723. .mode = 0644,
  724. .proc_handler = proc_dou8vec_minmax,
  725. },
  726. {
  727. .procname = "tcp_base_mss",
  728. .data = &init_net.ipv4.sysctl_tcp_base_mss,
  729. .maxlen = sizeof(int),
  730. .mode = 0644,
  731. .proc_handler = proc_dointvec,
  732. },
  733. {
  734. .procname = "tcp_min_snd_mss",
  735. .data = &init_net.ipv4.sysctl_tcp_min_snd_mss,
  736. .maxlen = sizeof(int),
  737. .mode = 0644,
  738. .proc_handler = proc_dointvec_minmax,
  739. .extra1 = &tcp_min_snd_mss_min,
  740. .extra2 = &tcp_min_snd_mss_max,
  741. },
  742. {
  743. .procname = "tcp_mtu_probe_floor",
  744. .data = &init_net.ipv4.sysctl_tcp_mtu_probe_floor,
  745. .maxlen = sizeof(int),
  746. .mode = 0644,
  747. .proc_handler = proc_dointvec_minmax,
  748. .extra1 = &tcp_min_snd_mss_min,
  749. .extra2 = &tcp_min_snd_mss_max,
  750. },
  751. {
  752. .procname = "tcp_probe_threshold",
  753. .data = &init_net.ipv4.sysctl_tcp_probe_threshold,
  754. .maxlen = sizeof(int),
  755. .mode = 0644,
  756. .proc_handler = proc_dointvec,
  757. },
  758. {
  759. .procname = "tcp_probe_interval",
  760. .data = &init_net.ipv4.sysctl_tcp_probe_interval,
  761. .maxlen = sizeof(u32),
  762. .mode = 0644,
  763. .proc_handler = proc_douintvec_minmax,
  764. .extra2 = &u32_max_div_HZ,
  765. },
  766. {
  767. .procname = "igmp_link_local_mcast_reports",
  768. .data = &init_net.ipv4.sysctl_igmp_llm_reports,
  769. .maxlen = sizeof(u8),
  770. .mode = 0644,
  771. .proc_handler = proc_dou8vec_minmax,
  772. },
  773. {
  774. .procname = "igmp_max_memberships",
  775. .data = &init_net.ipv4.sysctl_igmp_max_memberships,
  776. .maxlen = sizeof(int),
  777. .mode = 0644,
  778. .proc_handler = proc_dointvec
  779. },
  780. {
  781. .procname = "igmp_max_msf",
  782. .data = &init_net.ipv4.sysctl_igmp_max_msf,
  783. .maxlen = sizeof(int),
  784. .mode = 0644,
  785. .proc_handler = proc_dointvec
  786. },
  787. #ifdef CONFIG_IP_MULTICAST
  788. {
  789. .procname = "igmp_qrv",
  790. .data = &init_net.ipv4.sysctl_igmp_qrv,
  791. .maxlen = sizeof(int),
  792. .mode = 0644,
  793. .proc_handler = proc_dointvec_minmax,
  794. .extra1 = SYSCTL_ONE
  795. },
  796. #endif
  797. {
  798. .procname = "tcp_congestion_control",
  799. .data = &init_net.ipv4.tcp_congestion_control,
  800. .mode = 0644,
  801. .maxlen = TCP_CA_NAME_MAX,
  802. .proc_handler = proc_tcp_congestion_control,
  803. },
  804. {
  805. .procname = "tcp_available_congestion_control",
  806. .maxlen = TCP_CA_BUF_MAX,
  807. .mode = 0444,
  808. .proc_handler = proc_tcp_available_congestion_control,
  809. },
  810. {
  811. .procname = "tcp_allowed_congestion_control",
  812. .maxlen = TCP_CA_BUF_MAX,
  813. .mode = 0644,
  814. .proc_handler = proc_allowed_congestion_control,
  815. },
  816. {
  817. .procname = "tcp_keepalive_time",
  818. .data = &init_net.ipv4.sysctl_tcp_keepalive_time,
  819. .maxlen = sizeof(int),
  820. .mode = 0644,
  821. .proc_handler = proc_dointvec_jiffies,
  822. },
  823. {
  824. .procname = "tcp_keepalive_probes",
  825. .data = &init_net.ipv4.sysctl_tcp_keepalive_probes,
  826. .maxlen = sizeof(u8),
  827. .mode = 0644,
  828. .proc_handler = proc_dou8vec_minmax,
  829. },
  830. {
  831. .procname = "tcp_keepalive_intvl",
  832. .data = &init_net.ipv4.sysctl_tcp_keepalive_intvl,
  833. .maxlen = sizeof(int),
  834. .mode = 0644,
  835. .proc_handler = proc_dointvec_jiffies,
  836. },
  837. {
  838. .procname = "tcp_syn_retries",
  839. .data = &init_net.ipv4.sysctl_tcp_syn_retries,
  840. .maxlen = sizeof(u8),
  841. .mode = 0644,
  842. .proc_handler = proc_dou8vec_minmax,
  843. .extra1 = &tcp_syn_retries_min,
  844. .extra2 = &tcp_syn_retries_max
  845. },
  846. {
  847. .procname = "tcp_synack_retries",
  848. .data = &init_net.ipv4.sysctl_tcp_synack_retries,
  849. .maxlen = sizeof(u8),
  850. .mode = 0644,
  851. .proc_handler = proc_dou8vec_minmax,
  852. },
  853. #ifdef CONFIG_SYN_COOKIES
  854. {
  855. .procname = "tcp_syncookies",
  856. .data = &init_net.ipv4.sysctl_tcp_syncookies,
  857. .maxlen = sizeof(u8),
  858. .mode = 0644,
  859. .proc_handler = proc_dou8vec_minmax,
  860. },
  861. #endif
  862. {
  863. .procname = "tcp_migrate_req",
  864. .data = &init_net.ipv4.sysctl_tcp_migrate_req,
  865. .maxlen = sizeof(u8),
  866. .mode = 0644,
  867. .proc_handler = proc_dou8vec_minmax,
  868. .extra1 = SYSCTL_ZERO,
  869. .extra2 = SYSCTL_ONE
  870. },
  871. {
  872. .procname = "tcp_reordering",
  873. .data = &init_net.ipv4.sysctl_tcp_reordering,
  874. .maxlen = sizeof(int),
  875. .mode = 0644,
  876. .proc_handler = proc_dointvec
  877. },
  878. {
  879. .procname = "tcp_retries1",
  880. .data = &init_net.ipv4.sysctl_tcp_retries1,
  881. .maxlen = sizeof(u8),
  882. .mode = 0644,
  883. .proc_handler = proc_dou8vec_minmax,
  884. .extra2 = &tcp_retr1_max
  885. },
  886. {
  887. .procname = "tcp_retries2",
  888. .data = &init_net.ipv4.sysctl_tcp_retries2,
  889. .maxlen = sizeof(u8),
  890. .mode = 0644,
  891. .proc_handler = proc_dou8vec_minmax,
  892. },
  893. {
  894. .procname = "tcp_orphan_retries",
  895. .data = &init_net.ipv4.sysctl_tcp_orphan_retries,
  896. .maxlen = sizeof(u8),
  897. .mode = 0644,
  898. .proc_handler = proc_dou8vec_minmax,
  899. },
  900. {
  901. .procname = "tcp_fin_timeout",
  902. .data = &init_net.ipv4.sysctl_tcp_fin_timeout,
  903. .maxlen = sizeof(int),
  904. .mode = 0644,
  905. .proc_handler = proc_dointvec_jiffies,
  906. },
  907. {
  908. .procname = "tcp_notsent_lowat",
  909. .data = &init_net.ipv4.sysctl_tcp_notsent_lowat,
  910. .maxlen = sizeof(unsigned int),
  911. .mode = 0644,
  912. .proc_handler = proc_douintvec,
  913. },
  914. {
  915. .procname = "tcp_tw_reuse",
  916. .data = &init_net.ipv4.sysctl_tcp_tw_reuse,
  917. .maxlen = sizeof(u8),
  918. .mode = 0644,
  919. .proc_handler = proc_dou8vec_minmax,
  920. .extra1 = SYSCTL_ZERO,
  921. .extra2 = SYSCTL_TWO,
  922. },
  923. {
  924. .procname = "tcp_max_syn_backlog",
  925. .data = &init_net.ipv4.sysctl_max_syn_backlog,
  926. .maxlen = sizeof(int),
  927. .mode = 0644,
  928. .proc_handler = proc_dointvec
  929. },
  930. {
  931. .procname = "tcp_fastopen",
  932. .data = &init_net.ipv4.sysctl_tcp_fastopen,
  933. .maxlen = sizeof(int),
  934. .mode = 0644,
  935. .proc_handler = proc_dointvec,
  936. },
  937. {
  938. .procname = "tcp_fastopen_key",
  939. .mode = 0600,
  940. .data = &init_net.ipv4.sysctl_tcp_fastopen,
  941. /* maxlen to print the list of keys in hex (*2), with dashes
  942. * separating doublewords and a comma in between keys.
  943. */
  944. .maxlen = ((TCP_FASTOPEN_KEY_LENGTH *
  945. 2 * TCP_FASTOPEN_KEY_MAX) +
  946. (TCP_FASTOPEN_KEY_MAX * 5)),
  947. .proc_handler = proc_tcp_fastopen_key,
  948. },
  949. {
  950. .procname = "tcp_fastopen_blackhole_timeout_sec",
  951. .data = &init_net.ipv4.sysctl_tcp_fastopen_blackhole_timeout,
  952. .maxlen = sizeof(int),
  953. .mode = 0644,
  954. .proc_handler = proc_tfo_blackhole_detect_timeout,
  955. .extra1 = SYSCTL_ZERO,
  956. },
  957. #ifdef CONFIG_IP_ROUTE_MULTIPATH
  958. {
  959. .procname = "fib_multipath_use_neigh",
  960. .data = &init_net.ipv4.sysctl_fib_multipath_use_neigh,
  961. .maxlen = sizeof(u8),
  962. .mode = 0644,
  963. .proc_handler = proc_dou8vec_minmax,
  964. .extra1 = SYSCTL_ZERO,
  965. .extra2 = SYSCTL_ONE,
  966. },
  967. {
  968. .procname = "fib_multipath_hash_policy",
  969. .data = &init_net.ipv4.sysctl_fib_multipath_hash_policy,
  970. .maxlen = sizeof(u8),
  971. .mode = 0644,
  972. .proc_handler = proc_fib_multipath_hash_policy,
  973. .extra1 = SYSCTL_ZERO,
  974. .extra2 = SYSCTL_THREE,
  975. },
  976. {
  977. .procname = "fib_multipath_hash_fields",
  978. .data = &init_net.ipv4.sysctl_fib_multipath_hash_fields,
  979. .maxlen = sizeof(u32),
  980. .mode = 0644,
  981. .proc_handler = proc_fib_multipath_hash_fields,
  982. .extra1 = SYSCTL_ONE,
  983. .extra2 = &fib_multipath_hash_fields_all_mask,
  984. },
  985. #endif
  986. {
  987. .procname = "ip_unprivileged_port_start",
  988. .maxlen = sizeof(int),
  989. .data = &init_net.ipv4.sysctl_ip_prot_sock,
  990. .mode = 0644,
  991. .proc_handler = ipv4_privileged_ports,
  992. },
  993. #ifdef CONFIG_NET_L3_MASTER_DEV
  994. {
  995. .procname = "udp_l3mdev_accept",
  996. .data = &init_net.ipv4.sysctl_udp_l3mdev_accept,
  997. .maxlen = sizeof(u8),
  998. .mode = 0644,
  999. .proc_handler = proc_dou8vec_minmax,
  1000. .extra1 = SYSCTL_ZERO,
  1001. .extra2 = SYSCTL_ONE,
  1002. },
  1003. #endif
  1004. {
  1005. .procname = "tcp_sack",
  1006. .data = &init_net.ipv4.sysctl_tcp_sack,
  1007. .maxlen = sizeof(u8),
  1008. .mode = 0644,
  1009. .proc_handler = proc_dou8vec_minmax,
  1010. },
  1011. {
  1012. .procname = "tcp_window_scaling",
  1013. .data = &init_net.ipv4.sysctl_tcp_window_scaling,
  1014. .maxlen = sizeof(u8),
  1015. .mode = 0644,
  1016. .proc_handler = proc_dou8vec_minmax,
  1017. },
  1018. {
  1019. .procname = "tcp_timestamps",
  1020. .data = &init_net.ipv4.sysctl_tcp_timestamps,
  1021. .maxlen = sizeof(u8),
  1022. .mode = 0644,
  1023. .proc_handler = proc_dou8vec_minmax,
  1024. },
  1025. {
  1026. .procname = "tcp_early_retrans",
  1027. .data = &init_net.ipv4.sysctl_tcp_early_retrans,
  1028. .maxlen = sizeof(u8),
  1029. .mode = 0644,
  1030. .proc_handler = proc_dou8vec_minmax,
  1031. .extra1 = SYSCTL_ZERO,
  1032. .extra2 = SYSCTL_FOUR,
  1033. },
  1034. {
  1035. .procname = "tcp_recovery",
  1036. .data = &init_net.ipv4.sysctl_tcp_recovery,
  1037. .maxlen = sizeof(u8),
  1038. .mode = 0644,
  1039. .proc_handler = proc_dou8vec_minmax,
  1040. },
  1041. {
  1042. .procname = "tcp_thin_linear_timeouts",
  1043. .data = &init_net.ipv4.sysctl_tcp_thin_linear_timeouts,
  1044. .maxlen = sizeof(u8),
  1045. .mode = 0644,
  1046. .proc_handler = proc_dou8vec_minmax,
  1047. },
  1048. {
  1049. .procname = "tcp_slow_start_after_idle",
  1050. .data = &init_net.ipv4.sysctl_tcp_slow_start_after_idle,
  1051. .maxlen = sizeof(u8),
  1052. .mode = 0644,
  1053. .proc_handler = proc_dou8vec_minmax,
  1054. },
  1055. {
  1056. .procname = "tcp_retrans_collapse",
  1057. .data = &init_net.ipv4.sysctl_tcp_retrans_collapse,
  1058. .maxlen = sizeof(u8),
  1059. .mode = 0644,
  1060. .proc_handler = proc_dou8vec_minmax,
  1061. },
  1062. {
  1063. .procname = "tcp_stdurg",
  1064. .data = &init_net.ipv4.sysctl_tcp_stdurg,
  1065. .maxlen = sizeof(u8),
  1066. .mode = 0644,
  1067. .proc_handler = proc_dou8vec_minmax,
  1068. },
  1069. {
  1070. .procname = "tcp_rfc1337",
  1071. .data = &init_net.ipv4.sysctl_tcp_rfc1337,
  1072. .maxlen = sizeof(u8),
  1073. .mode = 0644,
  1074. .proc_handler = proc_dou8vec_minmax,
  1075. },
  1076. {
  1077. .procname = "tcp_abort_on_overflow",
  1078. .data = &init_net.ipv4.sysctl_tcp_abort_on_overflow,
  1079. .maxlen = sizeof(u8),
  1080. .mode = 0644,
  1081. .proc_handler = proc_dou8vec_minmax,
  1082. },
  1083. {
  1084. .procname = "tcp_fack",
  1085. .data = &init_net.ipv4.sysctl_tcp_fack,
  1086. .maxlen = sizeof(u8),
  1087. .mode = 0644,
  1088. .proc_handler = proc_dou8vec_minmax,
  1089. },
  1090. {
  1091. .procname = "tcp_max_reordering",
  1092. .data = &init_net.ipv4.sysctl_tcp_max_reordering,
  1093. .maxlen = sizeof(int),
  1094. .mode = 0644,
  1095. .proc_handler = proc_dointvec
  1096. },
  1097. {
  1098. .procname = "tcp_dsack",
  1099. .data = &init_net.ipv4.sysctl_tcp_dsack,
  1100. .maxlen = sizeof(u8),
  1101. .mode = 0644,
  1102. .proc_handler = proc_dou8vec_minmax,
  1103. },
  1104. {
  1105. .procname = "tcp_app_win",
  1106. .data = &init_net.ipv4.sysctl_tcp_app_win,
  1107. .maxlen = sizeof(u8),
  1108. .mode = 0644,
  1109. .proc_handler = proc_dou8vec_minmax,
  1110. .extra1 = SYSCTL_ZERO,
  1111. .extra2 = &tcp_app_win_max,
  1112. },
  1113. {
  1114. .procname = "tcp_adv_win_scale",
  1115. .data = &init_net.ipv4.sysctl_tcp_adv_win_scale,
  1116. .maxlen = sizeof(int),
  1117. .mode = 0644,
  1118. .proc_handler = proc_dointvec_minmax,
  1119. .extra1 = &tcp_adv_win_scale_min,
  1120. .extra2 = &tcp_adv_win_scale_max,
  1121. },
  1122. {
  1123. .procname = "tcp_frto",
  1124. .data = &init_net.ipv4.sysctl_tcp_frto,
  1125. .maxlen = sizeof(u8),
  1126. .mode = 0644,
  1127. .proc_handler = proc_dou8vec_minmax,
  1128. },
  1129. {
  1130. .procname = "tcp_no_metrics_save",
  1131. .data = &init_net.ipv4.sysctl_tcp_nometrics_save,
  1132. .maxlen = sizeof(u8),
  1133. .mode = 0644,
  1134. .proc_handler = proc_dou8vec_minmax,
  1135. },
  1136. {
  1137. .procname = "tcp_no_ssthresh_metrics_save",
  1138. .data = &init_net.ipv4.sysctl_tcp_no_ssthresh_metrics_save,
  1139. .maxlen = sizeof(u8),
  1140. .mode = 0644,
  1141. .proc_handler = proc_dou8vec_minmax,
  1142. .extra1 = SYSCTL_ZERO,
  1143. .extra2 = SYSCTL_ONE,
  1144. },
  1145. {
  1146. .procname = "tcp_moderate_rcvbuf",
  1147. .data = &init_net.ipv4.sysctl_tcp_moderate_rcvbuf,
  1148. .maxlen = sizeof(u8),
  1149. .mode = 0644,
  1150. .proc_handler = proc_dou8vec_minmax,
  1151. },
  1152. {
  1153. .procname = "tcp_tso_win_divisor",
  1154. .data = &init_net.ipv4.sysctl_tcp_tso_win_divisor,
  1155. .maxlen = sizeof(u8),
  1156. .mode = 0644,
  1157. .proc_handler = proc_dou8vec_minmax,
  1158. },
  1159. {
  1160. .procname = "tcp_workaround_signed_windows",
  1161. .data = &init_net.ipv4.sysctl_tcp_workaround_signed_windows,
  1162. .maxlen = sizeof(u8),
  1163. .mode = 0644,
  1164. .proc_handler = proc_dou8vec_minmax,
  1165. },
  1166. {
  1167. .procname = "tcp_limit_output_bytes",
  1168. .data = &init_net.ipv4.sysctl_tcp_limit_output_bytes,
  1169. .maxlen = sizeof(int),
  1170. .mode = 0644,
  1171. .proc_handler = proc_dointvec
  1172. },
  1173. {
  1174. .procname = "tcp_challenge_ack_limit",
  1175. .data = &init_net.ipv4.sysctl_tcp_challenge_ack_limit,
  1176. .maxlen = sizeof(int),
  1177. .mode = 0644,
  1178. .proc_handler = proc_dointvec
  1179. },
  1180. {
  1181. .procname = "tcp_min_tso_segs",
  1182. .data = &init_net.ipv4.sysctl_tcp_min_tso_segs,
  1183. .maxlen = sizeof(u8),
  1184. .mode = 0644,
  1185. .proc_handler = proc_dou8vec_minmax,
  1186. .extra1 = SYSCTL_ONE,
  1187. },
  1188. {
  1189. .procname = "tcp_tso_rtt_log",
  1190. .data = &init_net.ipv4.sysctl_tcp_tso_rtt_log,
  1191. .maxlen = sizeof(u8),
  1192. .mode = 0644,
  1193. .proc_handler = proc_dou8vec_minmax,
  1194. },
  1195. {
  1196. .procname = "tcp_min_rtt_wlen",
  1197. .data = &init_net.ipv4.sysctl_tcp_min_rtt_wlen,
  1198. .maxlen = sizeof(int),
  1199. .mode = 0644,
  1200. .proc_handler = proc_dointvec_minmax,
  1201. .extra1 = SYSCTL_ZERO,
  1202. .extra2 = &one_day_secs
  1203. },
  1204. {
  1205. .procname = "tcp_autocorking",
  1206. .data = &init_net.ipv4.sysctl_tcp_autocorking,
  1207. .maxlen = sizeof(u8),
  1208. .mode = 0644,
  1209. .proc_handler = proc_dou8vec_minmax,
  1210. .extra1 = SYSCTL_ZERO,
  1211. .extra2 = SYSCTL_ONE,
  1212. },
  1213. {
  1214. .procname = "tcp_invalid_ratelimit",
  1215. .data = &init_net.ipv4.sysctl_tcp_invalid_ratelimit,
  1216. .maxlen = sizeof(int),
  1217. .mode = 0644,
  1218. .proc_handler = proc_dointvec_ms_jiffies,
  1219. },
  1220. {
  1221. .procname = "tcp_pacing_ss_ratio",
  1222. .data = &init_net.ipv4.sysctl_tcp_pacing_ss_ratio,
  1223. .maxlen = sizeof(int),
  1224. .mode = 0644,
  1225. .proc_handler = proc_dointvec_minmax,
  1226. .extra1 = SYSCTL_ZERO,
  1227. .extra2 = SYSCTL_ONE_THOUSAND,
  1228. },
  1229. {
  1230. .procname = "tcp_pacing_ca_ratio",
  1231. .data = &init_net.ipv4.sysctl_tcp_pacing_ca_ratio,
  1232. .maxlen = sizeof(int),
  1233. .mode = 0644,
  1234. .proc_handler = proc_dointvec_minmax,
  1235. .extra1 = SYSCTL_ZERO,
  1236. .extra2 = SYSCTL_ONE_THOUSAND,
  1237. },
  1238. {
  1239. .procname = "tcp_wmem",
  1240. .data = &init_net.ipv4.sysctl_tcp_wmem,
  1241. .maxlen = sizeof(init_net.ipv4.sysctl_tcp_wmem),
  1242. .mode = 0644,
  1243. .proc_handler = proc_dointvec_minmax,
  1244. .extra1 = SYSCTL_ONE,
  1245. },
  1246. {
  1247. .procname = "tcp_rmem",
  1248. .data = &init_net.ipv4.sysctl_tcp_rmem,
  1249. .maxlen = sizeof(init_net.ipv4.sysctl_tcp_rmem),
  1250. .mode = 0644,
  1251. .proc_handler = proc_dointvec_minmax,
  1252. .extra1 = SYSCTL_ONE,
  1253. },
  1254. {
  1255. .procname = "tcp_comp_sack_delay_ns",
  1256. .data = &init_net.ipv4.sysctl_tcp_comp_sack_delay_ns,
  1257. .maxlen = sizeof(unsigned long),
  1258. .mode = 0644,
  1259. .proc_handler = proc_doulongvec_minmax,
  1260. },
  1261. {
  1262. .procname = "tcp_comp_sack_slack_ns",
  1263. .data = &init_net.ipv4.sysctl_tcp_comp_sack_slack_ns,
  1264. .maxlen = sizeof(unsigned long),
  1265. .mode = 0644,
  1266. .proc_handler = proc_doulongvec_minmax,
  1267. },
  1268. {
  1269. .procname = "tcp_comp_sack_nr",
  1270. .data = &init_net.ipv4.sysctl_tcp_comp_sack_nr,
  1271. .maxlen = sizeof(u8),
  1272. .mode = 0644,
  1273. .proc_handler = proc_dou8vec_minmax,
  1274. .extra1 = SYSCTL_ZERO,
  1275. },
  1276. {
  1277. .procname = "tcp_reflect_tos",
  1278. .data = &init_net.ipv4.sysctl_tcp_reflect_tos,
  1279. .maxlen = sizeof(u8),
  1280. .mode = 0644,
  1281. .proc_handler = proc_dou8vec_minmax,
  1282. .extra1 = SYSCTL_ZERO,
  1283. .extra2 = SYSCTL_ONE,
  1284. },
  1285. {
  1286. .procname = "tcp_ehash_entries",
  1287. .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
  1288. .mode = 0444,
  1289. .proc_handler = proc_tcp_ehash_entries,
  1290. },
  1291. {
  1292. .procname = "tcp_child_ehash_entries",
  1293. .data = &init_net.ipv4.sysctl_tcp_child_ehash_entries,
  1294. .maxlen = sizeof(unsigned int),
  1295. .mode = 0644,
  1296. .proc_handler = proc_douintvec_minmax,
  1297. .extra1 = SYSCTL_ZERO,
  1298. .extra2 = &tcp_child_ehash_entries_max,
  1299. },
  1300. {
  1301. .procname = "udp_rmem_min",
  1302. .data = &init_net.ipv4.sysctl_udp_rmem_min,
  1303. .maxlen = sizeof(init_net.ipv4.sysctl_udp_rmem_min),
  1304. .mode = 0644,
  1305. .proc_handler = proc_dointvec_minmax,
  1306. .extra1 = SYSCTL_ONE
  1307. },
  1308. {
  1309. .procname = "udp_wmem_min",
  1310. .data = &init_net.ipv4.sysctl_udp_wmem_min,
  1311. .maxlen = sizeof(init_net.ipv4.sysctl_udp_wmem_min),
  1312. .mode = 0644,
  1313. .proc_handler = proc_dointvec_minmax,
  1314. .extra1 = SYSCTL_ONE
  1315. },
  1316. {
  1317. .procname = "fib_notify_on_flag_change",
  1318. .data = &init_net.ipv4.sysctl_fib_notify_on_flag_change,
  1319. .maxlen = sizeof(u8),
  1320. .mode = 0644,
  1321. .proc_handler = proc_dou8vec_minmax,
  1322. .extra1 = SYSCTL_ZERO,
  1323. .extra2 = SYSCTL_TWO,
  1324. },
  1325. { }
  1326. };
  1327. static __net_init int ipv4_sysctl_init_net(struct net *net)
  1328. {
  1329. struct ctl_table *table;
  1330. table = ipv4_net_table;
  1331. if (!net_eq(net, &init_net)) {
  1332. int i;
  1333. table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
  1334. if (!table)
  1335. goto err_alloc;
  1336. for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) {
  1337. if (table[i].data) {
  1338. /* Update the variables to point into
  1339. * the current struct net
  1340. */
  1341. table[i].data += (void *)net - (void *)&init_net;
  1342. } else {
  1343. /* Entries without data pointer are global;
  1344. * Make them read-only in non-init_net ns
  1345. */
  1346. table[i].mode &= ~0222;
  1347. }
  1348. }
  1349. }
  1350. net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
  1351. if (!net->ipv4.ipv4_hdr)
  1352. goto err_reg;
  1353. net->ipv4.sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
  1354. if (!net->ipv4.sysctl_local_reserved_ports)
  1355. goto err_ports;
  1356. return 0;
  1357. err_ports:
  1358. unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
  1359. err_reg:
  1360. if (!net_eq(net, &init_net))
  1361. kfree(table);
  1362. err_alloc:
  1363. return -ENOMEM;
  1364. }
  1365. static __net_exit void ipv4_sysctl_exit_net(struct net *net)
  1366. {
  1367. struct ctl_table *table;
  1368. kfree(net->ipv4.sysctl_local_reserved_ports);
  1369. table = net->ipv4.ipv4_hdr->ctl_table_arg;
  1370. unregister_net_sysctl_table(net->ipv4.ipv4_hdr);
  1371. kfree(table);
  1372. }
  1373. static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
  1374. .init = ipv4_sysctl_init_net,
  1375. .exit = ipv4_sysctl_exit_net,
  1376. };
  1377. static __init int sysctl_ipv4_init(void)
  1378. {
  1379. struct ctl_table_header *hdr;
  1380. hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
  1381. if (!hdr)
  1382. return -ENOMEM;
  1383. if (register_pernet_subsys(&ipv4_sysctl_ops)) {
  1384. unregister_net_sysctl_table(hdr);
  1385. return -ENOMEM;
  1386. }
  1387. return 0;
  1388. }
  1389. __initcall(sysctl_ipv4_init);