diff options
author | Julian Anastasov <ja@ssi.bg> | 2013-06-24 15:44:41 -0400 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-06-26 05:01:46 -0400 |
commit | 4d0c875dcc4923476f364e83912d134da2df224c (patch) | |
tree | de662531facb4cd1629d0b2b9e8cac996a08a9be | |
parent | eba3b5a78799d21dea05118b294524958f0ab592 (diff) |
ipvs: add sync_persist_mode flag
Add sync_persist_mode flag to reduce sync traffic
by syncing only persistent templates.
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>
-rw-r--r-- | Documentation/networking/ipvs-sysctl.txt | 13 | ||||
-rw-r--r-- | include/net/ip_vs.h | 11 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_ctl.c | 7 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_sync.c | 12 |
4 files changed, 43 insertions, 0 deletions
diff --git a/Documentation/networking/ipvs-sysctl.txt b/Documentation/networking/ipvs-sysctl.txt index 9573d0c48c6e..7a3c04729591 100644 --- a/Documentation/networking/ipvs-sysctl.txt +++ b/Documentation/networking/ipvs-sysctl.txt | |||
@@ -181,6 +181,19 @@ snat_reroute - BOOLEAN | |||
181 | always be the same as the original route so it is an optimisation | 181 | always be the same as the original route so it is an optimisation |
182 | to disable snat_reroute and avoid the recalculation. | 182 | to disable snat_reroute and avoid the recalculation. |
183 | 183 | ||
184 | sync_persist_mode - INTEGER | ||
185 | default 0 | ||
186 | |||
187 | Controls the synchronisation of connections when using persistence | ||
188 | |||
189 | 0: All types of connections are synchronised | ||
190 | 1: Attempt to reduce the synchronisation traffic depending on | ||
191 | the connection type. For persistent services avoid synchronisation | ||
192 | for normal connections, do it only for persistence templates. | ||
193 | In such case, for TCP and SCTP it may need enabling sloppy_tcp and | ||
194 | sloppy_sctp flags on backup servers. For non-persistent services | ||
195 | such optimization is not applied, mode 0 is assumed. | ||
196 | |||
184 | sync_version - INTEGER | 197 | sync_version - INTEGER |
185 | default 1 | 198 | default 1 |
186 | 199 | ||
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index e667df171003..f0d70f066f3d 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -975,6 +975,7 @@ struct netns_ipvs { | |||
975 | int sysctl_snat_reroute; | 975 | int sysctl_snat_reroute; |
976 | int sysctl_sync_ver; | 976 | int sysctl_sync_ver; |
977 | int sysctl_sync_ports; | 977 | int sysctl_sync_ports; |
978 | int sysctl_sync_persist_mode; | ||
978 | unsigned long sysctl_sync_qlen_max; | 979 | unsigned long sysctl_sync_qlen_max; |
979 | int sysctl_sync_sock_size; | 980 | int sysctl_sync_sock_size; |
980 | int sysctl_cache_bypass; | 981 | int sysctl_cache_bypass; |
@@ -1076,6 +1077,11 @@ static inline int sysctl_sync_ports(struct netns_ipvs *ipvs) | |||
1076 | return ACCESS_ONCE(ipvs->sysctl_sync_ports); | 1077 | return ACCESS_ONCE(ipvs->sysctl_sync_ports); |
1077 | } | 1078 | } |
1078 | 1079 | ||
1080 | static inline int sysctl_sync_persist_mode(struct netns_ipvs *ipvs) | ||
1081 | { | ||
1082 | return ipvs->sysctl_sync_persist_mode; | ||
1083 | } | ||
1084 | |||
1079 | static inline unsigned long sysctl_sync_qlen_max(struct netns_ipvs *ipvs) | 1085 | static inline unsigned long sysctl_sync_qlen_max(struct netns_ipvs *ipvs) |
1080 | { | 1086 | { |
1081 | return ipvs->sysctl_sync_qlen_max; | 1087 | return ipvs->sysctl_sync_qlen_max; |
@@ -1139,6 +1145,11 @@ static inline int sysctl_sync_ports(struct netns_ipvs *ipvs) | |||
1139 | return 1; | 1145 | return 1; |
1140 | } | 1146 | } |
1141 | 1147 | ||
1148 | static inline int sysctl_sync_persist_mode(struct netns_ipvs *ipvs) | ||
1149 | { | ||
1150 | return 0; | ||
1151 | } | ||
1152 | |||
1142 | static inline unsigned long sysctl_sync_qlen_max(struct netns_ipvs *ipvs) | 1153 | static inline unsigned long sysctl_sync_qlen_max(struct netns_ipvs *ipvs) |
1143 | { | 1154 | { |
1144 | return IPVS_SYNC_QLEN_MAX; | 1155 | return IPVS_SYNC_QLEN_MAX; |
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index da035fc01eb2..c8148e487386 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c | |||
@@ -1715,6 +1715,12 @@ static struct ctl_table vs_vars[] = { | |||
1715 | .proc_handler = &proc_do_sync_ports, | 1715 | .proc_handler = &proc_do_sync_ports, |
1716 | }, | 1716 | }, |
1717 | { | 1717 | { |
1718 | .procname = "sync_persist_mode", | ||
1719 | .maxlen = sizeof(int), | ||
1720 | .mode = 0644, | ||
1721 | .proc_handler = proc_dointvec, | ||
1722 | }, | ||
1723 | { | ||
1718 | .procname = "sync_qlen_max", | 1724 | .procname = "sync_qlen_max", |
1719 | .maxlen = sizeof(unsigned long), | 1725 | .maxlen = sizeof(unsigned long), |
1720 | .mode = 0644, | 1726 | .mode = 0644, |
@@ -3729,6 +3735,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net) | |||
3729 | tbl[idx++].data = &ipvs->sysctl_sync_ver; | 3735 | tbl[idx++].data = &ipvs->sysctl_sync_ver; |
3730 | ipvs->sysctl_sync_ports = 1; | 3736 | ipvs->sysctl_sync_ports = 1; |
3731 | tbl[idx++].data = &ipvs->sysctl_sync_ports; | 3737 | tbl[idx++].data = &ipvs->sysctl_sync_ports; |
3738 | tbl[idx++].data = &ipvs->sysctl_sync_persist_mode; | ||
3732 | ipvs->sysctl_sync_qlen_max = nr_free_buffer_pages() / 32; | 3739 | ipvs->sysctl_sync_qlen_max = nr_free_buffer_pages() / 32; |
3733 | tbl[idx++].data = &ipvs->sysctl_sync_qlen_max; | 3740 | tbl[idx++].data = &ipvs->sysctl_sync_qlen_max; |
3734 | ipvs->sysctl_sync_sock_size = 0; | 3741 | ipvs->sysctl_sync_sock_size = 0; |
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 2fc66394d86d..f4484719f3e6 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c | |||
@@ -425,6 +425,16 @@ ip_vs_sync_buff_create_v0(struct netns_ipvs *ipvs) | |||
425 | return sb; | 425 | return sb; |
426 | } | 426 | } |
427 | 427 | ||
428 | /* Check if connection is controlled by persistence */ | ||
429 | static inline bool in_persistence(struct ip_vs_conn *cp) | ||
430 | { | ||
431 | for (cp = cp->control; cp; cp = cp->control) { | ||
432 | if (cp->flags & IP_VS_CONN_F_TEMPLATE) | ||
433 | return true; | ||
434 | } | ||
435 | return false; | ||
436 | } | ||
437 | |||
428 | /* Check if conn should be synced. | 438 | /* Check if conn should be synced. |
429 | * pkts: conn packets, use sysctl_sync_threshold to avoid packet check | 439 | * pkts: conn packets, use sysctl_sync_threshold to avoid packet check |
430 | * - (1) sync_refresh_period: reduce sync rate. Additionally, retry | 440 | * - (1) sync_refresh_period: reduce sync rate. Additionally, retry |
@@ -447,6 +457,8 @@ static int ip_vs_sync_conn_needed(struct netns_ipvs *ipvs, | |||
447 | /* Check if we sync in current state */ | 457 | /* Check if we sync in current state */ |
448 | if (unlikely(cp->flags & IP_VS_CONN_F_TEMPLATE)) | 458 | if (unlikely(cp->flags & IP_VS_CONN_F_TEMPLATE)) |
449 | force = 0; | 459 | force = 0; |
460 | else if (unlikely(sysctl_sync_persist_mode(ipvs) && in_persistence(cp))) | ||
461 | return 0; | ||
450 | else if (likely(cp->protocol == IPPROTO_TCP)) { | 462 | else if (likely(cp->protocol == IPPROTO_TCP)) { |
451 | if (!((1 << cp->state) & | 463 | if (!((1 << cp->state) & |
452 | ((1 << IP_VS_TCP_S_ESTABLISHED) | | 464 | ((1 << IP_VS_TCP_S_ESTABLISHED) | |