diff options
author | zsdc <taras@vyos.io> | 2023-06-29 16:31:13 +0300 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2023-06-29 16:31:13 +0300 |
commit | 199657fc60782961e86af2f3f49b246b29b9723c (patch) | |
tree | 427b50b7ccfa2840c9a2abf7b9ddb222424a3884 /src/conf_mode | |
parent | b7afb930e997915c8a4d117b5e138cb0555163c3 (diff) | |
download | vyos-1x-199657fc60782961e86af2f3f49b246b29b9723c.tar.gz vyos-1x-199657fc60782961e86af2f3f49b246b29b9723c.zip |
VPP: T1797: Optimized interfaces add/remove
- added extra renaming operation to be sure that interface has the same name as
before in the system after it was moved from VPP to kernel
- added extra check after PCI device removal/adding
- added check for proper `retval` for CPI calls where it is available
- replaced empty return with an error in `_get_pci_address_by_interface()`
because not resolved address will lead to inconsistency of the system later
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/vpp.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 25fe159f8..dd01da87e 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -53,12 +53,12 @@ def _get_pci_address_by_interface(iface) -> str: address = re_obj.groupdict().get('address', '') return address # use VPP - maybe interface already attached to it - vpp_control = VPPControl() + vpp_control = VPPControl(attempts=20, interval=500) pci_addr = vpp_control.get_pci_addr(iface) if pci_addr: return pci_addr - # return empty string if address was not found - return '' + # raise error if PCI address was not found + raise ConfigError(f'Cannot find PCI address for interface {iface}') @@ -148,8 +148,14 @@ def apply(config): call('systemctl daemon-reload') call(f'systemctl restart {service_name}.service') + # Initialize interfaces removed from VPP for iface in config.get('removed_ifaces', []): - HostControl().pci_rescan(iface['iface_pci_addr']) + host_control = HostControl() + # rescan PCI to use a proper driver + host_control.pci_rescan(iface['iface_pci_addr']) + # rename to the proper name + iface_new_name: str = host_control.get_eth_name(iface['iface_pci_addr']) + host_control.rename_iface(iface_new_name, iface['iface_name']) if 'interface' in config: # connect to VPP |