diff options
author | khramshinr <khramshinr@gmail.com> | 2024-11-13 13:33:08 +0800 |
---|---|---|
committer | khramshinr <khramshinr@gmail.com> | 2024-11-13 13:33:08 +0800 |
commit | 3fae9e812c21508e12e88b69697cbeb73c19720e (patch) | |
tree | 12158818365e944ac60031f951a2c23fb2e78609 | |
parent | c6a097ee7d9b6d2f4c4b8ee63ca45ccfb6fdda34 (diff) | |
download | vyos-1x-3fae9e812c21508e12e88b69697cbeb73c19720e.tar.gz vyos-1x-3fae9e812c21508e12e88b69697cbeb73c19720e.zip |
T6795: Fix duplicate entries in class match filters
-rw-r--r-- | python/vyos/qos/base.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index 98e486e42..322cdca44 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -248,6 +248,8 @@ class QoSBase: if 'match' in cls_config: has_filter = False + has_action_policy = any(tmp in ['exceed', 'bandwidth', 'burst'] for tmp in cls_config) + max_index = len(cls_config['match']) for index, (match, match_config) in enumerate(cls_config['match'].items(), start=1): filter_cmd = filter_cmd_base if not has_filter: @@ -335,15 +337,16 @@ class QoSBase: elif af == 'ipv6': filter_cmd += f' match u8 {mask} {mask} at 53' - cls = int(cls) - filter_cmd += f' flowid {self._parent:x}:{cls:x}' - self._cmd(filter_cmd) + if index != max_index or not has_action_policy: + # avoid duplicate last match rule + cls = int(cls) + filter_cmd += f' flowid {self._parent:x}:{cls:x}' + self._cmd(filter_cmd) vlan_expression = "match.*.vif" match_vlan = jmespath.search(vlan_expression, cls_config) - if any(tmp in ['exceed', 'bandwidth', 'burst'] for tmp in cls_config) \ - and has_filter: + if has_action_policy and has_filter: # For "vif" "basic match" is used instead of "action police" T5961 if not match_vlan: filter_cmd += f' action police' |