xref: /linux/include/net/netns/ipv4.h (revision 3fd6c59042dbba50391e30862beac979491145fe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * ipv4 in net namespaces
4  */
5 
6 #ifndef __NETNS_IPV4_H__
7 #define __NETNS_IPV4_H__
8 
9 #include <linux/uidgid.h>
10 #include <net/inet_frag.h>
11 #include <linux/rcupdate.h>
12 #include <linux/seqlock.h>
13 #include <linux/siphash.h>
14 
15 struct ctl_table_header;
16 struct ipv4_devconf;
17 struct fib_rules_ops;
18 struct hlist_head;
19 struct fib_table;
20 struct sock;
21 struct local_ports {
22 	u32		range;	/* high << 16 | low */
23 	bool		warned;
24 };
25 
26 struct ping_group_range {
27 	seqlock_t	lock;
28 	kgid_t		range[2];
29 };
30 
31 struct inet_hashinfo;
32 
33 struct inet_timewait_death_row {
34 	refcount_t		tw_refcount;
35 
36 	/* Padding to avoid false sharing, tw_refcount can be often written */
37 	struct inet_hashinfo 	*hashinfo ____cacheline_aligned_in_smp;
38 	int			sysctl_max_tw_buckets;
39 };
40 
41 struct tcp_fastopen_context;
42 
43 #ifdef CONFIG_IP_ROUTE_MULTIPATH
44 struct sysctl_fib_multipath_hash_seed {
45 	u32 user_seed;
46 	u32 mp_seed;
47 };
48 #endif
49 
50 struct netns_ipv4 {
51 	/* Cacheline organization can be found documented in
52 	 * Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst.
53 	 * Please update the document when adding new fields.
54 	 */
55 
56 	/* TX readonly hotpath cache lines */
57 	__cacheline_group_begin(netns_ipv4_read_tx);
58 	u8 sysctl_tcp_early_retrans;
59 	u8 sysctl_tcp_tso_win_divisor;
60 	u8 sysctl_tcp_tso_rtt_log;
61 	u8 sysctl_tcp_autocorking;
62 	int sysctl_tcp_min_snd_mss;
63 	unsigned int sysctl_tcp_notsent_lowat;
64 	int sysctl_tcp_limit_output_bytes;
65 	int sysctl_tcp_min_rtt_wlen;
66 	int sysctl_tcp_wmem[3];
67 	u8 sysctl_ip_fwd_use_pmtu;
68 	__cacheline_group_end(netns_ipv4_read_tx);
69 
70 	/* TXRX readonly hotpath cache lines */
71 	__cacheline_group_begin(netns_ipv4_read_txrx);
72 	u8 sysctl_tcp_moderate_rcvbuf;
73 	__cacheline_group_end(netns_ipv4_read_txrx);
74 
75 	/* RX readonly hotpath cache line */
76 	__cacheline_group_begin(netns_ipv4_read_rx);
77 	u8 sysctl_ip_early_demux;
78 	u8 sysctl_tcp_early_demux;
79 	u8 sysctl_tcp_l3mdev_accept;
80 	/* 3 bytes hole, try to pack */
81 	int sysctl_tcp_reordering;
82 	int sysctl_tcp_rmem[3];
83 	__cacheline_group_end(netns_ipv4_read_rx);
84 
85 	struct inet_timewait_death_row tcp_death_row;
86 	struct udp_table *udp_table;
87 
88 #ifdef CONFIG_SYSCTL
89 	struct ctl_table_header	*forw_hdr;
90 	struct ctl_table_header	*frags_hdr;
91 	struct ctl_table_header	*ipv4_hdr;
92 	struct ctl_table_header *route_hdr;
93 	struct ctl_table_header *xfrm4_hdr;
94 #endif
95 	struct ipv4_devconf	*devconf_all;
96 	struct ipv4_devconf	*devconf_dflt;
97 	struct ip_ra_chain __rcu *ra_chain;
98 	struct mutex		ra_mutex;
99 #ifdef CONFIG_IP_MULTIPLE_TABLES
100 	struct fib_rules_ops	*rules_ops;
101 	struct fib_table __rcu	*fib_main;
102 	struct fib_table __rcu	*fib_default;
103 	unsigned int		fib_rules_require_fldissect;
104 	bool			fib_has_custom_rules;
105 #endif
106 	bool			fib_has_custom_local_routes;
107 	bool			fib_offload_disabled;
108 	u8			sysctl_tcp_shrink_window;
109 #ifdef CONFIG_IP_ROUTE_CLASSID
110 	atomic_t		fib_num_tclassid_users;
111 #endif
112 	struct hlist_head	*fib_table_hash;
113 	struct sock		*fibnl;
114 
115 	struct sock		*mc_autojoin_sk;
116 
117 	struct inet_peer_base	*peers;
118 	struct fqdir		*fqdir;
119 
120 	u8 sysctl_icmp_echo_ignore_all;
121 	u8 sysctl_icmp_echo_enable_probe;
122 	u8 sysctl_icmp_echo_ignore_broadcasts;
123 	u8 sysctl_icmp_ignore_bogus_error_responses;
124 	u8 sysctl_icmp_errors_use_inbound_ifaddr;
125 	int sysctl_icmp_ratelimit;
126 	int sysctl_icmp_ratemask;
127 	int sysctl_icmp_msgs_per_sec;
128 	int sysctl_icmp_msgs_burst;
129 	atomic_t icmp_global_credit;
130 	u32 icmp_global_stamp;
131 	u32 ip_rt_min_pmtu;
132 	int ip_rt_mtu_expires;
133 	int ip_rt_min_advmss;
134 
135 	struct local_ports ip_local_ports;
136 
137 	u8 sysctl_tcp_ecn;
138 	u8 sysctl_tcp_ecn_fallback;
139 
140 	u8 sysctl_ip_default_ttl;
141 	u8 sysctl_ip_no_pmtu_disc;
142 	u8 sysctl_ip_fwd_update_priority;
143 	u8 sysctl_ip_nonlocal_bind;
144 	u8 sysctl_ip_autobind_reuse;
145 	/* Shall we try to damage output packets if routing dev changes? */
146 	u8 sysctl_ip_dynaddr;
147 #ifdef CONFIG_NET_L3_MASTER_DEV
148 	u8 sysctl_raw_l3mdev_accept;
149 #endif
150 	u8 sysctl_udp_early_demux;
151 
152 	u8 sysctl_nexthop_compat_mode;
153 
154 	u8 sysctl_fwmark_reflect;
155 	u8 sysctl_tcp_fwmark_accept;
156 	u8 sysctl_tcp_mtu_probing;
157 	int sysctl_tcp_mtu_probe_floor;
158 	int sysctl_tcp_base_mss;
159 	int sysctl_tcp_probe_threshold;
160 	u32 sysctl_tcp_probe_interval;
161 
162 	int sysctl_tcp_keepalive_time;
163 	int sysctl_tcp_keepalive_intvl;
164 	u8 sysctl_tcp_keepalive_probes;
165 
166 	u8 sysctl_tcp_syn_retries;
167 	u8 sysctl_tcp_synack_retries;
168 	u8 sysctl_tcp_syncookies;
169 	u8 sysctl_tcp_migrate_req;
170 	u8 sysctl_tcp_comp_sack_nr;
171 	u8 sysctl_tcp_backlog_ack_defer;
172 	u8 sysctl_tcp_pingpong_thresh;
173 
174 	u8 sysctl_tcp_retries1;
175 	u8 sysctl_tcp_retries2;
176 	u8 sysctl_tcp_orphan_retries;
177 	u8 sysctl_tcp_tw_reuse;
178 	int sysctl_tcp_fin_timeout;
179 	u8 sysctl_tcp_sack;
180 	u8 sysctl_tcp_window_scaling;
181 	u8 sysctl_tcp_timestamps;
182 	int sysctl_tcp_rto_min_us;
183 	u8 sysctl_tcp_recovery;
184 	u8 sysctl_tcp_thin_linear_timeouts;
185 	u8 sysctl_tcp_slow_start_after_idle;
186 	u8 sysctl_tcp_retrans_collapse;
187 	u8 sysctl_tcp_stdurg;
188 	u8 sysctl_tcp_rfc1337;
189 	u8 sysctl_tcp_abort_on_overflow;
190 	u8 sysctl_tcp_fack; /* obsolete */
191 	int sysctl_tcp_max_reordering;
192 	int sysctl_tcp_adv_win_scale; /* obsolete */
193 	u8 sysctl_tcp_dsack;
194 	u8 sysctl_tcp_app_win;
195 	u8 sysctl_tcp_frto;
196 	u8 sysctl_tcp_nometrics_save;
197 	u8 sysctl_tcp_no_ssthresh_metrics_save;
198 	u8 sysctl_tcp_workaround_signed_windows;
199 	int sysctl_tcp_challenge_ack_limit;
200 	u8 sysctl_tcp_min_tso_segs;
201 	u8 sysctl_tcp_reflect_tos;
202 	int sysctl_tcp_invalid_ratelimit;
203 	int sysctl_tcp_pacing_ss_ratio;
204 	int sysctl_tcp_pacing_ca_ratio;
205 	unsigned int sysctl_tcp_child_ehash_entries;
206 	unsigned long sysctl_tcp_comp_sack_delay_ns;
207 	unsigned long sysctl_tcp_comp_sack_slack_ns;
208 	int sysctl_max_syn_backlog;
209 	int sysctl_tcp_fastopen;
210 	const struct tcp_congestion_ops __rcu  *tcp_congestion_control;
211 	struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
212 	unsigned int sysctl_tcp_fastopen_blackhole_timeout;
213 	atomic_t tfo_active_disable_times;
214 	unsigned long tfo_active_disable_stamp;
215 	u32 tcp_challenge_timestamp;
216 	u32 tcp_challenge_count;
217 	u8 sysctl_tcp_plb_enabled;
218 	u8 sysctl_tcp_plb_idle_rehash_rounds;
219 	u8 sysctl_tcp_plb_rehash_rounds;
220 	u8 sysctl_tcp_plb_suspend_rto_sec;
221 	int sysctl_tcp_plb_cong_thresh;
222 
223 	int sysctl_udp_wmem_min;
224 	int sysctl_udp_rmem_min;
225 
226 	u8 sysctl_fib_notify_on_flag_change;
227 	u8 sysctl_tcp_syn_linear_timeouts;
228 
229 #ifdef CONFIG_NET_L3_MASTER_DEV
230 	u8 sysctl_udp_l3mdev_accept;
231 #endif
232 
233 	u8 sysctl_igmp_llm_reports;
234 	int sysctl_igmp_max_memberships;
235 	int sysctl_igmp_max_msf;
236 	int sysctl_igmp_qrv;
237 
238 	struct ping_group_range ping_group_range;
239 
240 	atomic_t dev_addr_genid;
241 
242 	unsigned int sysctl_udp_child_hash_entries;
243 
244 #ifdef CONFIG_SYSCTL
245 	unsigned long *sysctl_local_reserved_ports;
246 	int sysctl_ip_prot_sock;
247 #endif
248 
249 #ifdef CONFIG_IP_MROUTE
250 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
251 	struct mr_table		*mrt;
252 #else
253 	struct list_head	mr_tables;
254 	struct fib_rules_ops	*mr_rules_ops;
255 #endif
256 #endif
257 #ifdef CONFIG_IP_ROUTE_MULTIPATH
258 	struct sysctl_fib_multipath_hash_seed sysctl_fib_multipath_hash_seed;
259 	u32 sysctl_fib_multipath_hash_fields;
260 	u8 sysctl_fib_multipath_use_neigh;
261 	u8 sysctl_fib_multipath_hash_policy;
262 #endif
263 
264 	struct fib_notifier_ops	*notifier_ops;
265 	unsigned int	fib_seq;	/* writes protected by rtnl_mutex */
266 
267 	struct fib_notifier_ops	*ipmr_notifier_ops;
268 	unsigned int	ipmr_seq;	/* protected by rtnl_mutex */
269 
270 	atomic_t	rt_genid;
271 	siphash_key_t	ip_id_key;
272 	struct hlist_head	*inet_addr_lst;
273 	struct delayed_work	addr_chk_work;
274 };
275 #endif
276