ipv4.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * ipv4 in net namespaces
  4. */
  5. #ifndef __NETNS_IPV4_H__
  6. #define __NETNS_IPV4_H__
  7. #include <linux/uidgid.h>
  8. #include <net/inet_frag.h>
  9. #include <linux/rcupdate.h>
  10. #include <linux/seqlock.h>
  11. #include <linux/siphash.h>
  12. struct ctl_table_header;
  13. struct ipv4_devconf;
  14. struct fib_rules_ops;
  15. struct hlist_head;
  16. struct fib_table;
  17. struct sock;
  18. struct local_ports {
  19. u32 range; /* high << 16 | low */
  20. bool warned;
  21. };
  22. struct ping_group_range {
  23. seqlock_t lock;
  24. kgid_t range[2];
  25. };
  26. struct inet_hashinfo;
  27. struct inet_timewait_death_row {
  28. refcount_t tw_refcount;
  29. /* Padding to avoid false sharing, tw_refcount can be often written */
  30. struct inet_hashinfo *hashinfo ____cacheline_aligned_in_smp;
  31. int sysctl_max_tw_buckets;
  32. };
  33. struct tcp_fastopen_context;
  34. #ifdef CONFIG_IP_ROUTE_MULTIPATH
  35. struct sysctl_fib_multipath_hash_seed {
  36. u32 user_seed;
  37. u32 mp_seed;
  38. };
  39. #endif
  40. struct udp_tunnel_gro {
  41. struct sock __rcu *sk;
  42. struct hlist_head list;
  43. };
  44. struct netns_ipv4 {
  45. /* Cacheline organization can be found documented in
  46. * Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst.
  47. * Please update the document when adding new fields.
  48. */
  49. /* TX readonly hotpath cache lines */
  50. __cacheline_group_begin(netns_ipv4_read_tx);
  51. u8 sysctl_tcp_early_retrans;
  52. u8 sysctl_tcp_tso_win_divisor;
  53. u8 sysctl_tcp_tso_rtt_log;
  54. u8 sysctl_tcp_autocorking;
  55. int sysctl_tcp_min_snd_mss;
  56. unsigned int sysctl_tcp_notsent_lowat;
  57. int sysctl_tcp_limit_output_bytes;
  58. int sysctl_tcp_min_rtt_wlen;
  59. int sysctl_tcp_wmem[3];
  60. u8 sysctl_ip_fwd_use_pmtu;
  61. __cacheline_group_end(netns_ipv4_read_tx);
  62. /* TXRX readonly hotpath cache lines */
  63. __cacheline_group_begin(netns_ipv4_read_txrx);
  64. __cacheline_group_end(netns_ipv4_read_txrx);
  65. /* RX readonly hotpath cache line */
  66. __cacheline_group_begin(netns_ipv4_read_rx);
  67. u8 sysctl_tcp_moderate_rcvbuf;
  68. u8 sysctl_ip_early_demux;
  69. u8 sysctl_tcp_early_demux;
  70. u8 sysctl_tcp_l3mdev_accept;
  71. /* 3 bytes hole, try to pack */
  72. int sysctl_tcp_reordering;
  73. int sysctl_tcp_rmem[3];
  74. int sysctl_tcp_rcvbuf_low_rtt;
  75. __cacheline_group_end(netns_ipv4_read_rx);
  76. /* ICMP rate limiter hot cache line. */
  77. __cacheline_group_begin_aligned(icmp);
  78. atomic_t icmp_global_credit;
  79. u32 icmp_global_stamp;
  80. __cacheline_group_end_aligned(icmp);
  81. struct inet_timewait_death_row tcp_death_row;
  82. struct udp_table *udp_table;
  83. #if IS_ENABLED(CONFIG_NET_UDP_TUNNEL)
  84. /* Not in a pernet subsys because need to be available at GRO stage */
  85. struct udp_tunnel_gro udp_tunnel_gro[2];
  86. #endif
  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. struct hlist_head *fib_info_hash;
  114. unsigned int fib_info_hash_bits;
  115. unsigned int fib_info_cnt;
  116. struct sock *mc_autojoin_sk;
  117. struct inet_peer_base *peers;
  118. struct fqdir *fqdir;
  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. u8 sysctl_icmp_errors_extension_mask;
  125. int sysctl_icmp_ratelimit;
  126. int sysctl_icmp_ratemask;
  127. int sysctl_icmp_msgs_per_sec;
  128. int sysctl_icmp_msgs_burst;
  129. u32 ip_rt_min_pmtu;
  130. int ip_rt_mtu_expires;
  131. int ip_rt_min_advmss;
  132. struct local_ports ip_local_ports;
  133. u8 sysctl_tcp_ecn;
  134. u8 sysctl_tcp_ecn_option;
  135. u8 sysctl_tcp_ecn_option_beacon;
  136. u8 sysctl_tcp_ecn_fallback;
  137. u8 sysctl_ip_default_ttl;
  138. u8 sysctl_ip_no_pmtu_disc;
  139. u8 sysctl_ip_fwd_update_priority;
  140. u8 sysctl_ip_nonlocal_bind;
  141. u8 sysctl_ip_autobind_reuse;
  142. /* Shall we try to damage output packets if routing dev changes? */
  143. u8 sysctl_ip_dynaddr;
  144. #ifdef CONFIG_NET_L3_MASTER_DEV
  145. u8 sysctl_raw_l3mdev_accept;
  146. #endif
  147. u8 sysctl_udp_early_demux;
  148. u8 sysctl_nexthop_compat_mode;
  149. u8 sysctl_fwmark_reflect;
  150. u8 sysctl_tcp_fwmark_accept;
  151. u8 sysctl_tcp_mtu_probing;
  152. int sysctl_tcp_mtu_probe_floor;
  153. int sysctl_tcp_base_mss;
  154. int sysctl_tcp_probe_threshold;
  155. u32 sysctl_tcp_probe_interval;
  156. int sysctl_tcp_keepalive_time;
  157. int sysctl_tcp_keepalive_intvl;
  158. u8 sysctl_tcp_keepalive_probes;
  159. u8 sysctl_tcp_syn_retries;
  160. u8 sysctl_tcp_synack_retries;
  161. u8 sysctl_tcp_syncookies;
  162. u8 sysctl_tcp_migrate_req;
  163. u8 sysctl_tcp_comp_sack_nr;
  164. u8 sysctl_tcp_backlog_ack_defer;
  165. u8 sysctl_tcp_pingpong_thresh;
  166. u8 sysctl_tcp_retries1;
  167. u8 sysctl_tcp_retries2;
  168. u8 sysctl_tcp_orphan_retries;
  169. u8 sysctl_tcp_tw_reuse;
  170. unsigned int sysctl_tcp_tw_reuse_delay;
  171. int sysctl_tcp_fin_timeout;
  172. u8 sysctl_tcp_sack;
  173. u8 sysctl_tcp_window_scaling;
  174. u8 sysctl_tcp_timestamps;
  175. int sysctl_tcp_rto_min_us;
  176. int sysctl_tcp_rto_max_ms;
  177. u8 sysctl_tcp_recovery;
  178. u8 sysctl_tcp_thin_linear_timeouts;
  179. u8 sysctl_tcp_slow_start_after_idle;
  180. u8 sysctl_tcp_retrans_collapse;
  181. u8 sysctl_tcp_stdurg;
  182. u8 sysctl_tcp_rfc1337;
  183. u8 sysctl_tcp_abort_on_overflow;
  184. u8 sysctl_tcp_fack; /* obsolete */
  185. int sysctl_tcp_max_reordering;
  186. int sysctl_tcp_adv_win_scale; /* obsolete */
  187. u8 sysctl_tcp_dsack;
  188. u8 sysctl_tcp_app_win;
  189. u8 sysctl_tcp_frto;
  190. u8 sysctl_tcp_nometrics_save;
  191. u8 sysctl_tcp_no_ssthresh_metrics_save;
  192. u8 sysctl_tcp_workaround_signed_windows;
  193. int sysctl_tcp_challenge_ack_limit;
  194. u8 sysctl_tcp_min_tso_segs;
  195. u8 sysctl_tcp_reflect_tos;
  196. int sysctl_tcp_invalid_ratelimit;
  197. int sysctl_tcp_pacing_ss_ratio;
  198. int sysctl_tcp_pacing_ca_ratio;
  199. unsigned int sysctl_tcp_child_ehash_entries;
  200. int sysctl_tcp_comp_sack_rtt_percent;
  201. unsigned long sysctl_tcp_comp_sack_delay_ns;
  202. unsigned long sysctl_tcp_comp_sack_slack_ns;
  203. int sysctl_max_syn_backlog;
  204. int sysctl_tcp_fastopen;
  205. const struct tcp_congestion_ops __rcu *tcp_congestion_control;
  206. struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
  207. unsigned int sysctl_tcp_fastopen_blackhole_timeout;
  208. atomic_t tfo_active_disable_times;
  209. unsigned long tfo_active_disable_stamp;
  210. u32 tcp_challenge_timestamp;
  211. u32 tcp_challenge_count;
  212. u8 sysctl_tcp_plb_enabled;
  213. u8 sysctl_tcp_plb_idle_rehash_rounds;
  214. u8 sysctl_tcp_plb_rehash_rounds;
  215. u8 sysctl_tcp_plb_suspend_rto_sec;
  216. int sysctl_tcp_plb_cong_thresh;
  217. int sysctl_udp_wmem_min;
  218. int sysctl_udp_rmem_min;
  219. u8 sysctl_fib_notify_on_flag_change;
  220. u8 sysctl_tcp_syn_linear_timeouts;
  221. #ifdef CONFIG_NET_L3_MASTER_DEV
  222. u8 sysctl_udp_l3mdev_accept;
  223. #endif
  224. u8 sysctl_igmp_llm_reports;
  225. int sysctl_igmp_max_memberships;
  226. int sysctl_igmp_max_msf;
  227. int sysctl_igmp_qrv;
  228. struct ping_group_range ping_group_range;
  229. u16 ping_port_rover;
  230. atomic_t dev_addr_genid;
  231. unsigned int sysctl_udp_child_hash_entries;
  232. #ifdef CONFIG_SYSCTL
  233. unsigned long *sysctl_local_reserved_ports;
  234. int sysctl_ip_prot_sock;
  235. #endif
  236. #ifdef CONFIG_IP_MROUTE
  237. #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
  238. struct mr_table *mrt;
  239. #else
  240. struct list_head mr_tables;
  241. struct fib_rules_ops *mr_rules_ops;
  242. #endif
  243. #endif
  244. #ifdef CONFIG_IP_ROUTE_MULTIPATH
  245. struct sysctl_fib_multipath_hash_seed sysctl_fib_multipath_hash_seed;
  246. u32 sysctl_fib_multipath_hash_fields;
  247. u8 sysctl_fib_multipath_use_neigh;
  248. u8 sysctl_fib_multipath_hash_policy;
  249. #endif
  250. struct fib_notifier_ops *notifier_ops;
  251. unsigned int fib_seq; /* writes protected by rtnl_mutex */
  252. struct fib_notifier_ops *ipmr_notifier_ops;
  253. unsigned int ipmr_seq; /* protected by rtnl_mutex */
  254. atomic_t rt_genid;
  255. siphash_key_t ip_id_key;
  256. struct hlist_head *inet_addr_lst;
  257. struct delayed_work addr_chk_work;
  258. };
  259. #endif