Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T6373: QoS Policy Limiter - classes for marked traffic do not work (backport #3494) #3496

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions python/vyos/qos/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,15 @@ def update(self, config, direction, priority=None):
filter_cmd_base += ' protocol all'

if 'match' in cls_config:
is_filtered = False
has_filter = False
for index, (match, match_config) in enumerate(cls_config['match'].items(), start=1):
filter_cmd = filter_cmd_base
if not has_filter:
for key in ['mark', 'vif', 'ip', 'ipv6']:
if key in match_config:
has_filter = True
break

if self.qostype == 'shaper' and 'prio ' not in filter_cmd:
filter_cmd += f' prio {index}'
if 'mark' in match_config:
Expand Down Expand Up @@ -332,13 +338,12 @@ def update(self, config, direction, priority=None):
cls = int(cls)
filter_cmd += f' flowid {self._parent:x}:{cls:x}'
self._cmd(filter_cmd)
is_filtered = True

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 is_filtered:
and has_filter:
# For "vif" "basic match" is used instead of "action police" T5961
if not match_vlan:
filter_cmd += f' action police'
Expand Down
21 changes: 21 additions & 0 deletions smoketest/scripts/cli/test_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,27 @@ def test_13_shaper_delete_only_rule(self):
self.cli_commit()
self.assertEqual('', cmd(f'tc filter show dev {interface}'))

def test_14_policy_limiter_marked_traffic(self):
policy_name = 'smoke_test'
base_policy_path = ['qos', 'policy', 'limiter', policy_name]

self.cli_set(['qos', 'interface', self._interfaces[0], 'ingress', policy_name])
self.cli_set(base_policy_path + ['class', '100', 'bandwidth', '20gbit'])
self.cli_set(base_policy_path + ['class', '100', 'burst', '3760k'])
self.cli_set(base_policy_path + ['class', '100', 'match', 'INTERNAL', 'mark', '100'])
self.cli_set(base_policy_path + ['class', '100', 'priority', '20'])
self.cli_set(base_policy_path + ['default', 'bandwidth', '1gbit'])
self.cli_set(base_policy_path + ['default', 'burst', '125000000b'])
self.cli_commit()

tc_filters = cmd(f'tc filter show dev {self._interfaces[0]} ingress')
# class 100
self.assertIn('filter parent ffff: protocol all pref 20 fw chain 0', tc_filters)
self.assertIn('action order 1: police 0x1 rate 20Gbit burst 3847500b mtu 2Kb action drop overhead 0b', tc_filters)
# default
self.assertIn('filter parent ffff: protocol all pref 255 basic chain 0', tc_filters)
self.assertIn('action order 1: police 0x2 rate 1Gbit burst 125000000b mtu 2Kb action drop overhead 0b', tc_filters)


if __name__ == '__main__':
unittest.main(verbosity=2)
Loading