summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaige Fu <fukaige@huawei.com>2017-11-02 11:07:02 +0800
committerBen Pfaff <blp@ovn.org>2017-11-02 11:33:15 -0700
commita7c8533a9bcdf5bfee9c13ba391117897034329f (patch)
tree623ba6ad17ea92040e19b4e75ff2914081a84f90
parent2000b35f0920eead601a7e178bb82c713d1e57ef (diff)
downloadopenvswitch-a7c8533a9bcdf5bfee9c13ba391117897034329f.tar.gz
netdev-linux: Fix wrong ceil rate when max-rate less than 8bit.
When max-rate is less than 8bit, the hc->max_rate will be set as htb->max_rate mistakenly instead of mtu of netdev. Fixes: 13c1637 ("smap: New function smap_get_ullong().") Signed-off-by: Kaige Fu <fukaige@huawei.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/netdev-linux.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index fccf88ff6..260872d4b 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -3720,6 +3720,7 @@ htb_parse_class_details__(struct netdev *netdev,
{
const struct htb *htb = htb_get__(netdev);
int mtu, error;
+ unsigned long long int max_rate_bit;
error = netdev_linux_get_mtu__(netdev_linux_cast(netdev), &mtu);
if (error) {
@@ -3735,10 +3736,8 @@ htb_parse_class_details__(struct netdev *netdev,
hc->min_rate = MIN(hc->min_rate, htb->max_rate);
/* max-rate */
- hc->max_rate = smap_get_ullong(details, "max-rate", 0) / 8;
- if (!hc->max_rate) {
- hc->max_rate = htb->max_rate;
- }
+ max_rate_bit = smap_get_ullong(details, "max-rate", 0);
+ hc->max_rate = max_rate_bit ? max_rate_bit / 8 : htb->max_rate;
hc->max_rate = MAX(hc->max_rate, hc->min_rate);
hc->max_rate = MIN(hc->max_rate, htb->max_rate);