diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 612e8f985c..77a97176b0 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -358,7 +358,17 @@ virNetDevBandwidthSet(const char *ifname, if (rx) { average = g_strdup_printf("%llukbps", rx->average); - burst = g_strdup_printf("%llukb", rx->burst ? rx->burst : rx->average); + + if (rx->burst) { + burst = g_strdup_printf("%llukb", rx->burst); + } else { + /* Internally, tc uses uint to store burst size (in bytes). + * Therefore, the largest value we can set is UINT_MAX bytes. + * We're outputting the vale in KiB though. */ + unsigned long long avg = MIN(rx->average, UINT_MAX / 1024); + + burst = g_strdup_printf("%llukb", avg); + } virCommandFree(cmd); cmd = virCommandNew(TC); diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 6d0443876c..6f3cab27be 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -156,6 +156,21 @@ mymain(void) TC " filter add dev eth0 parent ffff: protocol all u32 match u32 0 0 " "police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n")); + DO_TEST_SET(("" + " " + " " + ""), + (TC " qdisc del dev eth0 root\n" + TC " qdisc del dev eth0 ingress\n" + TC " qdisc add dev eth0 root handle 1: htb default 1\n" + TC " class add dev eth0 parent 1: classid 1:1 htb rate 4294967295kbps quantum 366503875\n" + TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n" + TC " filter add dev eth0 parent 1:0 protocol all prio 1 handle 1 fw flowid 1\n" + TC " qdisc add dev eth0 ingress\n" + TC " filter add dev eth0 parent ffff: protocol all u32 match " + "u32 0 0 police rate 4294967295kbps burst 4194303kb mtu 64kb " + "drop flowid :1\n")); + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }