From patchwork Thu May 29 04:04:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 353638 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44CCF14007B for ; Thu, 29 May 2014 14:04:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932374AbaE2EEw (ORCPT ); Thu, 29 May 2014 00:04:52 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:16249 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932173AbaE2EEv (ORCPT ); Thu, 29 May 2014 00:04:51 -0400 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BUK08325; Thu, 29 May 2014 12:04:41 +0800 (CST) Received: from SZXEML454-HUB.china.huawei.com (10.82.67.197) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.3.158.1; Thu, 29 May 2014 12:04:40 +0800 Received: from [127.0.0.1] (10.177.18.231) by SZXEML454-HUB.china.huawei.com (10.82.67.197) with Microsoft SMTP Server id 14.3.158.1; Thu, 29 May 2014 12:04:35 +0800 Message-ID: <5386B1D2.3030804@huawei.com> Date: Thu, 29 May 2014 12:04:34 +0800 From: Yang Yingliang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Stephen Hemminger CC: Eric Dumazet , Subject: [PATCH iproute2 v4] fq: allow options of fair queue set to ~0U References: <1399868319-2184-1-git-send-email-yangyingliang@huawei.com> <1399874336.7973.17.camel@edumazet-glaptop2.roam.corp.google.com> <5370713F.7040701@huawei.com> <1399908225.7973.25.camel@edumazet-glaptop2.roam.corp.google.com> <53718221.6040909@huawei.com> <53719DA4.1010300@huawei.com> <20140528170957.19b50c12@nehalam.linuxnetplumber.net> In-Reply-To: <20140528170957.19b50c12@nehalam.linuxnetplumber.net> X-Originating-IP: [10.177.18.231] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yang Yingliang Some options of fair queue cannot be (~0U). It leads to maxrate cannot be reset to unlimited because it cannot be (~0U). Allow the options being ~0U. Tested by the following command: # tc qdisc add dev eth4 root handle 1: fq limit 2000 flow_limit 200 maxrate 100mbit quantum 2000 initial_quantum 1600 # tc -s -d qdisc show qdisc fq 1: dev eth4 root refcnt 2 limit 2000p flow_limit 200p buckets 1024 quantum 2000 initial_quantum 1600 maxrate 100Mbit Sent 1492 bytes 10 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 1 flows (0 inactive, 0 throttled) 0 gc, 0 highprio, 0 throttled # tc qdisc change dev eth4 root handle 1: fq limit 4294967295 flow_limit 4294967295 maxrate 34359738360 quantum 4294967295 initial_quantum 4294967295 # tc -s -d qdisc show qdisc fq 1: dev eth4 root refcnt 2 limit 4294967295p flow_limit 4294967295p buckets 1024 quantum 4294967295 initial_quantum 4294967295 Sent 38372 bytes 216 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 2 flows (1 inactive, 0 throttled) 0 gc, 2 highprio, 7 throttled Suggested-by: Eric Dumazet Signed-off-by: Yang Yingliang --- Change note: v3 -> v4: Change boolean flags from 'int' to 'bool'. --- tc/q_fq.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tc/q_fq.c b/tc/q_fq.c index c1f658e..e7288c2 100644 --- a/tc/q_fq.c +++ b/tc/q_fq.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "utils.h" #include "tc_util.h" @@ -71,13 +72,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; + bool set_plimit = false; + bool set_flow_plimit = false; + bool set_quantum = false; + bool set_initial_quantum = false; + bool set_maxrate = false; + bool set_defrate = false; int pacing = -1; struct rtattr *tail; @@ -88,12 +95,14 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv, fprintf(stderr, "Illegal \"limit\"\n"); return -1; } + set_plimit = true; } 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 = true; } else if (strcmp(*argv, "buckets") == 0) { NEXT_ARG(); if (get_unsigned(&buckets, *argv, 0)) { @@ -106,24 +115,28 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv, fprintf(stderr, "Illegal \"maxrate\"\n"); return -1; } + set_maxrate = true; } else if (strcmp(*argv, "defrate") == 0) { NEXT_ARG(); if (get_rate(&defrate, *argv)) { fprintf(stderr, "Illegal \"defrate\"\n"); return -1; } + set_defrate = true; } else if (strcmp(*argv, "quantum") == 0) { NEXT_ARG(); if (get_unsigned(&quantum, *argv, 0)) { fprintf(stderr, "Illegal \"quantum\"\n"); return -1; } + set_quantum = true; } 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 = true; } else if (strcmp(*argv, "pacing") == 0) { pacing = 1; } else if (strcmp(*argv, "nopacing") == 0) { @@ -147,24 +160,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;