sysctl_net_ipv4.c 32 KB

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