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