[PATCH] ipvs: Fix reuse connection if real server is dead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Expire cached connection for new TCP connection if real server is down

Signed-off-by: Grzegorz Lyczba <grzegorz.lyczba@xxxxxxxxx>
---
 net/netfilter/ipvs/ip_vs_core.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 47edf5a..7c5f083 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1002,6 +1002,17 @@ static inline int is_tcp_reset(const struct sk_buff *skb, int nh_len)
 	return th->rst;
 }
 
+static inline int is_tcp_syn(const struct sk_buff *skb, int nh_len)
+{
+    struct tcphdr _tcph, *th;
+
+    th = skb_header_pointer(skb, nh_len, sizeof(_tcph), &_tcph);
+    if (th == NULL)
+        return 0;
+    return th->syn;
+}
+
+
 /* Handle response packets: rewrite addresses and send away...
  */
 static unsigned int
@@ -1627,6 +1638,15 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
 	 * Check if the packet belongs to an existing connection entry
 	 */
 	cp = pp->conn_in_get(af, skb, &iph, 0);
+
+	if (likely(cp) && likely(cp->dest) &&
+	    unlikely(!atomic_read(&cp->dest->weight)) &&
+	    iph.protocol == IPPROTO_TCP && is_tcp_syn(skb, iph.len)) {
+		ip_vs_conn_expire_now(cp);
+		__ip_vs_conn_put(cp);
+		cp = NULL;
+	}
+
 	if (unlikely(!cp) && !iph.fragoffs) {
 		/* No (second) fragments need to enter here, as nf_defrag_ipv6
 		 * replayed fragment zero will already have created the cp
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Devel]     [Linux NFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [X.Org]

  Powered by Linux