Skip to content

Commit

Permalink
T7076: VPP check ethernet interface exist before adding to vpp
Browse files Browse the repository at this point in the history
  • Loading branch information
natali-rs1985 committed Jan 29, 2025
1 parent dfda2c7 commit 83c322a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/conf_mode/vpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from vyos.ifconfig import Section
from vyos.template import render
from vyos.utils.boot import boot_configuration_complete
from vyos.utils.network import interface_exists
from vyos.utils.process import call
from vyos.utils.system import sysctl_read, sysctl_apply

Expand All @@ -39,7 +40,7 @@
from vyos.vpp.config_deps import deps_xconnect_dict
from vyos.vpp.config_verify import verify_dev_driver
from vyos.vpp.config_filter import iface_filter_eth
from vyos.vpp.utils import EthtoolGDrvinfo
from vyos.vpp.utils import EthtoolGDrvinfo, vpp_ifaces_list
from vyos.vpp.configdb import JSONStorage

airbag.enable()
Expand Down Expand Up @@ -135,7 +136,20 @@ def get_config(config=None):

if 'settings' in config:
if 'interface' in config['settings']:
# get list of interfaces that exist in the VPP to verify interfaces
# that disappeared from the system
vpp_ifaces = []
if effective_config:
vpp_api = VPPControl()
vpp_ifaces = [
i.get('interface_name', '') for i in vpp_ifaces_list(vpp_api.api)
]

for iface, iface_config in config['settings']['interface'].items():
# verify interface exists
if not interface_exists(iface) and iface not in vpp_ifaces:
raise ConfigError(f'Interface "{iface}" does not exist!')

# Driver must be configured to continue
if 'driver' not in iface_config:
raise ConfigError(
Expand Down

0 comments on commit 83c322a

Please sign in to comment.