From 2e8fa45c7f0663549edd118622b3381e7c428b2e Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Fri, 9 Feb 2024 10:51:00 +0000 Subject: T6028: Fix QoS policy shaper wrong class_id_max and default_minor_id The `class_id_max` is wrong due to `tmp.sort` of Strings If we have class 5 and class 10 we get sorted max value 5, expected 10 ``` >>> tmp = ['5', '10'] >>> tmp.sort() >>> tmp ['10', '5'] >>> >>> hex(5+1) '0x6' >>> >>> hex(10+1) '0xb' >>> ``` This way we get wrong default maximum class value: ``` tc qdisc replace dev eth1 root handle 1: htb r2q 444 default 6 ``` Expect: ``` tc qdisc replace dev eth1 root handle 1: htb r2q 444 default b ``` Fix this converting Strings to Integers and get max value. --- python/vyos/qos/trafficshaper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/vyos/qos/trafficshaper.py b/python/vyos/qos/trafficshaper.py index 7d580baa2..8b0333c21 100644 --- a/python/vyos/qos/trafficshaper.py +++ b/python/vyos/qos/trafficshaper.py @@ -29,8 +29,9 @@ class TrafficShaper(QoSBase): class_id_max = 0 if 'class' in config: tmp = list(config['class']) - tmp.sort() - class_id_max = tmp[-1] + # Convert strings to integers + tmp = [int(x) for x in tmp] + class_id_max = max(tmp) r2q = 10 # bandwidth is a mandatory CLI node -- cgit v1.2.3