From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH iproute2] tc: allow 0% for percent options Date: Thu, 17 May 2018 16:29:21 -0700 Message-ID: <20180517232921.5648-1-stephen@networkplumber.org> Cc: Stephen Hemminger To: netdev@vger.kernel.org Return-path: Received: from mail-pf0-f194.google.com ([209.85.192.194]:42027 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752356AbeEQX3Y (ORCPT ); Thu, 17 May 2018 19:29:24 -0400 Received: by mail-pf0-f194.google.com with SMTP id p14-v6so2811792pfh.9 for ; Thu, 17 May 2018 16:29:24 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: Allowing 0% is sometimes useful for example in netem loss and drop or perhaps dropping all traffic in a HTB bin. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199745 Reported-by: stuartmarsden@gmail.com Fixes: 927e3cfb52b5 ("tc: B.W limits can now be specified in %.") Signed-off-by: Stephen Hemminger --- lib/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.c b/lib/utils.c index 7b2c6dd19268..02ce67721915 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -105,7 +105,7 @@ int parse_percent(double *val, const char *str) *val = strtod(str, &p) / 100.; if (*val == HUGE_VALF || *val == HUGE_VALL) return 1; - if (*val == 0.0 || (*p && strcmp(p, "%"))) + if (*p && strcmp(p, "%")) return -1; return 0; -- 2.17.0