Skip to content

Commit

Permalink
netdev-linux: Fix wrong ceil rate when max-rate less than 8bit.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fukaige authored and blp committed Nov 2, 2017
1 parent 274cd1f commit 214117f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/netdev-linux.c
Expand Up @@ -3762,6 +3762,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) {
Expand All @@ -3777,10 +3778,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);

Expand Down

0 comments on commit 214117f

Please sign in to comment.