xref: /linux/include/net/netns/ipv4.h (revision 9410645520e9b820069761f3450ef6661418e279)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28afd351cSPavel Emelyanov /*
38afd351cSPavel Emelyanov  * ipv4 in net namespaces
48afd351cSPavel Emelyanov  */
58afd351cSPavel Emelyanov 
68afd351cSPavel Emelyanov #ifndef __NETNS_IPV4_H__
78afd351cSPavel Emelyanov #define __NETNS_IPV4_H__
8e4e4971cSDenis V. Lunev 
97064d16eSEric W. Biederman #include <linux/uidgid.h>
10ac18e750SPavel Emelyanov #include <net/inet_frag.h>
11a7e53531SAlexander Duyck #include <linux/rcupdate.h>
12949d6b40SJakub Kicinski #include <linux/seqlock.h>
13df453700SEric Dumazet #include <linux/siphash.h>
14ac18e750SPavel Emelyanov 
15752d14dcSPavel Emelyanov struct ctl_table_header;
16752d14dcSPavel Emelyanov struct ipv4_devconf;
17e4e4971cSDenis V. Lunev struct fib_rules_ops;
18e4aef8aeSDenis V. Lunev struct hlist_head;
19f4530fa5SDavid S. Miller struct fib_table;
206bd48fcfSDenis V. Lunev struct sock;
210bbf87d8SEric W. Biederman struct local_ports {
22d9f28735SDavid Laight 	u32		range;	/* high << 16 | low */
23ed2dfd90SEric Dumazet 	bool		warned;
240bbf87d8SEric W. Biederman };
25752d14dcSPavel Emelyanov 
26ba6b918aSCong Wang struct ping_group_range {
27ba6b918aSCong Wang 	seqlock_t	lock;
28ba6b918aSCong Wang 	kgid_t		range[2];
29ba6b918aSCong Wang };
30ba6b918aSCong Wang 
311946e672SHaishuang Yan struct inet_hashinfo;
321946e672SHaishuang Yan 
331946e672SHaishuang Yan struct inet_timewait_death_row {
34fbb82952SEric Dumazet 	refcount_t		tw_refcount;
351946e672SHaishuang Yan 
36e9bd0ccaSKuniyuki Iwashima 	/* Padding to avoid false sharing, tw_refcount can be often written */
37fbb82952SEric Dumazet 	struct inet_hashinfo 	*hashinfo ____cacheline_aligned_in_smp;
381946e672SHaishuang Yan 	int			sysctl_max_tw_buckets;
391946e672SHaishuang Yan };
401946e672SHaishuang Yan 
4143713848SHaishuang Yan struct tcp_fastopen_context;
4243713848SHaishuang Yan 
434ee2a8caSPetr Machata #ifdef CONFIG_IP_ROUTE_MULTIPATH
444ee2a8caSPetr Machata struct sysctl_fib_multipath_hash_seed {
454ee2a8caSPetr Machata 	u32 user_seed;
464ee2a8caSPetr Machata 	u32 mp_seed;
474ee2a8caSPetr Machata };
484ee2a8caSPetr Machata #endif
494ee2a8caSPetr Machata 
508afd351cSPavel Emelyanov struct netns_ipv4 {
5118fd64d2SCoco Li 	/* Cacheline organization can be found documented in
5218fd64d2SCoco Li 	 * Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst.
5318fd64d2SCoco Li 	 * Please update the document when adding new fields.
5418fd64d2SCoco Li 	 */
5518fd64d2SCoco Li 
5618fd64d2SCoco Li 	/* TX readonly hotpath cache lines */
5718fd64d2SCoco Li 	__cacheline_group_begin(netns_ipv4_read_tx);
5818fd64d2SCoco Li 	u8 sysctl_tcp_early_retrans;
5918fd64d2SCoco Li 	u8 sysctl_tcp_tso_win_divisor;
6018fd64d2SCoco Li 	u8 sysctl_tcp_tso_rtt_log;
6118fd64d2SCoco Li 	u8 sysctl_tcp_autocorking;
6218fd64d2SCoco Li 	int sysctl_tcp_min_snd_mss;
6318fd64d2SCoco Li 	unsigned int sysctl_tcp_notsent_lowat;
6418fd64d2SCoco Li 	int sysctl_tcp_limit_output_bytes;
6518fd64d2SCoco Li 	int sysctl_tcp_min_rtt_wlen;
6618fd64d2SCoco Li 	int sysctl_tcp_wmem[3];
6718fd64d2SCoco Li 	u8 sysctl_ip_fwd_use_pmtu;
6818fd64d2SCoco Li 	__cacheline_group_end(netns_ipv4_read_tx);
6918fd64d2SCoco Li 
7018fd64d2SCoco Li 	/* TXRX readonly hotpath cache lines */
7118fd64d2SCoco Li 	__cacheline_group_begin(netns_ipv4_read_txrx);
7218fd64d2SCoco Li 	u8 sysctl_tcp_moderate_rcvbuf;
7318fd64d2SCoco Li 	__cacheline_group_end(netns_ipv4_read_txrx);
7418fd64d2SCoco Li 
7518fd64d2SCoco Li 	/* RX readonly hotpath cache line */
7618fd64d2SCoco Li 	__cacheline_group_begin(netns_ipv4_read_rx);
7718fd64d2SCoco Li 	u8 sysctl_ip_early_demux;
7818fd64d2SCoco Li 	u8 sysctl_tcp_early_demux;
7918fd64d2SCoco Li 	int sysctl_tcp_reordering;
8018fd64d2SCoco Li 	int sysctl_tcp_rmem[3];
8118fd64d2SCoco Li 	__cacheline_group_end(netns_ipv4_read_rx);
8218fd64d2SCoco Li 
83e9bd0ccaSKuniyuki Iwashima 	struct inet_timewait_death_row tcp_death_row;
8467fb4330SKuniyuki Iwashima 	struct udp_table *udp_table;
851caf8d39SEric Dumazet 
862a75de0cSEric Dumazet #ifdef CONFIG_SYSCTL
87752d14dcSPavel Emelyanov 	struct ctl_table_header	*forw_hdr;
88e4a2d5c2SPavel Emelyanov 	struct ctl_table_header	*frags_hdr;
8968528f09SPavel Emelyanov 	struct ctl_table_header	*ipv4_hdr;
9039a23e75SDenis V. Lunev 	struct ctl_table_header *route_hdr;
918d068875SMichal Kubecek 	struct ctl_table_header *xfrm4_hdr;
922a75de0cSEric Dumazet #endif
93752d14dcSPavel Emelyanov 	struct ipv4_devconf	*devconf_all;
94752d14dcSPavel Emelyanov 	struct ipv4_devconf	*devconf_dflt;
955796ef75SKirill Tkhai 	struct ip_ra_chain __rcu *ra_chain;
96d9ff3049SKirill Tkhai 	struct mutex		ra_mutex;
97e4e4971cSDenis V. Lunev #ifdef CONFIG_IP_MULTIPLE_TABLES
98e4e4971cSDenis V. Lunev 	struct fib_rules_ops	*rules_ops;
99a7e53531SAlexander Duyck 	struct fib_table __rcu	*fib_main;
100a7e53531SAlexander Duyck 	struct fib_table __rcu	*fib_default;
101490f33c4SEric Dumazet 	unsigned int		fib_rules_require_fldissect;
102490f33c4SEric Dumazet 	bool			fib_has_custom_rules;
103f4530fa5SDavid S. Miller #endif
104a1f3316dSDavid S. Miller 	bool			fib_has_custom_local_routes;
105490f33c4SEric Dumazet 	bool			fib_offload_disabled;
106b650d953Smfreemon@cloudflare.com 	u8			sysctl_tcp_shrink_window;
107f4530fa5SDavid S. Miller #ifdef CONFIG_IP_ROUTE_CLASSID
108213f5f8fSEric Dumazet 	atomic_t		fib_num_tclassid_users;
109e4e4971cSDenis V. Lunev #endif
110e4aef8aeSDenis V. Lunev 	struct hlist_head	*fib_table_hash;
1116bd48fcfSDenis V. Lunev 	struct sock		*fibnl;
112ac18e750SPavel Emelyanov 
11393a714d6SMadhu Challa 	struct sock		*mc_autojoin_sk;
114349c9e3cSEric Dumazet 
115c8a627edSGao feng 	struct inet_peer_base	*peers;
1164907abc6SEric Dumazet 	struct fqdir		*fqdir;
117a24022e1SPavel Emelyanov 
1184b6bbf17SEric Dumazet 	u8 sysctl_icmp_echo_ignore_all;
119f1b8fa9fSAndreas Roeseler 	u8 sysctl_icmp_echo_enable_probe;
1204b6bbf17SEric Dumazet 	u8 sysctl_icmp_echo_ignore_broadcasts;
1214b6bbf17SEric Dumazet 	u8 sysctl_icmp_ignore_bogus_error_responses;
1224b6bbf17SEric Dumazet 	u8 sysctl_icmp_errors_use_inbound_ifaddr;
123a24022e1SPavel Emelyanov 	int sysctl_icmp_ratelimit;
124a24022e1SPavel Emelyanov 	int sysctl_icmp_ratemask;
125*f17bf505SEric Dumazet 	int sysctl_icmp_msgs_per_sec;
126*f17bf505SEric Dumazet 	int sysctl_icmp_msgs_burst;
127b056b4cdSEric Dumazet 	atomic_t icmp_global_credit;
128b056b4cdSEric Dumazet 	u32 icmp_global_stamp;
1291de6b15aSxu xin 	u32 ip_rt_min_pmtu;
1301135fad2Sxu xin 	int ip_rt_mtu_expires;
1312e9589ffSxu xin 	int ip_rt_min_advmss;
1321de6b15aSxu xin 
133c9d8f1a6SCong Wang 	struct local_ports ip_local_ports;
1340bbf87d8SEric W. Biederman 
1354b6bbf17SEric Dumazet 	u8 sysctl_tcp_ecn;
1364b6bbf17SEric Dumazet 	u8 sysctl_tcp_ecn_fallback;
13749213555SDaniel Borkmann 
1384b6bbf17SEric Dumazet 	u8 sysctl_ip_default_ttl;
1394b6bbf17SEric Dumazet 	u8 sysctl_ip_no_pmtu_disc;
1401c69dedcSEric Dumazet 	u8 sysctl_ip_fwd_update_priority;
1414b6bbf17SEric Dumazet 	u8 sysctl_ip_nonlocal_bind;
1424b6bbf17SEric Dumazet 	u8 sysctl_ip_autobind_reuse;
143287b7f38SNikolay Borisov 	/* Shall we try to damage output packets if routing dev changes? */
1444b6bbf17SEric Dumazet 	u8 sysctl_ip_dynaddr;
1456897445fSMike Manning #ifdef CONFIG_NET_L3_MASTER_DEV
1464b6bbf17SEric Dumazet 	u8 sysctl_raw_l3mdev_accept;
1476897445fSMike Manning #endif
1482932bcdaSEric Dumazet 	u8 sysctl_udp_early_demux;
1495d134f1cSHannes Frederic Sowa 
1504b6bbf17SEric Dumazet 	u8 sysctl_nexthop_compat_mode;
1514f80116dSRoopa Prabhu 
1524b6bbf17SEric Dumazet 	u8 sysctl_fwmark_reflect;
1534ecc1bafSEric Dumazet 	u8 sysctl_tcp_fwmark_accept;
1546dd9a14eSDavid Ahern #ifdef CONFIG_NET_L3_MASTER_DEV
1554ecc1bafSEric Dumazet 	u8 sysctl_tcp_l3mdev_accept;
1566dd9a14eSDavid Ahern #endif
1574ecc1bafSEric Dumazet 	u8 sysctl_tcp_mtu_probing;
158c04b79b6SJosh Hunt 	int sysctl_tcp_mtu_probe_floor;
159b0f9ca53SFan Du 	int sysctl_tcp_base_mss;
1606b58e0a5SFan Du 	int sysctl_tcp_probe_threshold;
16105cbc0dbSFan Du 	u32 sysctl_tcp_probe_interval;
162e110861fSLorenzo Colitti 
16313b287e8SNikolay Borisov 	int sysctl_tcp_keepalive_time;
164b840d15dSNikolay Borisov 	int sysctl_tcp_keepalive_intvl;
1654ecc1bafSEric Dumazet 	u8 sysctl_tcp_keepalive_probes;
16613b287e8SNikolay Borisov 
1674ecc1bafSEric Dumazet 	u8 sysctl_tcp_syn_retries;
1684ecc1bafSEric Dumazet 	u8 sysctl_tcp_synack_retries;
1694ecc1bafSEric Dumazet 	u8 sysctl_tcp_syncookies;
170f9ac779fSKuniyuki Iwashima 	u8 sysctl_tcp_migrate_req;
17165466904SEric Dumazet 	u8 sysctl_tcp_comp_sack_nr;
172133c4c0dSEric Dumazet 	u8 sysctl_tcp_backlog_ack_defer;
173562b1fdfSHaiyang Zhang 	u8 sysctl_tcp_pingpong_thresh;
174562b1fdfSHaiyang Zhang 
1754ecc1bafSEric Dumazet 	u8 sysctl_tcp_retries1;
1764ecc1bafSEric Dumazet 	u8 sysctl_tcp_retries2;
1774ecc1bafSEric Dumazet 	u8 sysctl_tcp_orphan_retries;
1784ecc1bafSEric Dumazet 	u8 sysctl_tcp_tw_reuse;
1791e579caaSNikolay Borisov 	int sysctl_tcp_fin_timeout;
1804ecc1bafSEric Dumazet 	u8 sysctl_tcp_sack;
1814ecc1bafSEric Dumazet 	u8 sysctl_tcp_window_scaling;
1824ecc1bafSEric Dumazet 	u8 sysctl_tcp_timestamps;
183f086edefSKevin Yang 	int sysctl_tcp_rto_min_us;
1844ecc1bafSEric Dumazet 	u8 sysctl_tcp_recovery;
1854ecc1bafSEric Dumazet 	u8 sysctl_tcp_thin_linear_timeouts;
1864ecc1bafSEric Dumazet 	u8 sysctl_tcp_slow_start_after_idle;
1874ecc1bafSEric Dumazet 	u8 sysctl_tcp_retrans_collapse;
1884ecc1bafSEric Dumazet 	u8 sysctl_tcp_stdurg;
1894ecc1bafSEric Dumazet 	u8 sysctl_tcp_rfc1337;
1904ecc1bafSEric Dumazet 	u8 sysctl_tcp_abort_on_overflow;
1914ecc1bafSEric Dumazet 	u8 sysctl_tcp_fack; /* obsolete */
192c6e21803SEric Dumazet 	int sysctl_tcp_max_reordering;
193dfa2f048SEric Dumazet 	int sysctl_tcp_adv_win_scale; /* obsolete */
1944ecc1bafSEric Dumazet 	u8 sysctl_tcp_dsack;
1954ecc1bafSEric Dumazet 	u8 sysctl_tcp_app_win;
1964ecc1bafSEric Dumazet 	u8 sysctl_tcp_frto;
1974ecc1bafSEric Dumazet 	u8 sysctl_tcp_nometrics_save;
1984ecc1bafSEric Dumazet 	u8 sysctl_tcp_no_ssthresh_metrics_save;
1994ecc1bafSEric Dumazet 	u8 sysctl_tcp_workaround_signed_windows;
200b530b681SEric Dumazet 	int sysctl_tcp_challenge_ack_limit;
2014ecc1bafSEric Dumazet 	u8 sysctl_tcp_min_tso_segs;
2024ecc1bafSEric Dumazet 	u8 sysctl_tcp_reflect_tos;
2034170ba6bSEric Dumazet 	int sysctl_tcp_invalid_ratelimit;
20423a7102aSEric Dumazet 	int sysctl_tcp_pacing_ss_ratio;
205c26e91f8SEric Dumazet 	int sysctl_tcp_pacing_ca_ratio;
206d1e5e640SKuniyuki Iwashima 	unsigned int sysctl_tcp_child_ehash_entries;
2076d82aa24SEric Dumazet 	unsigned long sysctl_tcp_comp_sack_delay_ns;
208a70437ccSEric Dumazet 	unsigned long sysctl_tcp_comp_sack_slack_ns;
209fee83d09SHaishuang Yan 	int sysctl_max_syn_backlog;
210e1cfcbe8SHaishuang Yan 	int sysctl_tcp_fastopen;
2116670e152SStephen Hemminger 	const struct tcp_congestion_ops __rcu  *tcp_congestion_control;
21243713848SHaishuang Yan 	struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
2133733be14SHaishuang Yan 	unsigned int sysctl_tcp_fastopen_blackhole_timeout;
2143733be14SHaishuang Yan 	atomic_t tfo_active_disable_times;
2153733be14SHaishuang Yan 	unsigned long tfo_active_disable_stamp;
21679e3602cSEric Dumazet 	u32 tcp_challenge_timestamp;
21779e3602cSEric Dumazet 	u32 tcp_challenge_count;
218bd456f28SMubashir Adnan Qureshi 	u8 sysctl_tcp_plb_enabled;
219bd456f28SMubashir Adnan Qureshi 	u8 sysctl_tcp_plb_idle_rehash_rounds;
220bd456f28SMubashir Adnan Qureshi 	u8 sysctl_tcp_plb_rehash_rounds;
221bd456f28SMubashir Adnan Qureshi 	u8 sysctl_tcp_plb_suspend_rto_sec;
222bd456f28SMubashir Adnan Qureshi 	int sysctl_tcp_plb_cong_thresh;
22312ed8244SNikolay Borisov 
2241e802951STonghao Zhang 	int sysctl_udp_wmem_min;
2251e802951STonghao Zhang 	int sysctl_udp_rmem_min;
2261e802951STonghao Zhang 
227b2908facSEric Dumazet 	u8 sysctl_fib_notify_on_flag_change;
228ccce324dSDavid Morley 	u8 sysctl_tcp_syn_linear_timeouts;
229680aea08SAmit Cohen 
23063a6fff3SRobert Shearman #ifdef CONFIG_NET_L3_MASTER_DEV
231cd04bd02SEric Dumazet 	u8 sysctl_udp_l3mdev_accept;
23263a6fff3SRobert Shearman #endif
23363a6fff3SRobert Shearman 
2347d4b37ebSEric Dumazet 	u8 sysctl_igmp_llm_reports;
235815c5270SNikolay Borisov 	int sysctl_igmp_max_memberships;
236166b6b2dSNikolay Borisov 	int sysctl_igmp_max_msf;
237165094afSNikolay Borisov 	int sysctl_igmp_qrv;
238815c5270SNikolay Borisov 
239ba6b918aSCong Wang 	struct ping_group_range ping_group_range;
240c319b4d7SVasiliy Kulikov 
241436c3b66SDavid S. Miller 	atomic_t dev_addr_genid;
24270a269e6SBenjamin Thery 
2439804985bSKuniyuki Iwashima 	unsigned int sysctl_udp_child_hash_entries;
2449804985bSKuniyuki Iwashima 
245122ff243SWANG Cong #ifdef CONFIG_SYSCTL
246122ff243SWANG Cong 	unsigned long *sysctl_local_reserved_ports;
2474548b683SKrister Johansen 	int sysctl_ip_prot_sock;
248122ff243SWANG Cong #endif
249122ff243SWANG Cong 
25070a269e6SBenjamin Thery #ifdef CONFIG_IP_MROUTE
251f0ad0860SPatrick McHardy #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
2520c12295aSPatrick McHardy 	struct mr_table		*mrt;
253f0ad0860SPatrick McHardy #else
254f0ad0860SPatrick McHardy 	struct list_head	mr_tables;
255f0ad0860SPatrick McHardy 	struct fib_rules_ops	*mr_rules_ops;
256f0ad0860SPatrick McHardy #endif
25770a269e6SBenjamin Thery #endif
258a6db4494SDavid Ahern #ifdef CONFIG_IP_ROUTE_MULTIPATH
2594ee2a8caSPetr Machata 	struct sysctl_fib_multipath_hash_seed sysctl_fib_multipath_hash_seed;
260ce5c9c20SIdo Schimmel 	u32 sysctl_fib_multipath_hash_fields;
261be205fe6SEric Dumazet 	u8 sysctl_fib_multipath_use_neigh;
262be205fe6SEric Dumazet 	u8 sysctl_fib_multipath_hash_policy;
263a6db4494SDavid Ahern #endif
264cacaad11SIdo Schimmel 
26504b1d4e5SIdo Schimmel 	struct fib_notifier_ops	*notifier_ops;
266cacaad11SIdo Schimmel 	unsigned int	fib_seq;	/* protected by rtnl_mutex */
267cacaad11SIdo Schimmel 
2684d65b948SYotam Gigi 	struct fib_notifier_ops	*ipmr_notifier_ops;
2694d65b948SYotam Gigi 	unsigned int	ipmr_seq;	/* protected by rtnl_mutex */
2704d65b948SYotam Gigi 
271ca4c3fc2Sfan.du 	atomic_t	rt_genid;
272df453700SEric Dumazet 	siphash_key_t	ip_id_key;
2738afd351cSPavel Emelyanov };
2748afd351cSPavel Emelyanov #endif
275