aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_vs.h
diff options
context:
space:
mode:
authorJulian Anastasov <ja@ssi.bg>2012-04-24 16:46:40 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2012-05-08 13:40:10 -0400
commit749c42b620a9511782bc38d0a88702a42434529e (patch)
tree057b15f2bbd7fad96becdada1dc2ee775482e0b6 /include/net/ip_vs.h
parent1c003b1580e20ff9f500846677303a695b1837cc (diff)
ipvs: reduce sync rate with time thresholds
Add two new sysctl vars to control the sync rate with the main idea to reduce the rate for connection templates because currently it depends on the packet rate for controlled connections. This mechanism should be useful also for normal connections with high traffic. sync_refresh_period: in seconds, difference in reported connection timer that triggers new sync message. It can be used to avoid sync messages for the specified period (or half of the connection timeout if it is lower) if connection state is not changed from last sync. sync_retries: integer, 0..3, defines sync retries with period of sync_refresh_period/8. Useful to protect against loss of sync messages. Allow sysctl_sync_threshold to be used with sysctl_sync_period=0, so that only single sync message is sent if sync_refresh_period is also 0. Add new field "sync_endtime" in connection structure to hold the reported time when connection expires. The 2 lowest bits will represent the retry count. As the sysctl_sync_period now can be 0 use ACCESS_ONCE to avoid division by zero. Special thanks to Aleksey Chudov for being patient with me, for his extensive reports and 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.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 30e43c8c0283..d3a4b934d521 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -504,6 +504,7 @@ struct ip_vs_conn {
504 * state transition triggerd 504 * state transition triggerd
505 * synchronization 505 * synchronization
506 */ 506 */
507 unsigned long sync_endtime; /* jiffies + sent_retries */
507 508
508 /* Control members */ 509 /* Control members */
509 struct ip_vs_conn *control; /* Master control connection */ 510 struct ip_vs_conn *control; /* Master control connection */
@@ -875,6 +876,8 @@ struct netns_ipvs {
875 int sysctl_expire_nodest_conn; 876 int sysctl_expire_nodest_conn;
876 int sysctl_expire_quiescent_template; 877 int sysctl_expire_quiescent_template;
877 int sysctl_sync_threshold[2]; 878 int sysctl_sync_threshold[2];
879 unsigned int sysctl_sync_refresh_period;
880 int sysctl_sync_retries;
878 int sysctl_nat_icmp_send; 881 int sysctl_nat_icmp_send;
879 882
880 /* ip_vs_lblc */ 883 /* ip_vs_lblc */
@@ -916,10 +919,13 @@ struct netns_ipvs {
916#define DEFAULT_SYNC_THRESHOLD 3 919#define DEFAULT_SYNC_THRESHOLD 3
917#define DEFAULT_SYNC_PERIOD 50 920#define DEFAULT_SYNC_PERIOD 50
918#define DEFAULT_SYNC_VER 1 921#define DEFAULT_SYNC_VER 1
922#define DEFAULT_SYNC_REFRESH_PERIOD (0U * HZ)
923#define DEFAULT_SYNC_RETRIES 0
919#define IPVS_SYNC_WAKEUP_RATE 8 924#define IPVS_SYNC_WAKEUP_RATE 8
920#define IPVS_SYNC_QLEN_MAX (IPVS_SYNC_WAKEUP_RATE * 4) 925#define IPVS_SYNC_QLEN_MAX (IPVS_SYNC_WAKEUP_RATE * 4)
921#define IPVS_SYNC_SEND_DELAY (HZ / 50) 926#define IPVS_SYNC_SEND_DELAY (HZ / 50)
922#define IPVS_SYNC_CHECK_PERIOD HZ 927#define IPVS_SYNC_CHECK_PERIOD HZ
928#define IPVS_SYNC_FLUSH_TIME (HZ * 2)
923 929
924#ifdef CONFIG_SYSCTL 930#ifdef CONFIG_SYSCTL
925 931
@@ -930,7 +936,17 @@ static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
930 936
931static inline int sysctl_sync_period(struct netns_ipvs *ipvs) 937static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
932{ 938{
933 return ipvs->sysctl_sync_threshold[1]; 939 return ACCESS_ONCE(ipvs->sysctl_sync_threshold[1]);
940}
941
942static inline unsigned int sysctl_sync_refresh_period(struct netns_ipvs *ipvs)
943{
944 return ACCESS_ONCE(ipvs->sysctl_sync_refresh_period);
945}
946
947static inline int sysctl_sync_retries(struct netns_ipvs *ipvs)
948{
949 return ipvs->sysctl_sync_retries;
934} 950}
935 951
936static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) 952static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
@@ -960,6 +976,16 @@ static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
960 return DEFAULT_SYNC_PERIOD; 976 return DEFAULT_SYNC_PERIOD;
961} 977}
962 978
979static inline unsigned int sysctl_sync_refresh_period(struct netns_ipvs *ipvs)
980{
981 return DEFAULT_SYNC_REFRESH_PERIOD;
982}
983
984static inline int sysctl_sync_retries(struct netns_ipvs *ipvs)
985{
986 return DEFAULT_SYNC_RETRIES & 3;
987}
988
963static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) 989static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
964{ 990{
965 return DEFAULT_SYNC_VER; 991 return DEFAULT_SYNC_VER;
@@ -1248,7 +1274,7 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
1248extern int start_sync_thread(struct net *net, int state, char *mcast_ifn, 1274extern int start_sync_thread(struct net *net, int state, char *mcast_ifn,
1249 __u8 syncid); 1275 __u8 syncid);
1250extern int stop_sync_thread(struct net *net, int state); 1276extern int stop_sync_thread(struct net *net, int state);
1251extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp); 1277extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp, int pkts);
1252 1278
1253 1279
1254/* 1280/*