lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190206180913.19381-1-marcos.antonio@digirati.com.br>
Date:   Wed,  6 Feb 2019 16:09:13 -0200
From:   Marcos Antonio Moraes <marcos.antonio@...irati.com.br>
To:     netdev@...r.kernel.org
Cc:     Marcos Antonio Moraes <marcos.antonio@...irati.com.br>
Subject: [PATCH] Using rates in bits when limits are specified in %

As /sys/class/net/<iface>/speed indicates a value in Mbits/sec, the
transformation is necessary to create the correct limitations.
---
 tc/tc_util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tc/tc_util.c b/tc/tc_util.c
index ab717890..b82142ab 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -194,7 +194,7 @@ static int parse_percent_rate(char *rate, const char *str, const char *dev)
 {
 	long dev_mbit;
 	int ret;
-	double perc, rate_mbit;
+	double perc, rate_bit;
 	char *str_perc;
 
 	if (!dev[0]) {
@@ -219,9 +219,9 @@ static int parse_percent_rate(char *rate, const char *str, const char *dev)
 		return -1;
 	}
 
-	rate_mbit = perc * dev_mbit;
+	rate_bit = perc * dev_mbit * 1000 * 1000;
 
-	ret = snprintf(rate, 20, "%lf", rate_mbit);
+	ret = snprintf(rate, 20, "%lf", rate_bit);
 	if (ret <= 0 || ret >= 20) {
 		fprintf(stderr, "Unable to parse calculated rate\n");
 		return -1;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