sysctl_net_ipv4.c 42 KB

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