All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: Eric Dumazet <eric.dumazet@gmail.com>, <stephen@networkplumber.org>
Cc: <netdev@vger.kernel.org>
Subject: [PATCH iproute2 v2] fq: allow options of fair queue set to ~0U
Date: Tue, 13 May 2014 10:23:29 +0800	[thread overview]
Message-ID: <53718221.6040909@huawei.com> (raw)
In-Reply-To: <1399908225.7973.25.camel@edumazet-glaptop2.roam.corp.google.com>

From: Yang Yingliang <yangyingliang@huawei.com>

Some options of fair queue cannot be (~0U). It leads to maxrate
cannot be reset to unlimited because it cannot be (~0U).

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 tc/q_fq.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/tc/q_fq.c b/tc/q_fq.c
index c1f658e..6a493a5 100644
--- a/tc/q_fq.c
+++ b/tc/q_fq.c
@@ -71,13 +71,19 @@ static unsigned int ilog2(unsigned int val)
 static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 			struct nlmsghdr *n)
 {
-	unsigned int plimit = ~0U;
-	unsigned int flow_plimit = ~0U;
-	unsigned int quantum = ~0U;
-	unsigned int initial_quantum = ~0U;
+	unsigned int plimit;
+	unsigned int flow_plimit;
+	unsigned int quantum;
+	unsigned int initial_quantum;
 	unsigned int buckets = 0;
-	unsigned int maxrate = ~0U;
-	unsigned int defrate = ~0U;
+	unsigned int maxrate;
+	unsigned int defrate;
+	int set_plimit = 0;
+	int set_flow_plimit = 0;
+	int set_quantum = 0;
+	int set_initial_quantum = 0;
+	int set_maxrate = 0;
+	int set_defrate = 0;
 	int pacing = -1;
 	struct rtattr *tail;
 
@@ -88,12 +94,14 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 				fprintf(stderr, "Illegal \"limit\"\n");
 				return -1;
 			}
+			set_plimit = 1;
 		} else if (strcmp(*argv, "flow_limit") == 0) {
 			NEXT_ARG();
 			if (get_unsigned(&flow_plimit, *argv, 0)) {
 				fprintf(stderr, "Illegal \"flow_limit\"\n");
 				return -1;
 			}
+			set_flow_plimit = 0;
 		} else if (strcmp(*argv, "buckets") == 0) {
 			NEXT_ARG();
 			if (get_unsigned(&buckets, *argv, 0)) {
@@ -106,24 +114,28 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 				fprintf(stderr, "Illegal \"maxrate\"\n");
 				return -1;
 			}
+			set_maxrate = 1;
 		} else if (strcmp(*argv, "defrate") == 0) {
 			NEXT_ARG();
 			if (get_rate(&defrate, *argv)) {
 				fprintf(stderr, "Illegal \"defrate\"\n");
 				return -1;
 			}
+			set_defrate = 1;
 		} else if (strcmp(*argv, "quantum") == 0) {
 			NEXT_ARG();
 			if (get_unsigned(&quantum, *argv, 0)) {
 				fprintf(stderr, "Illegal \"quantum\"\n");
 				return -1;
 			}
+			set_quantum = 1;
 		} else if (strcmp(*argv, "initial_quantum") == 0) {
 			NEXT_ARG();
 			if (get_unsigned(&initial_quantum, *argv, 0)) {
 				fprintf(stderr, "Illegal \"initial_quantum\"\n");
 				return -1;
 			}
+			set_initial_quantum = 1;
 		} else if (strcmp(*argv, "pacing") == 0) {
 			pacing = 1;
 		} else if (strcmp(*argv, "nopacing") == 0) {
@@ -147,24 +159,24 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 		addattr_l(n, 1024, TCA_FQ_BUCKETS_LOG,
 			  &log, sizeof(log));
 	}
-	if (plimit != ~0U)
+	if (set_plimit)
 		addattr_l(n, 1024, TCA_FQ_PLIMIT,
 			  &plimit, sizeof(plimit));
-	if (flow_plimit != ~0U)
+	if (set_flow_plimit)
 		addattr_l(n, 1024, TCA_FQ_FLOW_PLIMIT,
 			  &flow_plimit, sizeof(flow_plimit));
-	if (quantum != ~0U)
+	if (set_quantum)
 		addattr_l(n, 1024, TCA_FQ_QUANTUM, &quantum, sizeof(quantum));
-	if (initial_quantum != ~0U)
+	if (set_initial_quantum)
 		addattr_l(n, 1024, TCA_FQ_INITIAL_QUANTUM,
 			  &initial_quantum, sizeof(initial_quantum));
 	if (pacing != -1)
 		addattr_l(n, 1024, TCA_FQ_RATE_ENABLE,
 			  &pacing, sizeof(pacing));
-	if (maxrate != ~0U)
+	if (set_maxrate)
 		addattr_l(n, 1024, TCA_FQ_FLOW_MAX_RATE,
 			  &maxrate, sizeof(maxrate));
-	if (defrate != ~0U)
+	if (set_defrate)
 		addattr_l(n, 1024, TCA_FQ_FLOW_DEFAULT_RATE,
 			  &defrate, sizeof(defrate));
 	tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;

  reply	other threads:[~2014-05-13  2:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12  4:18 [PATCH iproute2] fq: don't allow set options to zero Yang Yingliang
2014-05-12  5:58 ` Eric Dumazet
2014-05-12  6:51   ` Yang Yingliang
2014-05-12  6:55     ` Yang Yingliang
2014-05-12  6:59   ` Yang Yingliang
2014-05-12 15:23     ` Eric Dumazet
2014-05-13  2:23       ` Yang Yingliang [this message]
2014-05-13  3:03         ` [PATCH iproute2 v2] fq: allow options of fair queue set to ~0U Eric Dumazet
2014-05-13  4:10           ` Yang Yingliang
2014-05-13  4:20         ` [PATCH iproute2 v3] " Yang Yingliang
2014-05-29  0:09           ` Stephen Hemminger
2014-05-29  2:43             ` Yang Yingliang
2014-05-29  4:04             ` [PATCH iproute2 v4] " Yang Yingliang
2014-06-09 19:43               ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53718221.6040909@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.