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