diff options
| -rw-r--r-- | data/templates/dhcp-server/kea-dhcp4.conf.j2 | 4 | ||||
| -rw-r--r-- | interface-definitions/include/version/system-version.xml.i | 2 | ||||
| -rw-r--r-- | interface-definitions/system_option.xml.in | 21 | ||||
| -rw-r--r-- | python/vyos/qos/roundrobin.py | 13 | ||||
| -rw-r--r-- | smoketest/config-tests/dialup-router-wireguard-ipv6 | 2 | ||||
| -rw-r--r-- | smoketest/configs/dialup-router-wireguard-ipv6 | 2 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_qos.py | 82 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_system_option.py | 10 | ||||
| -rwxr-xr-x | src/conf_mode/system_option.py | 12 | ||||
| -rw-r--r-- | src/migration-scripts/system/27-to-28 | 33 |
10 files changed, 159 insertions, 22 deletions
diff --git a/data/templates/dhcp-server/kea-dhcp4.conf.j2 b/data/templates/dhcp-server/kea-dhcp4.conf.j2 index bf37b94f6..29cf5e082 100644 --- a/data/templates/dhcp-server/kea-dhcp4.conf.j2 +++ b/data/templates/dhcp-server/kea-dhcp4.conf.j2 @@ -29,14 +29,14 @@ "code": 121, "type": "record", "array": true, - "record-types": "uint8,uint8,uint8,uint8,uint8,uint8,uint8,uint8" + "record-types": "uint8,uint8,uint8,uint8,uint8,uint8,uint8" }, { "name": "windows-static-route", "code": 249, "type": "record", "array": true, - "record-types": "uint8,uint8,uint8,uint8,uint8,uint8,uint8,uint8" + "record-types": "uint8,uint8,uint8,uint8,uint8,uint8,uint8" }, { "name": "wpad-url", diff --git a/interface-definitions/include/version/system-version.xml.i b/interface-definitions/include/version/system-version.xml.i index fcb24abe2..3ecf124c7 100644 --- a/interface-definitions/include/version/system-version.xml.i +++ b/interface-definitions/include/version/system-version.xml.i @@ -1,3 +1,3 @@ <!-- include start from include/version/system-version.xml.i --> -<syntaxVersion component='system' version='27'></syntaxVersion> +<syntaxVersion component='system' version='28'></syntaxVersion> <!-- include end --> diff --git a/interface-definitions/system_option.xml.in b/interface-definitions/system_option.xml.in index 064d9ff40..638ac1a3d 100644 --- a/interface-definitions/system_option.xml.in +++ b/interface-definitions/system_option.xml.in @@ -149,19 +149,32 @@ <properties> <help>Tune system performance</help> <completionHelp> - <list>throughput latency</list> + <list>network-throughput network-latency power-save virtual-host virtual-guest</list> </completionHelp> <valueHelp> - <format>throughput</format> + <format>network-throughput</format> <description>Tune for maximum network throughput</description> </valueHelp> <valueHelp> - <format>latency</format> + <format>network-latency</format> <description>Tune for low network latency</description> </valueHelp> + <valueHelp> + <format>power-save</format> + <description>Tune for low power consumption</description> + </valueHelp> + <valueHelp> + <format>virtual-guest</format> + <description>Tune for running inside a virtual machine</description> + </valueHelp> + <valueHelp> + <format>virtual-host</format> + <description>Tune for running guest virtual machines</description> + </valueHelp> <constraint> - <regex>(throughput|latency)</regex> + <regex>(network-throughput|network-latency|power-save|virtual-guest|virtual-host)</regex> </constraint> + <multi/> </properties> </leafNode> <node name="http-client"> diff --git a/python/vyos/qos/roundrobin.py b/python/vyos/qos/roundrobin.py index 80814ddfb..509c4069f 100644 --- a/python/vyos/qos/roundrobin.py +++ b/python/vyos/qos/roundrobin.py @@ -15,6 +15,7 @@ from vyos.qos.base import QoSBase + class RoundRobin(QoSBase): _parent = 1 @@ -34,11 +35,21 @@ class RoundRobin(QoSBase): if 'default' in config: class_id_max = self._get_class_max_id(config) - default_cls_id = int(class_id_max) +1 + default_cls_id = int(class_id_max) + 1 if class_id_max else 1 # class ID via CLI is in range 1-4095, thus 1000 hex = 4096 tmp = f'tc class replace dev {self._interface} parent 1:1 classid 1:{default_cls_id:x} drr' self._cmd(tmp) + # You need to add at least one filter to classify packets + # otherwise, all packets will be dropped. + filter_cmd = ( + f'tc filter replace dev {self._interface} ' + f'parent {self._parent:x}: prio {default_cls_id} protocol all ' + 'u32 match u32 0 0 ' + f'flowid {self._parent}:{default_cls_id}' + ) + self._cmd(filter_cmd) + # call base class super().update(config, direction, priority=True) diff --git a/smoketest/config-tests/dialup-router-wireguard-ipv6 b/smoketest/config-tests/dialup-router-wireguard-ipv6 index ff4bf89c2..c2cf2e9d8 100644 --- a/smoketest/config-tests/dialup-router-wireguard-ipv6 +++ b/smoketest/config-tests/dialup-router-wireguard-ipv6 @@ -688,7 +688,7 @@ set system login user vyos authentication encrypted-password '$6$2Ta6TWHd/U$NmrX set system login user vyos authentication plaintext-password '' set system name-server '172.16.254.30' set system option ctrl-alt-delete 'ignore' -set system option performance 'latency' +set system option performance 'network-latency' set system option reboot-on-panic set system option startup-beep set system syslog global facility all level 'debug' diff --git a/smoketest/configs/dialup-router-wireguard-ipv6 b/smoketest/configs/dialup-router-wireguard-ipv6 index 058582148..767606341 100644 --- a/smoketest/configs/dialup-router-wireguard-ipv6 +++ b/smoketest/configs/dialup-router-wireguard-ipv6 @@ -1470,7 +1470,7 @@ system { } option { ctrl-alt-delete ignore - performance latency + performance network-latency reboot-on-panic startup-beep } diff --git a/smoketest/scripts/cli/test_qos.py b/smoketest/scripts/cli/test_qos.py index b98c0e9b7..77d384024 100755 --- a/smoketest/scripts/cli/test_qos.py +++ b/smoketest/scripts/cli/test_qos.py @@ -26,25 +26,42 @@ from vyos.utils.process import cmd base_path = ['qos'] -def get_tc_qdisc_json(interface) -> dict: +def get_tc_qdisc_json(interface, all=False) -> dict: tmp = cmd(f'tc -detail -json qdisc show dev {interface}') tmp = loads(tmp) + + if all: + return tmp + return next(iter(tmp)) -def get_tc_filter_json(interface, direction) -> list: - if direction not in ['ingress', 'egress']: + +def get_tc_filter_json(interface, direction=None) -> list: + if direction not in ['ingress', 'egress', None]: raise ValueError() - tmp = cmd(f'tc -detail -json filter show dev {interface} {direction}') + + cmd_stmt = f'tc -detail -json filter show dev {interface}' + if direction: + cmd_stmt += f' {direction}' + + tmp = cmd(cmd_stmt) tmp = loads(tmp) return tmp -def get_tc_filter_details(interface, direction) -> list: + +def get_tc_filter_details(interface, direction=None) -> list: # json doesn't contain all params, such as mtu - if direction not in ['ingress', 'egress']: + if direction not in ['ingress', 'egress', None]: raise ValueError() - tmp = cmd(f'tc -details filter show dev {interface} {direction}') + + cmd_stmt = f'tc -details filter show dev {interface}' + if direction: + cmd_stmt += f' {direction}' + + tmp = cmd(cmd_stmt) return tmp + class TestQoS(VyOSUnitTestSHIM.TestCase): @classmethod def setUpClass(cls): @@ -854,6 +871,57 @@ class TestQoS(VyOSUnitTestSHIM.TestCase): self.cli_set(['qos', 'traffic-match-group', '3', 'match-group', 'unexpected']) self.cli_commit() + def test_20_round_robin_policy_default(self): + interface = self._interfaces[0] + policy_name = f'qos-policy-{interface}' + + self.cli_set(base_path + ['interface', interface, 'egress', policy_name]) + self.cli_set( + base_path + + ['policy', 'round-robin', policy_name, 'description', 'default policy'] + ) + + # commit changes + self.cli_commit() + + tmp = get_tc_qdisc_json(interface, all=True) + + self.assertEqual(2, len(tmp)) + self.assertEqual('drr', tmp[0]['kind']) + self.assertDictEqual({}, tmp[0]['options']) + self.assertEqual('sfq', tmp[1]['kind']) + self.assertDictEqual( + { + 'limit': 127, + 'quantum': 1514, + 'depth': 127, + 'flows': 128, + 'divisor': 1024, + }, + tmp[1]['options'], + ) + + tmp = get_tc_filter_json(interface) + self.assertEqual(3, len(tmp)) + + for rec in tmp: + self.assertEqual('u32', rec['kind']) + self.assertEqual(1, rec['pref']) + self.assertEqual('all', rec['protocol']) + + self.assertDictEqual( + { + 'fh': '800::800', + 'order': 2048, + 'key_ht': '800', + 'bkt': '0', + 'flowid': '1:1', + 'not_in_hw': True, + 'match': {'value': '0', 'mask': '0', 'offmask': '', 'off': 0}, + }, + tmp[2]['options'], + ) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/smoketest/scripts/cli/test_system_option.py b/smoketest/scripts/cli/test_system_option.py index ed0280628..f3112cf0b 100755 --- a/smoketest/scripts/cli/test_system_option.py +++ b/smoketest/scripts/cli/test_system_option.py @@ -23,6 +23,7 @@ from vyos.utils.system import sysctl_read base_path = ['system', 'option'] + class TestSystemOption(VyOSUnitTestSHIM.TestCase): def tearDown(self): self.cli_delete(base_path) @@ -59,6 +60,7 @@ class TestSystemOption(VyOSUnitTestSHIM.TestCase): def test_performance(self): tuned_service = 'tuned.service' + path = ['system', 'sysctl', 'parameter'] self.assertFalse(is_systemd_service_active(tuned_service)) @@ -67,11 +69,11 @@ class TestSystemOption(VyOSUnitTestSHIM.TestCase): gc_thresh2 = '262000' gc_thresh3 = '524000' - self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh1', 'value', gc_thresh1]) - self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh2', 'value', gc_thresh2]) - self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh3', 'value', gc_thresh3]) + self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh1', 'value', gc_thresh1]) + self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh2', 'value', gc_thresh2]) + self.cli_set(path + ['net.ipv4.neigh.default.gc_thresh3', 'value', gc_thresh3]) - self.cli_set(base_path + ['performance', 'throughput']) + self.cli_set(base_path + ['performance', 'network-throughput']) self.cli_commit() self.assertTrue(is_systemd_service_active(tuned_service)) diff --git a/src/conf_mode/system_option.py b/src/conf_mode/system_option.py index a84572f83..e2832cde6 100755 --- a/src/conf_mode/system_option.py +++ b/src/conf_mode/system_option.py @@ -46,6 +46,13 @@ systemd_action_file = '/lib/systemd/system/ctrl-alt-del.target' usb_autosuspend = r'/etc/udev/rules.d/40-usb-autosuspend.rules' kernel_dynamic_debug = r'/sys/kernel/debug/dynamic_debug/control' time_format_to_locale = {'12-hour': 'en_US.UTF-8', '24-hour': 'en_GB.UTF-8'} +tuned_profiles = { + 'power-save': 'powersave', + 'network-latency': 'network-latency', + 'network-throughput': 'network-throughput', + 'virtual-guest': 'virtual-guest', + 'virtual-host': 'virtual-host', +} def get_config(config=None): @@ -171,7 +178,10 @@ def apply(options): # wait until daemon has started before sending configuration while not is_systemd_service_running('tuned.service'): sleep(0.250) - cmd('tuned-adm profile network-{performance}'.format(**options)) + performance = ' '.join( + list(tuned_profiles[profile] for profile in options['performance']) + ) + cmd(f'tuned-adm profile {performance}') else: cmd('systemctl stop tuned.service') diff --git a/src/migration-scripts/system/27-to-28 b/src/migration-scripts/system/27-to-28 new file mode 100644 index 000000000..0a5be48ab --- /dev/null +++ b/src/migration-scripts/system/27-to-28 @@ -0,0 +1,33 @@ +# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see <http://www.gnu.org/licenses/>. + +# rename 'system option performance' leaf nodes to new names + +from vyos.configtree import ConfigTree + +base = ['system', 'option', 'performance'] + +def migrate(config: ConfigTree) -> None: + if not config.exists(base): + return + + replace = { + 'throughput' : 'network-throughput', + 'latency' : 'network-latency' + } + + for old_name, new_name in replace.items(): + if config.return_value(base) == old_name: + config.set(base, new_name) |
