]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: don't re-add the qdisc used for tx filters if it already exists
authorLaine Stump <laine@redhat.com>
Tue, 26 Nov 2024 03:24:47 +0000 (22:24 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 26 Nov 2024 13:36:14 +0000 (14:36 +0100)
commitf1d94bbfa6e5ae2564fb4e857aaeeaa722539b73
tree14bf5abf902efa398c678f5ecf0e326557a2ccbc
parent35a5bf25d125074356ee40881b5592e3b793f6b4
util: don't re-add the qdisc used for tx filters if it already exists

There will soon be two separate users of tc on virtual networks, and
both will use the "qdisc root handle 1: htb" to add tx filters. One or the
other could get the first chance to add the qdisc, and then if at a
later time the other decides to use it, we need to prevent the 2nd
user from attempting to re-add the qdisc (because that just generates
an error).

We do this by running "tc qdisc show dev $bridge handle 1:" then
checking if the output of that command contains both "qdisc" and " 1:
".[*] If it does then the qdisc has already been added. If not then we
need to add it now.

[*]As of this writing, the output more exactly starts with "qdisc
htb 1: root", but our comparison is made purposefully generous to
increase the chances that it will continue to work properly if tc
modifies the format of its output.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevbandwidth.c
tests/virnetdevbandwidthtest.c