From 6c5fa7623bca706879d025ffe49dd0f3977b687b Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Mon, 28 Oct 2024 15:18:19 +0200 Subject: [PATCH 1/2] T3501: Allow using more than one tuned profile --- .../include/version/system-version.xml.i | 2 +- interface-definitions/system_option.xml.in | 21 +++++++++--- .../config-tests/dialup-router-wireguard-ipv6 | 2 +- .../configs/dialup-router-wireguard-ipv6 | 2 +- smoketest/scripts/cli/test_system_option.py | 2 +- src/conf_mode/system_option.py | 3 +- src/migration-scripts/system/27-to-28 | 33 +++++++++++++++++++ 7 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/migration-scripts/system/27-to-28 diff --git a/interface-definitions/include/version/system-version.xml.i b/interface-definitions/include/version/system-version.xml.i index fcb24abe2c..3ecf124c79 100644 --- a/interface-definitions/include/version/system-version.xml.i +++ b/interface-definitions/include/version/system-version.xml.i @@ -1,3 +1,3 @@ - + diff --git a/interface-definitions/system_option.xml.in b/interface-definitions/system_option.xml.in index 064d9ff402..cdc0334cdf 100644 --- a/interface-definitions/system_option.xml.in +++ b/interface-definitions/system_option.xml.in @@ -149,19 +149,32 @@ Tune system performance - throughput latency + network-throughput network-latency powersave virtual-host virtual-guest - throughput + network-throughput Tune for maximum network throughput - latency + network-latency Tune for low network latency + + powersave + Tune for low power consumption + + + virtual-guest + Tune for running inside a virtual guest + + + virtual-host + Tune for running KVM guests + - (throughput|latency) + (network-throughput|network-latency|powersave|virtual-guest|virtual-host) + diff --git a/smoketest/config-tests/dialup-router-wireguard-ipv6 b/smoketest/config-tests/dialup-router-wireguard-ipv6 index ff4bf89c26..c2cf2e9d8a 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 0585821487..7676063418 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_system_option.py b/smoketest/scripts/cli/test_system_option.py index ed02806286..e0874a46ee 100755 --- a/smoketest/scripts/cli/test_system_option.py +++ b/smoketest/scripts/cli/test_system_option.py @@ -71,7 +71,7 @@ def test_performance(self): 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(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 a84572f831..f4aa83f2d9 100755 --- a/src/conf_mode/system_option.py +++ b/src/conf_mode/system_option.py @@ -171,7 +171,8 @@ 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(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 0000000000..0a5be48ab9 --- /dev/null +++ b/src/migration-scripts/system/27-to-28 @@ -0,0 +1,33 @@ +# Copyright 2023-2024 VyOS maintainers and contributors +# +# 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 . + +# 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) From af8eb89649cb0833258b0f216fcc2f460c467dc8 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Mon, 28 Oct 2024 15:42:29 +0200 Subject: [PATCH 2/2] T3501: normalize formatting --- smoketest/scripts/cli/test_system_option.py | 34 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/smoketest/scripts/cli/test_system_option.py b/smoketest/scripts/cli/test_system_option.py index e0874a46ee..6e440315b1 100755 --- a/smoketest/scripts/cli/test_system_option.py +++ b/smoketest/scripts/cli/test_system_option.py @@ -23,6 +23,7 @@ base_path = ['system', 'option'] + class TestSystemOption(VyOSUnitTestSHIM.TestCase): def tearDown(self): self.cli_delete(base_path) @@ -67,9 +68,36 @@ def test_performance(self): 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( + [ + '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(base_path + ['performance', 'network-throughput']) self.cli_commit()