aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJulian Anastasov <ja@ssi.bg>2013-06-24 15:44:41 -0400
committerSimon Horman <horms@verge.net.au>2013-06-26 05:01:46 -0400
commit4d0c875dcc4923476f364e83912d134da2df224c (patch)
treede662531facb4cd1629d0b2b9e8cac996a08a9be /net
parenteba3b5a78799d21dea05118b294524958f0ab592 (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>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c7
-rw-r--r--net/netfilter/ipvs/ip_vs_sync.c12
2 files changed, 19 insertions, 0 deletions
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 */
429static 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) |