aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_vs.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-05-08 13:40:30 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2012-05-08 13:40:33 -0400
commitf73181c8288fc38747ec4f0f3e8a9052ab785cd5 (patch)
tree9523b3ba632e051b3d196f3bc6d8b0258e7c4fcd /include/net/ip_vs.h
parent749c42b620a9511782bc38d0a88702a42434529e (diff)
ipvs: add support for sync threads
Allow master and backup servers to use many threads for sync traffic. Add sysctl var "sync_ports" to define the number of threads. Every thread will use single UDP port, thread 0 will use the default port 8848 while last thread will use port 8848+sync_ports-1. The sync traffic for connections is scheduled to many master threads based on the cp address but one connection is always assigned to same thread to avoid reordering of the sync messages. Remove ip_vs_sync_switch_mode because this check for sync mode change is still risky. Instead, check for mode change under sync_buff_lock. Make sure the backup socks do not block on reading. Special thanks to Aleksey Chudov for helping in all tests. Signed-off-by: Julian Anastasov <ja@ssi.bg> Tested-by: Aleksey Chudov <aleksey.chudov@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r--include/net/ip_vs.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index d3a4b934d521..d6146b4811c2 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -784,6 +784,16 @@ struct ip_vs_app {
784 void (*timeout_change)(struct ip_vs_app *app, int flags); 784 void (*timeout_change)(struct ip_vs_app *app, int flags);
785}; 785};
786 786
787struct ipvs_master_sync_state {
788 struct list_head sync_queue;
789 struct ip_vs_sync_buff *sync_buff;
790 int sync_queue_len;
791 unsigned int sync_queue_delay;
792 struct task_struct *master_thread;
793 struct delayed_work master_wakeup_work;
794 struct netns_ipvs *ipvs;
795};
796
787/* IPVS in network namespace */ 797/* IPVS in network namespace */
788struct netns_ipvs { 798struct netns_ipvs {
789 int gen; /* Generation */ 799 int gen; /* Generation */
@@ -870,6 +880,7 @@ struct netns_ipvs {
870#endif 880#endif
871 int sysctl_snat_reroute; 881 int sysctl_snat_reroute;
872 int sysctl_sync_ver; 882 int sysctl_sync_ver;
883 int sysctl_sync_ports;
873 int sysctl_sync_qlen_max; 884 int sysctl_sync_qlen_max;
874 int sysctl_sync_sock_size; 885 int sysctl_sync_sock_size;
875 int sysctl_cache_bypass; 886 int sysctl_cache_bypass;
@@ -893,16 +904,11 @@ struct netns_ipvs {
893 spinlock_t est_lock; 904 spinlock_t est_lock;
894 struct timer_list est_timer; /* Estimation timer */ 905 struct timer_list est_timer; /* Estimation timer */
895 /* ip_vs_sync */ 906 /* ip_vs_sync */
896 struct list_head sync_queue;
897 int sync_queue_len;
898 unsigned int sync_queue_delay;
899 struct delayed_work master_wakeup_work;
900 spinlock_t sync_lock; 907 spinlock_t sync_lock;
901 struct ip_vs_sync_buff *sync_buff; 908 struct ipvs_master_sync_state *ms;
902 spinlock_t sync_buff_lock; 909 spinlock_t sync_buff_lock;
903 struct sockaddr_in sync_mcast_addr; 910 struct task_struct **backup_threads;
904 struct task_struct *master_thread; 911 int threads_mask;
905 struct task_struct *backup_thread;
906 int send_mesg_maxlen; 912 int send_mesg_maxlen;
907 int recv_mesg_maxlen; 913 int recv_mesg_maxlen;
908 volatile int sync_state; 914 volatile int sync_state;
@@ -926,6 +932,7 @@ struct netns_ipvs {
926#define IPVS_SYNC_SEND_DELAY (HZ / 50) 932#define IPVS_SYNC_SEND_DELAY (HZ / 50)
927#define IPVS_SYNC_CHECK_PERIOD HZ 933#define IPVS_SYNC_CHECK_PERIOD HZ
928#define IPVS_SYNC_FLUSH_TIME (HZ * 2) 934#define IPVS_SYNC_FLUSH_TIME (HZ * 2)
935#define IPVS_SYNC_PORTS_MAX (1 << 6)
929 936
930#ifdef CONFIG_SYSCTL 937#ifdef CONFIG_SYSCTL
931 938
@@ -954,6 +961,11 @@ static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
954 return ipvs->sysctl_sync_ver; 961 return ipvs->sysctl_sync_ver;
955} 962}
956 963
964static inline int sysctl_sync_ports(struct netns_ipvs *ipvs)
965{
966 return ACCESS_ONCE(ipvs->sysctl_sync_ports);
967}
968
957static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs) 969static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs)
958{ 970{
959 return ipvs->sysctl_sync_qlen_max; 971 return ipvs->sysctl_sync_qlen_max;
@@ -991,6 +1003,11 @@ static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
991 return DEFAULT_SYNC_VER; 1003 return DEFAULT_SYNC_VER;
992} 1004}
993 1005
1006static inline int sysctl_sync_ports(struct netns_ipvs *ipvs)
1007{
1008 return 1;
1009}
1010
994static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs) 1011static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs)
995{ 1012{
996 return IPVS_SYNC_QLEN_MAX; 1013 return IPVS_SYNC_QLEN_MAX;
@@ -1240,7 +1257,6 @@ extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg);
1240extern struct ip_vs_stats ip_vs_stats; 1257extern struct ip_vs_stats ip_vs_stats;
1241extern int sysctl_ip_vs_sync_ver; 1258extern int sysctl_ip_vs_sync_ver;
1242 1259
1243extern void ip_vs_sync_switch_mode(struct net *net, int mode);
1244extern struct ip_vs_service * 1260extern struct ip_vs_service *
1245ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, 1261ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol,
1246 const union nf_inet_addr *vaddr, __be16 vport); 1262 const union nf_inet_addr *vaddr, __be16 vport);