summaryrefslogtreecommitdiff
path: root/python/vyos/qos/trafficshaper.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2023-01-04 17:55:06 +0100
committerChristian Poessinger <christian@poessinger.com>2023-01-04 17:55:48 +0100
commit5867d21077d605f1246459881addffa72ef538ff (patch)
tree1712bea1f5ffc897bce2e4cc3e434491ce24ac0d /python/vyos/qos/trafficshaper.py
parentae8935ce62e55ad047b51bebef8a1d9124ed1826 (diff)
downloadvyos-1x-5867d21077d605f1246459881addffa72ef538ff.tar.gz
vyos-1x-5867d21077d605f1246459881addffa72ef538ff.zip
qos: T4284: replace qdisc/class instead of always adding it
This makes transitions/updates faster and less error prone
Diffstat (limited to 'python/vyos/qos/trafficshaper.py')
-rw-r--r--python/vyos/qos/trafficshaper.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/python/vyos/qos/trafficshaper.py b/python/vyos/qos/trafficshaper.py
index 6d465b38e..f42f4d022 100644
--- a/python/vyos/qos/trafficshaper.py
+++ b/python/vyos/qos/trafficshaper.py
@@ -39,7 +39,6 @@ class TrafficShaper(QoSBase):
# need a bigger r2q if going fast than 16 mbits/sec
if (speed_bps // r2q) >= MAXQUANTUM: # integer division
r2q = ceil(speed_bps // MAXQUANTUM)
- print(r2q)
else:
# if there is a slow class then may need smaller value
if 'class' in config:
@@ -59,10 +58,10 @@ class TrafficShaper(QoSBase):
default_minor_id = int(class_id_max) +1
- tmp = f'tc qdisc add dev {self._interface} root handle {self._parent:x}: htb r2q {r2q} default {default_minor_id:x}' # default is in hex
+ tmp = f'tc qdisc replace dev {self._interface} root handle {self._parent:x}: htb r2q {r2q} default {default_minor_id:x}' # default is in hex
self._cmd(tmp)
- tmp = f'tc class add dev {self._interface} parent {self._parent:x}: classid {self._parent:x}:1 htb rate {speed}'
+ tmp = f'tc class replace dev {self._interface} parent {self._parent:x}: classid {self._parent:x}:1 htb rate {speed}'
self._cmd(tmp)
if 'class' in config:
@@ -75,23 +74,26 @@ class TrafficShaper(QoSBase):
burst = cls_config['burst']
quantum = cls_config['codel_quantum']
- tmp = f'tc class add dev {self._interface} parent {self._parent:x}:1 classid {self._parent:x}:{cls:x} htb rate {rate} burst {burst} quantum {quantum}'
+ tmp = f'tc class replace dev {self._interface} parent {self._parent:x}:1 classid {self._parent:x}:{cls:x} htb rate {rate} burst {burst} quantum {quantum}'
if 'priority' in cls_config:
priority = cls_config['priority']
tmp += f' prio {priority}'
self._cmd(tmp)
- tmp = f'tc qdisc add dev {self._interface} parent {self._parent:x}:{cls:x} sfq'
+ tmp = f'tc qdisc replace dev {self._interface} parent {self._parent:x}:{cls:x} sfq'
self._cmd(tmp)
if 'default' in config:
- tmp = f'tc class add dev {self._interface} parent {self._parent:x}:1 classid {self._parent:x}:{default_minor_id:x} htb rate {rate} burst {burst} quantum {quantum}'
+ rate = self._rate_convert(config['default']['bandwidth'])
+ burst = config['default']['burst']
+ quantum = config['default']['codel_quantum']
+ tmp = f'tc class replace dev {self._interface} parent {self._parent:x}:1 classid {self._parent:x}:{default_minor_id:x} htb rate {rate} burst {burst} quantum {quantum}'
if 'priority' in config['default']:
priority = config['default']['priority']
tmp += f' prio {priority}'
self._cmd(tmp)
- tmp = f'tc qdisc add dev {self._interface} parent {self._parent:x}:{default_minor_id:x} sfq'
+ tmp = f'tc qdisc replace dev {self._interface} parent {self._parent:x}:{default_minor_id:x} sfq'
self._cmd(tmp)
# call base class