Skip to contentSkip to conversation

: Set TX Queue Length Bounds via Sysctl

PATCH In review Arnaldo Carvalho de Melo 1 participant 1 message Nov 20, 2006 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 4/9 : Set TX Queue Length Bounds via Sysctl

Previously the transmit queue was unbounded.

This patch:
* puts a limit on transmit queue length and sends back EAGAIN if the buffer is full
* sets the TX queue length to a sensible default
* implements tx buffer sysctls for DCCP

---
 net/dccp/dccp.h  |    1 +
 net/dccp/proto.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
net/dccp/dccp.h +1 -0
index 33d86f5..3a94625 100644
@@ -87,6 +87,7 @@ extern int  sysctl_dccp_feat_tx_ccid;
 extern int  sysctl_dccp_feat_ack_ratio;
 extern int  sysctl_dccp_feat_send_ack_vector;
 extern int  sysctl_dccp_feat_send_ndp_count;
+extern int  sysctl_dccp_tx_qlen;
 
 /* is seq1 < seq2 ? */
 static inline int before48(const u64 seq1, const u64 seq2)
net/dccp/proto.c +10 -0
index 0225bda..a7f345c 100644
@@ -52,6 +52,9 @@ struct inet_hashinfo __cacheline_aligned
 
 EXPORT_SYMBOL_GPL(dccp_hashinfo);
 
+/* the maximum queue length for tx in packets. 0 is no limit */
+int sysctl_dccp_tx_qlen __read_mostly = 5;
+
 void dccp_set_state(struct sock *sk, const int state)
 {
 	const int oldstate = sk->sk_state;
@@ -645,6 +648,13 @@ int dccp_sendmsg(struct kiocb *iocb, str
 		return -EMSGSIZE;
 
 	lock_sock(sk);
+
+	if (sysctl_dccp_tx_qlen &&
+	    (sk->sk_write_queue.qlen >= sysctl_dccp_tx_qlen)) {
+		rc = -EAGAIN;
+		goto out_release;
+	}
+
 	timeo = sock_sndtimeo(sk, noblock);
 
 	/*
Signature · 1 line
1.4.2.1.g3d5c