diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-03-20 15:48:50 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-20 15:48:50 +0000 |
| commit | af6751ecdf44bde0c6dfb397e5ad128561f93112 (patch) | |
| tree | 6f56ac0b76307aacd464dfc6dff0783d4ed803c8 /python | |
| parent | 337837dd8a57d7af282d603f8b930ed40f7fa03c (diff) | |
| parent | 877166b8aef1132f5bad208aee00444819264501 (diff) | |
| download | vyos-1x-af6751ecdf44bde0c6dfb397e5ad128561f93112.tar.gz vyos-1x-af6751ecdf44bde0c6dfb397e5ad128561f93112.zip | |
Merge pull request #23 from natali-rs1985/T7189
T7189: VPP source of the tunnel interface should be checked and configured
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/vpp/config_verify.py | 13 | ||||
| -rw-r--r-- | python/vyos/vpp/utils.py | 37 |
2 files changed, 50 insertions, 0 deletions
diff --git a/python/vyos/vpp/config_verify.py b/python/vyos/vpp/config_verify.py index 6b35858d2..830d4af73 100644 --- a/python/vyos/vpp/config_verify.py +++ b/python/vyos/vpp/config_verify.py @@ -102,6 +102,19 @@ def verify_vpp_remove_xconnect_interface(config: dict): ) +def verify_vpp_tunnel_source_address(config: dict): + from vyos.utils.network import is_intf_addr_assigned + + address = config.get('source_address') + for iface in config.get('vpp_ether_vif_ifaces', []): + if is_intf_addr_assigned(iface, address): + return True + + raise ConfigError( + f'Source address "{address}" is not assigned on any Ethernet or VIF interface!' + ) + + def verify_dev_driver(iface_name: str, driver_type: str) -> bool: # Lists of drivers compatible with DPDK and XDP drivers_dpdk: list[str] = [ diff --git a/python/vyos/vpp/utils.py b/python/vyos/vpp/utils.py index 681d25578..fe08a98b8 100644 --- a/python/vyos/vpp/utils.py +++ b/python/vyos/vpp/utils.py @@ -85,6 +85,43 @@ def cli_ifaces_list(config_instance, mode: str = 'candidate') -> list[str]: return vpp_ifaces +def cli_ethernet_with_vifs_ifaces(config_instance) -> list[str]: + """List of all VPP Ethernet interfaces with VIFs + + Args: + config_instance (VyOS Config): VyOS Config instance + + Returns: + list[str]: list of interfaces + """ + from vyos.configdict import get_interface_dict + + # Read a config + config = config_instance.get_config_dict( + ['vpp'], + key_mangling=('-', '_'), + get_first_key=True, + no_tag_node_value_mangle=True, + with_recursive_defaults=True, + ) + + ifaces: list[str] = [] + + # Get a list of Ethernet interfaces + for iface in config.get('settings', {}).get('interface', {}).keys(): + ifaces.append(iface) + + # Add Ethernet interfaces with VIFs + for iface in ifaces: + _, iface_config = get_interface_dict( + config_instance, ['interfaces', 'ethernet'], ifname=iface + ) + ifaces.extend([f'{iface}.{vif}' for vif in iface_config.get('vif', {})]) + ifaces.extend([f'{iface}.{vif_s}' for vif_s in iface_config.get('vif_s', {})]) + + return ifaces + + def vpp_ifaces_list(vpp_api) -> list[dict]: """List interfaces in VPP |
