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