Skip to contentSkip to conversation

ipvs: Keep track of backlog connections

PATCH New Simon Horman 1 participant 1 message Sep 27, 2010

Subsystems (5)
lore
Share & tools
lore

Simon Horman

author maintainer
#0 lore raw

PATCH 1/1 ipvs: Keep track of backlog connections

From: Sven Wegener <[email protected]>

A backlog connection is a connection that is on its way from inactive to active. Speaking in TCP language, a connection from which we've seen the initial SYN packet, but the three-way handshake hasn't finished yet. These connections are expected to move to active soon. When a destination is overloaded or isn't able to successfully establish connections for various reasons, this count increases quickly and is an indication for a problem.

---

Patrick, please consider this for nf-next

include/linux/ip_vs.h renamed from linux/include/linux/ip_vs.h +0 -0
diff -urp net-next-2.6-e548833-nfct/linux/include/linux/ip_vs.h linux/include/linux/ip_vs.h
@@ -91,6 +91,7 @@
 

/* Flags that are not sent to backup server start from bit 16 */
#define IP_VS_CONN_F_NFCT (1 << 16) /* use netfilter conntrack */
+#define IP_VS_CONN_F_BACKLOG (1 << 17) /* backlog connection */

/* Connection flags from destination that can be changed by user space */ #define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \
@@ -360,6 +361,7 @@ enum {
IPVS_DEST_ATTR_PERSIST_CONNS, /* persistent connections */

IPVS_DEST_ATTR_STATS, /* nested attribute for dest stats */
+ IPVS_DEST_ATTR_BACKLOG_CONNS, /* backlog connections */

	__IPVS_DEST_ATTR_MAX,
};
include/net/ip_vs.h renamed from linux/include/net/ip_vs.h +0 -0
diff -urp net-next-2.6-e548833-nfct/linux/include/net/ip_vs.h linux/include/net/ip_vs.h
@@ -501,6 +501,7 @@ struct ip_vs_dest {

/* connection counters and thresholds */
atomic_t activeconns; /* active connections */
atomic_t inactconns; /* inactive connections */
+ atomic_t backlogconns; /* backlog connections */

	atomic_t		persistconns;	/* persistent connections */
	__u32			u_threshold;	/* upper threshold */
	__u32			l_threshold;	/* lower threshold */
net/netfilter/ipvs/ip_vs_conn.c renamed from linux/net/netfilter/ipvs/ip_vs_conn.c +0 -0
diff -urp net-next-2.6-e548833-nfct/linux/net/netfilter/ipvs/ip_vs_conn.c linux/net/netfilter/ipvs/ip_vs_conn.c
@@ -611,6 +611,8 @@ static inline void ip_vs_unbind_dest(str
		} else {
			atomic_dec(&dest->activeconns);
		}
+		if (cp->flags & IP_VS_CONN_F_BACKLOG)
+			atomic_dec(&dest->backlogconns);
	} else {
		/* It is a persistent connection/template, so decrease
		   the peristent connection counter */
net/netfilter/ipvs/ip_vs_ctl.c renamed from linux/net/netfilter/ipvs/ip_vs_ctl.c +0 -0
diff -urp net-next-2.6-e548833-nfct/linux/net/netfilter/ipvs/ip_vs_ctl.c linux/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2593,6 +2593,7 @@ static const struct nla_policy ip_vs_des
	[IPVS_DEST_ATTR_INACT_CONNS]	= { .type = NLA_U32 },
	[IPVS_DEST_ATTR_PERSIST_CONNS]	= { .type = NLA_U32 },
	[IPVS_DEST_ATTR_STATS]		= { .type = NLA_NESTED },

+ [IPVS_DEST_ATTR_BACKLOG_CONNS] = { .type = NLA_U32 },
};

static int ip_vs_genl_fill_stats(struct sk_buff *skb, int container_type, @@ -2840,6 +2841,8 @@ static int ip_vs_genl_fill_dest(struct s

		    atomic_read(&dest->activeconns));
	NLA_PUT_U32(skb, IPVS_DEST_ATTR_INACT_CONNS,
		    atomic_read(&dest->inactconns));
+	NLA_PUT_U32(skb, IPVS_DEST_ATTR_BACKLOG_CONNS,
+		    atomic_read(&dest->backlogconns));
	NLA_PUT_U32(skb, IPVS_DEST_ATTR_PERSIST_CONNS,
		    atomic_read(&dest->persistconns));
net/netfilter/ipvs/ip_vs_proto_tcp.c renamed from linux/net/netfilter/ipvs/ip_vs_proto_tcp.c +0 -0
diff -urp net-next-2.6-e548833-nfct/linux/net/netfilter/ipvs/ip_vs_proto_tcp.c linux/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -510,6 +510,15 @@ set_tcp_state(struct ip_vs_protocol *pp,
				atomic_dec(&dest->inactconns);
				cp->flags &= ~IP_VS_CONN_F_INACTIVE;
			}

+ if (new_state == IP_VS_TCP_S_SYN_RECV &&
+ !(cp->flags & IP_VS_CONN_F_BACKLOG)) {
+ atomic_inc(&dest->backlogconns);
+ cp->flags |= IP_VS_CONN_F_BACKLOG;
+ } else if (new_state == IP_VS_TCP_S_ESTABLISHED &&
+ cp->flags & IP_VS_CONN_F_BACKLOG) {
+ atomic_dec(&dest->backlogconns);
+ cp->flags &= ~IP_VS_CONN_F_BACKLOG;
+ }

		}
	}

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