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