Blame SOURCES/iproute2-3.10.0-fq-allow-options-of-fair-queue-set-to-0U.patch

a4b897
From 2adc0d473370b683726e2ea019c6d1cc302823ce Mon Sep 17 00:00:00 2001
a4b897
From: Yang Yingliang <yangyingliang@huawei.com>
a4b897
Date: Thu, 29 May 2014 12:04:34 +0800
a4b897
Subject: [PATCH 2/2] fq: allow options of fair queue set to ~0U
a4b897
a4b897
Some options of fair queue cannot be (~0U). It leads to maxrate
a4b897
cannot be reset to unlimited because it cannot be (~0U). Allow
a4b897
the options being ~0U.
a4b897
a4b897
Tested by the following command:
a4b897
 # tc qdisc add dev eth4 root handle 1: fq limit 2000 flow_limit 200 maxrate 100mbit quantum 2000 initial_quantum 1600
a4b897
 # tc -s -d qdisc show
a4b897
qdisc fq 1: dev eth4 root refcnt 2 limit 2000p flow_limit 200p buckets 1024 quantum 2000 initial_quantum 1600 maxrate 100Mbit
a4b897
 Sent 1492 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
a4b897
 backlog 0b 0p requeues 0
a4b897
  1 flows (0 inactive, 0 throttled)
a4b897
  0 gc, 0 highprio, 0 throttled
a4b897
a4b897
 # tc qdisc change dev eth4 root handle 1: fq limit 4294967295 flow_limit 4294967295 maxrate 34359738360 quantum 4294967295 initial_quantum 4294967295
a4b897
 # tc -s -d qdisc show
a4b897
qdisc fq 1: dev eth4 root refcnt 2 limit 4294967295p flow_limit 4294967295p buckets 1024 quantum 4294967295 initial_quantum 4294967295
a4b897
 Sent 38372 bytes 216 pkt (dropped 0, overlimits 0 requeues 0)
a4b897
 backlog 0b 0p requeues 0
a4b897
  2 flows (1 inactive, 0 throttled)
a4b897
  0 gc, 2 highprio, 7 throttled
a4b897
a4b897
Suggested-by: Eric Dumazet <edumazet@google.com>
a4b897
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
a4b897
---
a4b897
 tc/q_fq.c | 37 +++++++++++++++++++++++++------------
a4b897
 1 file changed, 25 insertions(+), 12 deletions(-)
a4b897
a4b897
diff --git a/tc/q_fq.c b/tc/q_fq.c
a4b897
index c1f658e..e7288c2 100644
a4b897
--- a/tc/q_fq.c
a4b897
+++ b/tc/q_fq.c
a4b897
@@ -44,6 +44,7 @@
a4b897
 #include <netinet/in.h>
a4b897
 #include <arpa/inet.h>
a4b897
 #include <string.h>
a4b897
+#include <stdbool.h>
a4b897
 
a4b897
 #include "utils.h"
a4b897
 #include "tc_util.h"
a4b897
@@ -71,13 +72,19 @@ static unsigned int ilog2(unsigned int val)
a4b897
 static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
a4b897
 			struct nlmsghdr *n)
