From a7f757874af0657709934db48a1e8239e4f31b74 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Fri, 25 Jan 2013 20:13:55 +0100 Subject: [PATCH] linux: Increase accuracy of ingress_policing_rate at low rates The current method of calculating the ingress policer rate can lead to inaccuracy if ingress_policing_rate is set to a smallish values because the rate is divided by 8 first which causes rounding errors. Signed-off-by: Thomas Graf Signed-off-by: Ben Pfaff --- lib/netdev-linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 412a92deb..1fac087df 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -3693,7 +3693,7 @@ tc_add_policer(struct netdev *netdev, int kbits_rate, int kbits_burst) memset(&tc_police, 0, sizeof tc_police); tc_police.action = TC_POLICE_SHOT; tc_police.mtu = mtu; - tc_fill_rate(&tc_police.rate, kbits_rate/8 * 1000, mtu); + tc_fill_rate(&tc_police.rate, (kbits_rate * 1000)/8, mtu); tc_police.burst = tc_bytes_to_ticks(tc_police.rate.rate, kbits_burst * 1024); -- 2.20.1