xref: /linux/include/net/netns/ipv4.h (revision f17bf505)
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 	int sysctl_tcp_reordering;
80 	int sysctl_tcp_rmem[3];
81 	__cacheline_group_end(netns_ipv4_read_rx);
82 
83 	struct inet_timewait_death_row tcp_death_row;
84 	struct udp_table *udp_table;
85 
86 #ifdef CONFIG_SYSCTL
87 	struct ctl_table_header	*forw_hdr;
88 	struct ctl_table_header	*frags_hdr;
89 	struct ctl_table_header	*ipv4_hdr;
90 	struct ctl_table_header *route_hdr;
91 	struct ctl_table_header *xfrm4_hdr;
92 #endif
93 	struct ipv4_devconf	*devconf_all;
94 	struct ipv4_devconf	*devconf_dflt;
95 	struct ip_ra_chain __rcu *ra_chain;
96 	struct mutex		ra_mutex;
97 #ifdef CONFIG_IP_MULTIPLE_TABLES
98 	struct fib_rules_ops	*rules_ops;
99 	struct fib_table __rcu	*fib_main;
100 	struct fib_table __rcu	*fib_default;
101 	unsigned int		fib_rules_require_fldissect;
102 	bool			fib_has_custom_rules;
103 #endif
104 	bool			fib_has_custom_local_routes;
105 	bool			fib_offload_disabled;
106 	u8			sysctl_tcp_shrink_window;
107 #ifdef CONFIG_IP_ROUTE_CLASSID
108 	atomic_t		fib_num_tclassid_users;
109 #endif
110 	struct hlist_head	*fib_table_hash;
111 	struct sock		*fibnl;
112 
113 	struct sock		*mc_autojoin_sk;
114 
115 	struct inet_peer_base	*peers;
116 	struct fqdir		*fqdir;
117 
118 	u8 sysctl_icmp_echo_ignore_all;
119 	u8 sysctl_icmp_echo_enable_probe;
120 	u8 sysctl_icmp_echo_ignore_broadcasts;
121 	u8 sysctl_icmp_ignore_bogus_error_responses;
122 	u8 sysctl_icmp_errors_use_inbound_ifaddr;
123 	int sysctl_icmp_ratelimit;
124 	int sysctl_icmp_ratemask;
125 	int sysctl_icmp_msgs_per_sec;
126 	int sysctl_icmp_msgs_burst;
127 	atomic_t icmp_global_credit;
128 	u32 icmp_global_stamp;
129 	u32 ip_rt_min_pmtu;
130 	int ip_rt_mtu_expires;
131 	int ip_rt_min_advmss;
132 
133 	struct local_ports ip_local_ports;
134 
135 	u8 sysctl_tcp_ecn;
136 	u8 sysctl_tcp_ecn_fallback;
137 
138 	u8 sysctl_ip_default_ttl;
139 	u8 sysctl_ip_no_pmtu_disc;
140 	u8 sysctl_ip_fwd_update_priority;
141 	u8 sysctl_ip_nonlocal_bind;
142 	u8 sysctl_ip_autobind_reuse;
143 	/* Shall we try to damage output packets if routing dev changes? */
144 	u8 sysctl_ip_dynaddr;
145 #ifdef CONFIG_NET_L3_MASTER_DEV
146 	u8 sysctl_raw_l3mdev_accept;
147 #endif
148 	u8 sysctl_udp_early_demux;
149 
150 	u8 sysctl_nexthop_compat_mode;
151 
152 	u8 sysctl_fwmark_reflect;
153 	u8 sysctl_tcp_fwmark_accept;
154 #ifdef CONFIG_NET_L3_MASTER_DEV
155 	u8 sysctl_tcp_l3mdev_accept;
156 #endif
157 	u8 sysctl_tcp_mtu_probing;
158 	int sysctl_tcp_mtu_probe_floor;
159 	int sysctl_tcp_base_mss;
160 	int sysctl_tcp_probe_threshold;
161 	u32 sysctl_tcp_probe_interval;
162 
163 	int sysctl_tcp_keepalive_time;
164 	int sysctl_tcp_keepalive_intvl;
165 	u8 sysctl_tcp_keepalive_probes;
166 
167 	u8 sysctl_tcp_syn_retries;
168 	u8 sysctl_tcp_synack_retries;
169 	u8 sysctl_tcp_syncookies;
170 	u8 sysctl_tcp_migrate_req;
171 	u8 sysctl_tcp_comp_sack_nr;
172 	u8 sysctl_tcp_backlog_ack_defer;
173 	u8 sysctl_tcp_pingpong_thresh;
174 
175 	u8 sysctl_tcp_retries1;
176 	u8 sysctl_tcp_retries2;
177 	u8 sysctl_tcp_orphan_retries;
178 	u8 sysctl_tcp_tw_reuse;
179 	int sysctl_tcp_fin_timeout;
180 	u8 sysctl_tcp_sack;
181 	u8 sysctl_tcp_window_scaling;
182 	u8 sysctl_tcp_timestamps;
183 	int sysctl_tcp_rto_min_us;
184 	u8 sysctl_tcp_recovery;
185 	u8 sysctl_tcp_thin_linear_timeouts;
186 	u8 sysctl_tcp_slow_start_after_idle;
187 	u8 sysctl_tcp_retrans_collapse;
188 	u8 sysctl_tcp_stdurg;
189 	u8 sysctl_tcp_rfc1337;
190 	u8 sysctl_tcp_abort_on_overflow;
191 	u8 sysctl_tcp_fack; /* obsolete */
192 	int sysctl_tcp_max_reordering;
193 	int sysctl_tcp_adv_win_scale; /* obsolete */
194 	u8 sysctl_tcp_dsack;
195 	u8 sysctl_tcp_app_win;
196 	u8 sysctl_tcp_frto;
197 	u8 sysctl_tcp_nometrics_save;
198 	u8 sysctl_tcp_no_ssthresh_metrics_save;
199 	u8 sysctl_tcp_workaround_signed_windows;
200 	int sysctl_tcp_challenge_ack_limit;
201 	u8 sysctl_tcp_min_tso_segs;
202 	u8 sysctl_tcp_reflect_tos;
203 	int sysctl_tcp_invalid_ratelimit;
204 	int sysctl_tcp_pacing_ss_ratio;
205 	int sysctl_tcp_pacing_ca_ratio;
206 	unsigned int sysctl_tcp_child_ehash_entries;
207 	unsigned long sysctl_tcp_comp_sack_delay_ns;
208 	unsigned long sysctl_tcp_comp_sack_slack_ns;
209 	int sysctl_max_syn_backlog;
210 	int sysctl_tcp_fastopen;
211 	const struct tcp_congestion_ops __rcu  *tcp_congestion_control;
212 	struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
213 	unsigned int sysctl_tcp_fastopen_blackhole_timeout;
214 	atomic_t tfo_active_disable_times;
215 	unsigned long tfo_active_disable_stamp;
216 	u32 tcp_challenge_timestamp;
217 	u32 tcp_challenge_count;
218 	u8 sysctl_tcp_plb_enabled;
219 	u8 sysctl_tcp_plb_idle_rehash_rounds;
220 	u8 sysctl_tcp_plb_rehash_rounds;
221 	u8 sysctl_tcp_plb_suspend_rto_sec;
222 	int sysctl_tcp_plb_cong_thresh;
223 
224 	int sysctl_udp_wmem_min;
225 	int sysctl_udp_rmem_min;
226 
227 	u8 sysctl_fib_notify_on_flag_change;
228 	u8 sysctl_tcp_syn_linear_timeouts;
229 
230 #ifdef CONFIG_NET_L3_MASTER_DEV
231 	u8 sysctl_udp_l3mdev_accept;
232 #endif
233 
234 	u8 sysctl_igmp_llm_reports;
235 	int sysctl_igmp_max_memberships;
236 	int sysctl_igmp_max_msf;
237 	int sysctl_igmp_qrv;
238 
239 	struct ping_group_range ping_group_range;
240 
241 	atomic_t dev_addr_genid;
242 
243 	unsigned int sysctl_udp_child_hash_entries;
244 
245 #ifdef CONFIG_SYSCTL
246 	unsigned long *sysctl_local_reserved_ports;
247 	int sysctl_ip_prot_sock;
248 #endif
249 
250 #ifdef CONFIG_IP_MROUTE
251 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
252 	struct mr_table		*mrt;
253 #else
254 	struct list_head	mr_tables;
255 	struct fib_rules_ops	*mr_rules_ops;
256 #endif
257 #endif
258 #ifdef CONFIG_IP_ROUTE_MULTIPATH
259 	struct sysctl_fib_multipath_hash_seed sysctl_fib_multipath_hash_seed;
260 	u32 sysctl_fib_multipath_hash_fields;
261 	u8 sysctl_fib_multipath_use_neigh;
262 	u8 sysctl_fib_multipath_hash_policy;
263 #endif
264 
265 	struct fib_notifier_ops	*notifier_ops;
266 	unsigned int	fib_seq;	/* protected by rtnl_mutex */
267 
268 	struct fib_notifier_ops	*ipmr_notifier_ops;
269 	unsigned int	ipmr_seq;	/* protected by rtnl_mutex */
270 
271 	atomic_t	rt_genid;
272 	siphash_key_t	ip_id_key;
273 };
274 #endif
275