a4b897
 {
a4b897
-	unsigned int plimit = ~0U;
a4b897
-	unsigned int flow_plimit = ~0U;
a4b897
-	unsigned int quantum = ~0U;
a4b897
-	unsigned int initial_quantum = ~0U;
a4b897
+	unsigned int plimit;
a4b897
+	unsigned int flow_plimit;
a4b897
+	unsigned int quantum;
a4b897
+	unsigned int initial_quantum;
a4b897
 	unsigned int buckets = 0;
a4b897
-	unsigned int maxrate = ~0U;
a4b897
-	unsigned int defrate = ~0U;
a4b897
+	unsigned int maxrate;
a4b897
+	unsigned int defrate;
a4b897
+	bool set_plimit = false;
a4b897
+	bool set_flow_plimit = false;
a4b897
+	bool set_quantum = false;
a4b897
+	bool set_initial_quantum = false;
a4b897
+	bool set_maxrate = false;
a4b897
+	bool set_defrate = false;
a4b897
 	int pacing = -1;
a4b897
 	struct rtattr *tail;
a4b897
 
a4b897
@@ -88,12 +95,14 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
a4b897
 				fprintf(stderr, "Illegal \"limit\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_plimit = true;
a4b897
 		} else if (strcmp(*argv, "flow_limit") == 0) {
a4b897
 			NEXT_ARG();
a4b897
 			if (get_unsigned(&flow_plimit, *argv, 0)) {
a4b897
 				fprintf(stderr, "Illegal \"flow_limit\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_flow_plimit = true;
a4b897
 		} else if (strcmp(*argv, "buckets") == 0) {
a4b897
 			NEXT_ARG();
a4b897
 			if (get_unsigned(&buckets, *argv, 0)) {
a4b897
@@ -106,24 +115,28 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
a4b897
 				fprintf(stderr, "Illegal \"maxrate\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_maxrate = true;
a4b897
 		} else if (strcmp(*argv, "defrate") == 0) {
a4b897
 			NEXT_ARG();
a4b897
 			if (get_rate(&defrate, *argv)) {
a4b897
 				fprintf(stderr, "Illegal \"defrate\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_defrate = true;
a4b897
 		} else if (strcmp(*argv, "quantum") == 0) {
a4b897
 			NEXT_ARG();
a4b897
 			if (get_unsigned(&quantum, *argv, 0)) {
a4b897
 				fprintf(stderr, "Illegal \"quantum\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_quantum = true;
a4b897
 		} else if (strcmp(*argv, "initial_quantum") == 0) {
a4b897
 			NEXT_ARG();
a4b897
 			if (get_unsigned(&initial_quantum, *argv, 0)) {
a4b897
 				fprintf(stderr, "Illegal \"initial_quantum\"\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
+			set_initial_quantum = true;
a4b897
 		} else if (strcmp(*argv, "pacing") == 0) {
a4b897
 			pacing = 1;
a4b897
 		} else if (strcmp(*argv, "nopacing") == 0) {
a4b897
@@ -147,24 +160,24 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
a4b897
 		addattr_l(n, 1024, TCA_FQ_BUCKETS_LOG,
a4b897
 			  &log, sizeof(log));
a4b897
 	}
a4b897
-	if (plimit != ~0U)
a4b897
+	if (set_plimit)
a4b897
 		addattr_l(n, 1024, TCA_FQ_PLIMIT,
a4b897
 			  &plimit, sizeof(plimit));
a4b897
-	if (flow_plimit != ~0U)
a4b897
+	if (set_flow_plimit)
a4b897
 		addattr_l(n, 1024, TCA_FQ_FLOW_PLIMIT,
a4b897
 			  &flow_plimit, sizeof(flow_plimit));
a4b897
-	if (quantum != ~0U)
a4b897
+	if (set_quantum)
a4b897
 		addattr_l(n, 1024, TCA_FQ_QUANTUM, &quantum, sizeof(quantum));
a4b897
-	if (initial_quantum != ~0U)
a4b897
+	if (set_initial_quantum)
a4b897
 		addattr_l(n, 1024, TCA_FQ_INITIAL_QUANTUM,
a4b897
 			  &initial_quantum, sizeof(initial_quantum));
a4b897
 	if (pacing != -1)
a4b897
 		addattr_l(n, 1024, TCA_FQ_RATE_ENABLE,
a4b897
 			  &pacing, sizeof(pacing));
a4b897
-	if (maxrate != ~0U)
a4b897
+	if (set_maxrate)
a4b897
 		addattr_l(n, 1024, TCA_FQ_FLOW_MAX_RATE,
a4b897
 			  &maxrate, sizeof(maxrate));
a4b897
-	if (defrate != ~0U)
a4b897
+	if (set_defrate)
a4b897
 		addattr_l(n, 1024, TCA_FQ_FLOW_DEFAULT_RATE,
a4b897
 			  &defrate, sizeof(defrate));
a4b897
 	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
a4b897
-- 
a4b897
1.8.3.1
a4b897