2.4 version as advertised.
[IPVS, 2.4] Ignore expired templates and cleanup expiry
* Backport 2.6's behaviour to delete timers rather than
seting their expriy to 0 in ip_vs_conn_expire_now().
* Give expired connections a nice short timeout.
3*HZ is arbitary, though it matches the timeout
that connections are given when they are created.
* Mark expired connections with a new flag, IP_VS_CONN_F_EXPIRED.
This is simply brilliant! Atomic change without breaking anything as
mentioned by Julian's concerns.
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index ba304fa..ab16dbc 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -83,6 +83,10 @@
#define IP_VS_CONN_F_SEQ_MASK 0x0600 /* in/out sequence mask */
#define IP_VS_CONN_F_NO_CPORT 0x0800 /* no client port set yet */
#define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */
+#define IP_VS_CONN_F_EXPIRED 0x2000 /* expired, currently used to
+ mark old templates whose
+ controlled connections are
+ yet to expire */
/* Move it to better place one day, for now keep it unique */
#define NFC_IPVS_PROPERTY 0x10000
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 015c819..ea3f778 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -257,6 +257,7 @@ struct ip_vs_conn *ip_vs_ct_in_get
if (s_addr==cp->caddr && s_port==cp->cport &&
d_port==cp->vport && d_addr==cp->vaddr &&
cp->flags & IP_VS_CONN_F_TEMPLATE &&
+ ! cp->flags & IP_VS_CONN_F_EXPIRED &&
protocol==cp->protocol) {
/* HIT */
atomic_inc(&cp->refcnt);
@@ -1221,10 +1222,9 @@ static void ip_vs_conn_expire(unsigned l
{
struct ip_vs_conn *cp = (struct ip_vs_conn *)data;
- if (cp->timeout_table)
- cp->timeout = cp->timeout_table->timeout[IP_VS_S_TIME_WAIT];
- else
- cp->timeout = vs_timeout_table.timeout[IP_VS_S_TIME_WAIT];
+ cp->timeout = 3*HZ;
+ /* Only effects templates, but harmless for others */
+ cp->flags |= IP_VS_CONN_F_EXPIRED;
Well, using this we can also leave the 60*HZ. Flagging the template as
expired is a really great idea and should not break anything.
/*
* hey, I'm using it
@@ -1280,8 +1280,8 @@ static void ip_vs_conn_expire(unsigned l
void ip_vs_conn_expire_now(struct ip_vs_conn *cp)
{
- cp->timeout = 0;
- mod_timer(&cp->timer, jiffies);
+ if (del_timer(&cp->timer))
+ mod_timer(&cp->timer, jiffies);
}
Similar to 2.6, right?
I'll include your patch as a hotfix to my local tree which needs to be
released today.
Best regards and thanks for putting so much thinking into it,
Roberto Nibali, ratz
--
-------------------------------------------------------------
addr://Kasinostrasse 30, CH-5001 Aarau tel://++41 62 823 9355
http://www.terreactive.com fax://++41 62 823 9356
-------------------------------------------------------------
terreActive AG Wir sichern Ihren Erfolg
-------------------------------------------------------------
|