diff options
author | khramshinr <khramshinr@gmail.com> | 2024-11-14 10:25:38 +0800 |
---|---|---|
committer | khramshinr <khramshinr@gmail.com> | 2024-11-14 10:50:03 +0800 |
commit | e6558a535594c1cd25133979f07663cf6958ce75 (patch) | |
tree | 9979074b1a761ae892657c5b593958d397d91fc9 | |
parent | d51765cac49dd1d3b2d489387cd35d41e8b45b3d (diff) | |
download | vyos-1x-e6558a535594c1cd25133979f07663cf6958ce75.tar.gz vyos-1x-e6558a535594c1cd25133979f07663cf6958ce75.zip |
T6801: QoS: Policy rate-control is broken by default
- Fixed unhandled exception for policy rate-control without params
-rwxr-xr-x | smoketest/scripts/cli/test_qos.py | 21 | ||||
-rwxr-xr-x | src/conf_mode/qos.py | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_qos.py b/smoketest/scripts/cli/test_qos.py index 77d384024..aaeebcdae 100755 --- a/smoketest/scripts/cli/test_qos.py +++ b/smoketest/scripts/cli/test_qos.py @@ -922,6 +922,27 @@ class TestQoS(VyOSUnitTestSHIM.TestCase): tmp[2]['options'], ) + def test_22_rate_control_default(self): + interface = self._interfaces[0] + policy_name = f'qos-policy-{interface}' + bandwidth = 5000 + + self.cli_set(base_path + ['interface', interface, 'egress', policy_name]) + self.cli_set(base_path + ['policy', 'rate-control', policy_name]) + with self.assertRaises(ConfigSessionError): + # Bandwidth not defined + self.cli_commit() + + self.cli_set(base_path + ['policy', 'rate-control', policy_name, 'bandwidth', str(bandwidth)]) + # commit changes + self.cli_commit() + + tmp = get_tc_qdisc_json(interface) + + self.assertEqual('tbf', tmp['kind']) + # TC store rates as a 32-bit unsigned integer in bps (Bytes per second) + self.assertEqual(int(bandwidth * 125), tmp['options']['rate']) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py index 7dfad3180..a4d5f44e7 100755 --- a/src/conf_mode/qos.py +++ b/src/conf_mode/qos.py @@ -255,6 +255,9 @@ def verify(qos): if policy_type in ['priority_queue']: if 'default' not in policy_config: raise ConfigError(f'Policy {policy} misses "default" class!') + if policy_type in ['rate_control']: + if 'bandwidth' not in policy_config: + raise ConfigError('Bandwidth not defined') if 'default' in policy_config: if 'bandwidth' not in policy_config['default'] and policy_type not in ['priority_queue', 'round_robin', 'shaper_hfsc']: raise ConfigError('Bandwidth not defined for default traffic!') |