diff options
| author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2025-02-04 11:51:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-04 11:51:58 +0200 |
| commit | 2b543c685886974006ac279f5ac054448b2501be (patch) | |
| tree | 1950a83f13711bad6e308c5e0bf0145980433072 | |
| parent | a649b1adaca050e0ce2c882689239ce286903a9c (diff) | |
| parent | 9be3a63f700acef43b7a84bd83b9bea0cdd0c481 (diff) | |
| download | vyos-1x-2b543c685886974006ac279f5ac054448b2501be.tar.gz vyos-1x-2b543c685886974006ac279f5ac054448b2501be.zip | |
Merge pull request #7 from natali-rs1985/T7075
T7075: VPP check driver's options before apply
| -rwxr-xr-x | smoketest/scripts/cli/test_vpp.py | 30 | ||||
| -rwxr-xr-x | src/conf_mode/vpp.py | 20 |
2 files changed, 48 insertions, 2 deletions
diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py index ffbed2c8c..8f812d520 100755 --- a/smoketest/scripts/cli/test_vpp.py +++ b/smoketest/scripts/cli/test_vpp.py @@ -948,6 +948,36 @@ class TestVPP(VyOSUnitTestSHIM.TestCase): for required_string in required_str_list: self.assertNotIn(required_string, out) + def test_10_vpp_driver_options(self): + dpdk_options = { + 'num-rx-desc': '512', + 'num-tx-desc': '512', + 'num-rx-queues': '3', + 'num-tx-queues': '3', + } + + base_interface_path = base_path + ['settings', 'interface', interface] + + for option, value in dpdk_options.items(): + self.cli_set(base_interface_path + ['dpdk-options', option, value]) + + # DPDK driver expect only dpdk-options and not xdp-options to be set + # expect raise ConfigError + self.cli_set(base_interface_path + ['xdp-options', 'no-syscall-lock']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + # delete xdp-options and apply commit + self.cli_delete(base_interface_path + ['xdp-options']) + self.cli_commit() + + # check dpdk options in config file + config = read_file(VPP_CONF) + + for option, value in dpdk_options.items(): + self.assertIn(f'{option} {value}', config) + def test_11_vpp_cpu_settings(self): main_core = '0' workers = '2' diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 249467460..0b2d4cbe8 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -24,7 +24,7 @@ from pyroute2 import IPRoute from vyos import ConfigError from vyos import airbag from vyos.base import Warning -from vyos.config import Config +from vyos.config import Config, config_dict_merge from vyos.configdep import set_dependents, call_dependents from vyos.configdict import node_changed, leaf_node_changed from vyos.utils.cpu import get_core_count @@ -126,9 +126,19 @@ def get_config(config=None): get_first_key=True, key_mangling=('-', '_'), no_tag_node_value_mangle=True, - with_recursive_defaults=True, ) + # Get default values which we need to conditionally update into the + # dictionary retrieved. + default_values = conf.get_config_defaults(**config.kwargs, recursive=True) + + # delete "xdp-options" from defaults if driver is DPDK + for iface, iface_config in config.get('settings', {}).get('interface', {}).items(): + if iface_config.get('driver') == 'dpdk': + del default_values['settings']['interface'][iface]['xdp_options'] + + config = config_dict_merge(default_values, config) + # add running config if effective_config: config['effective'] = effective_config @@ -335,6 +345,12 @@ def verify(config): if iface_config['xdp_options']['num_rx_queues'] != 'all': Warning(f'Not all RX queues will be connected to VPP for {iface}!') + if iface_config['driver'] == 'xdp' and 'dpdk_options' in iface_config: + raise ConfigError('DPDK options are not applicable for XDP driver!') + + if iface_config['driver'] == 'dpdk' and 'xdp_options' in iface_config: + raise ConfigError('XDP options are not applicable for DPDK driver!') + # check GRE tunnels as part of the bridge, only tunnel-type teb is allowed # set vpp interfaces bridge br1 member interface gre1 # set vpp interfaces gre gre1 tunnel-type teb |
