iproute/0007-tc-allow-0-for-percent-options.patch

35 lines
1.1 KiB
Diff
Raw Normal View History

From 011d598dc86ad94c0560e1eb7921546daf4f81eb Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu, 17 May 2018 16:20:50 -0700
Subject: [PATCH] tc: allow 0% for percent options
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 <stephen@networkplumber.org>
(cherry picked from commit 405e0c4ffe7a410b09201db42955089fb0033776)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
lib/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils.c b/lib/utils.c
index 7d3fe9c91d3df..44ba237e63557 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -103,7 +103,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