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 
13 struct tcpm_hash_bucket;
14 struct ctl_table_header;
15 struct ipv4_devconf;
16 struct fib_rules_ops;
17 struct hlist_head;
18 struct fib_table;
19 struct sock;
20 struct local_ports {
21 	seqlock_t	lock;
22 	int		range[2];
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 	atomic_t		tw_count;
35 
36 	struct inet_hashinfo 	*hashinfo ____cacheline_aligned_in_smp;
37 	int			sysctl_max_tw_buckets;
38 };
39 
40 struct tcp_fastopen_context;
41 
42 struct netns_ipv4 {
43 #ifdef CONFIG_SYSCTL
44 	struct ctl_table_header	*forw_hdr;
45 	struct ctl_table_header	*frags_hdr;
46 	struct ctl_table_header	*ipv4_hdr;
47 	struct ctl_table_header *route_hdr;
48 	struct ctl_table_header *xfrm4_hdr;
49 #endif
50 	struct ipv4_devconf	*devconf_all;
51 	struct ipv4_devconf	*devconf_dflt;
52 	struct ip_ra_chain __rcu *ra_chain;
53 	struct mutex		ra_mutex;
54 #ifdef CONFIG_IP_MULTIPLE_TABLES
55 	struct fib_rules_ops	*rules_ops;
56 	bool			fib_has_custom_rules;
57 	unsigned int		fib_rules_require_fldissect;
58 	struct fib_table __rcu	*fib_main;
59 	struct fib_table __rcu	*fib_default;
60 #endif
61 	bool			fib_has_custom_local_routes;
62 #ifdef CONFIG_IP_ROUTE_CLASSID
63 	int			fib_num_tclassid_users;
64 #endif
65 	struct hlist_head	*fib_table_hash;
66 	bool			fib_offload_disabled;
67 	struct sock		*fibnl;
68 
69 	struct sock  * __percpu	*icmp_sk;
70 	struct sock		*mc_autojoin_sk;
71 
72 	struct inet_peer_base	*peers;
73 	struct sock  * __percpu	*tcp_sk;
74 	struct netns_frags	frags;
75 #ifdef CONFIG_NETFILTER
76 	struct xt_table		*iptable_filter;
77 	struct xt_table		*iptable_mangle;
78 	struct xt_table		*iptable_raw;
79 	struct xt_table		*arptable_filter;
80 #ifdef CONFIG_SECURITY
81 	struct xt_table		*iptable_security;
82 #endif
83 	struct xt_table		*nat_table;
84 #endif
85 
86 	int sysctl_icmp_echo_ignore_all;
87 	int sysctl_icmp_echo_ignore_broadcasts;
88 	int sysctl_icmp_ignore_bogus_error_responses;
89 	int sysctl_icmp_ratelimit;
90 	int sysctl_icmp_ratemask;
91 	int sysctl_icmp_errors_use_inbound_ifaddr;
92 
93 	struct local_ports ip_local_ports;
94 
95 	int sysctl_tcp_ecn;
96 	int sysctl_tcp_ecn_fallback;
97 
98 	int sysctl_ip_default_ttl;
99 	int sysctl_ip_no_pmtu_disc;
100 	int sysctl_ip_fwd_use_pmtu;
101 	int sysctl_ip_fwd_update_priority;
102 	int sysctl_ip_nonlocal_bind;
103 	/* Shall we try to damage output packets if routing dev changes? */
104 	int sysctl_ip_dynaddr;
105 	int sysctl_ip_early_demux;
106 	int sysctl_tcp_early_demux;
107 	int sysctl_udp_early_demux;
108 
109 	int sysctl_fwmark_reflect;
110 	int sysctl_tcp_fwmark_accept;
111 #ifdef CONFIG_NET_L3_MASTER_DEV
112 	int sysctl_tcp_l3mdev_accept;
113 #endif
114 	int sysctl_tcp_mtu_probing;
115 	int sysctl_tcp_base_mss;
116 	int sysctl_tcp_probe_threshold;
117 	u32 sysctl_tcp_probe_interval;
118 
119 	int sysctl_tcp_keepalive_time;
120 	int sysctl_tcp_keepalive_probes;
121 	int sysctl_tcp_keepalive_intvl;
122 
123 	int sysctl_tcp_syn_retries;
124 	int sysctl_tcp_synack_retries;
125 	int sysctl_tcp_syncookies;
126 	int sysctl_tcp_reordering;
127 	int sysctl_tcp_retries1;
128 	int sysctl_tcp_retries2;
129 	int sysctl_tcp_orphan_retries;
130 	int sysctl_tcp_fin_timeout;
131 	unsigned int sysctl_tcp_notsent_lowat;
132 	int sysctl_tcp_tw_reuse;
133 	int sysctl_tcp_sack;
134 	int sysctl_tcp_window_scaling;
135 	int sysctl_tcp_timestamps;
136 	int sysctl_tcp_early_retrans;
137 	int sysctl_tcp_recovery;
138 	int sysctl_tcp_thin_linear_timeouts;
139 	int sysctl_tcp_slow_start_after_idle;
140 	int sysctl_tcp_retrans_collapse;
141 	int sysctl_tcp_stdurg;
142 	int sysctl_tcp_rfc1337;
143 	int sysctl_tcp_abort_on_overflow;
144 	int sysctl_tcp_fack;
145 	int sysctl_tcp_max_reordering;
146 	int sysctl_tcp_dsack;
147 	int sysctl_tcp_app_win;
148 	int sysctl_tcp_adv_win_scale;
149 	int sysctl_tcp_frto;
150 	int sysctl_tcp_nometrics_save;
151 	int sysctl_tcp_moderate_rcvbuf;
152 	int sysctl_tcp_tso_win_divisor;
153 	int sysctl_tcp_workaround_signed_windows;
154 	int sysctl_tcp_limit_output_bytes;
155 	int sysctl_tcp_challenge_ack_limit;
156 	int sysctl_tcp_min_tso_segs;
157 	int sysctl_tcp_min_rtt_wlen;
158 	int sysctl_tcp_autocorking;
159 	int sysctl_tcp_invalid_ratelimit;
160 	int sysctl_tcp_pacing_ss_ratio;
161 	int sysctl_tcp_pacing_ca_ratio;
162 	int sysctl_tcp_wmem[3];
163 	int sysctl_tcp_rmem[3];
164 	int sysctl_tcp_comp_sack_nr;
165 	unsigned long sysctl_tcp_comp_sack_delay_ns;
166 	struct inet_timewait_death_row tcp_death_row;
167 	int sysctl_max_syn_backlog;
168 	int sysctl_tcp_fastopen;
169 	const struct tcp_congestion_ops __rcu  *tcp_congestion_control;
170 	struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
171 	spinlock_t tcp_fastopen_ctx_lock;
172 	unsigned int sysctl_tcp_fastopen_blackhole_timeout;
173 	atomic_t tfo_active_disable_times;
174 	unsigned long tfo_active_disable_stamp;
175 
176 	int sysctl_udp_wmem_min;
177 	int sysctl_udp_rmem_min;
178 
179 #ifdef CONFIG_NET_L3_MASTER_DEV
180 	int sysctl_udp_l3mdev_accept;
181 #endif
182 
183 	int sysctl_igmp_max_memberships;
184 	int sysctl_igmp_max_msf;
185 	int sysctl_igmp_llm_reports;
186 	int sysctl_igmp_qrv;
187 
188 	struct ping_group_range ping_group_range;
189 
190 	atomic_t dev_addr_genid;
191 
192 #ifdef CONFIG_SYSCTL
193 	unsigned long *sysctl_local_reserved_ports;
194 	int sysctl_ip_prot_sock;
195 #endif
196 
197 #ifdef CONFIG_IP_MROUTE
198 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
199 	struct mr_table		*mrt;
200 #else
201 	struct list_head	mr_tables;
202 	struct fib_rules_ops	*mr_rules_ops;
203 #endif
204 #endif
205 #ifdef CONFIG_IP_ROUTE_MULTIPATH
206 	int sysctl_fib_multipath_use_neigh;
207 	int sysctl_fib_multipath_hash_policy;
208 #endif
209 
210 	struct fib_notifier_ops	*notifier_ops;
211 	unsigned int	fib_seq;	/* protected by rtnl_mutex */
212 
213 	struct fib_notifier_ops	*ipmr_notifier_ops;
214 	unsigned int	ipmr_seq;	/* protected by rtnl_mutex */
215 
216 	atomic_t	rt_genid;
217 };
218 #endif
219