ip_vs.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * IP Virtual Server
  3. * Data structure for network namspace
  4. *
  5. */
  6. #ifndef IP_VS_H_
  7. #define IP_VS_H_
  8. #include <linux/list.h>
  9. #include <linux/mutex.h>
  10. #include <linux/list_nulls.h>
  11. #include <linux/ip_vs.h>
  12. #include <asm/atomic.h>
  13. #include <linux/in.h>
  14. struct ip_vs_stats;
  15. struct ip_vs_sync_buff;
  16. struct ctl_table_header;
  17. struct netns_ipvs {
  18. int gen; /* Generation */
  19. /*
  20. * Hash table: for real service lookups
  21. */
  22. #define IP_VS_RTAB_BITS 4
  23. #define IP_VS_RTAB_SIZE (1 << IP_VS_RTAB_BITS)
  24. #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1)
  25. struct list_head rs_table[IP_VS_RTAB_SIZE];
  26. /* ip_vs_app */
  27. struct list_head app_list;
  28. struct mutex app_mutex;
  29. struct lock_class_key app_key; /* mutex debuging */
  30. /* ip_vs_proto */
  31. #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
  32. struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
  33. /* ip_vs_proto_tcp */
  34. #ifdef CONFIG_IP_VS_PROTO_TCP
  35. #define TCP_APP_TAB_BITS 4
  36. #define TCP_APP_TAB_SIZE (1 << TCP_APP_TAB_BITS)
  37. #define TCP_APP_TAB_MASK (TCP_APP_TAB_SIZE - 1)
  38. struct list_head tcp_apps[TCP_APP_TAB_SIZE];
  39. spinlock_t tcp_app_lock;
  40. #endif
  41. /* ip_vs_proto_udp */
  42. #ifdef CONFIG_IP_VS_PROTO_UDP
  43. #define UDP_APP_TAB_BITS 4
  44. #define UDP_APP_TAB_SIZE (1 << UDP_APP_TAB_BITS)
  45. #define UDP_APP_TAB_MASK (UDP_APP_TAB_SIZE - 1)
  46. struct list_head udp_apps[UDP_APP_TAB_SIZE];
  47. spinlock_t udp_app_lock;
  48. #endif
  49. /* ip_vs_proto_sctp */
  50. #ifdef CONFIG_IP_VS_PROTO_SCTP
  51. #define SCTP_APP_TAB_BITS 4
  52. #define SCTP_APP_TAB_SIZE (1 << SCTP_APP_TAB_BITS)
  53. #define SCTP_APP_TAB_MASK (SCTP_APP_TAB_SIZE - 1)
  54. /* Hash table for SCTP application incarnations */
  55. struct list_head sctp_apps[SCTP_APP_TAB_SIZE];
  56. spinlock_t sctp_app_lock;
  57. #endif
  58. /* ip_vs_conn */
  59. atomic_t conn_count; /* connection counter */
  60. /* ip_vs_ctl */
  61. struct ip_vs_stats *tot_stats; /* Statistics & est. */
  62. struct ip_vs_cpu_stats __percpu *cpustats; /* Stats per cpu */
  63. seqcount_t *ustats_seq; /* u64 read retry */
  64. int num_services; /* no of virtual services */
  65. /* 1/rate drop and drop-entry variables */
  66. struct delayed_work defense_work; /* Work handler */
  67. int drop_rate;
  68. int drop_counter;
  69. atomic_t dropentry;
  70. /* locks in ctl.c */
  71. spinlock_t dropentry_lock; /* drop entry handling */
  72. spinlock_t droppacket_lock; /* drop packet handling */
  73. spinlock_t securetcp_lock; /* state and timeout tables */
  74. rwlock_t rs_lock; /* real services table */
  75. /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
  76. struct lock_class_key ctl_key; /* ctl_mutex debuging */
  77. /* Trash for destinations */
  78. struct list_head dest_trash;
  79. /* Service counters */
  80. atomic_t ftpsvc_counter;
  81. atomic_t nullsvc_counter;
  82. /* sys-ctl struct */
  83. struct ctl_table_header *sysctl_hdr;
  84. struct ctl_table *sysctl_tbl;
  85. /* sysctl variables */
  86. int sysctl_amemthresh;
  87. int sysctl_am_droprate;
  88. int sysctl_drop_entry;
  89. int sysctl_drop_packet;
  90. int sysctl_secure_tcp;
  91. #ifdef CONFIG_IP_VS_NFCT
  92. int sysctl_conntrack;
  93. #endif
  94. int sysctl_snat_reroute;
  95. int sysctl_sync_ver;
  96. int sysctl_cache_bypass;
  97. int sysctl_expire_nodest_conn;
  98. int sysctl_expire_quiescent_template;
  99. int sysctl_sync_threshold[2];
  100. int sysctl_nat_icmp_send;
  101. /* ip_vs_lblc */
  102. int sysctl_lblc_expiration;
  103. struct ctl_table_header *lblc_ctl_header;
  104. struct ctl_table *lblc_ctl_table;
  105. /* ip_vs_lblcr */
  106. int sysctl_lblcr_expiration;
  107. struct ctl_table_header *lblcr_ctl_header;
  108. struct ctl_table *lblcr_ctl_table;
  109. /* ip_vs_est */
  110. struct list_head est_list; /* estimator list */
  111. spinlock_t est_lock;
  112. struct timer_list est_timer; /* Estimation timer */
  113. /* ip_vs_sync */
  114. struct list_head sync_queue;
  115. spinlock_t sync_lock;
  116. struct ip_vs_sync_buff *sync_buff;
  117. spinlock_t sync_buff_lock;
  118. struct sockaddr_in sync_mcast_addr;
  119. struct task_struct *master_thread;
  120. struct task_struct *backup_thread;
  121. int send_mesg_maxlen;
  122. int recv_mesg_maxlen;
  123. volatile int sync_state;
  124. volatile int master_syncid;
  125. volatile int backup_syncid;
  126. /* multicast interface name */
  127. char master_mcast_ifn[IP_VS_IFNAME_MAXLEN];
  128. char backup_mcast_ifn[IP_VS_IFNAME_MAXLEN];
  129. /* net name space ptr */
  130. struct net *net; /* Needed by timer routines */
  131. };
  132. #endif /* IP_VS_H_ */