From 199657fc60782961e86af2f3f49b246b29b9723c Mon Sep 17 00:00:00 2001 From: zsdc Date: Thu, 29 Jun 2023 16:31:13 +0300 Subject: 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 --- src/conf_mode/vpp.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/conf_mode') 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 -- cgit v1.2.3