From ad8f5762234d6b482b40b574d97fc51f6557daff Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Fri, 25 Nov 2022 17:13:24 +0000 Subject: T4825: Verify if veth interface not used in conf before deleting Prevent to delete interface "vethX" which used for another interface as "vethY peer-name vethX" set interfaces virtual-ethernet veth0 peer-name 'veth1' set interfaces virtual-ethernet veth1 peer-name 'veth0' commit delete interfaces virtual-ethernet veth0 commit --- src/conf_mode/interfaces-virtual-ethernet.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/conf_mode/interfaces-virtual-ethernet.py b/src/conf_mode/interfaces-virtual-ethernet.py index b1819233c..53422ad2d 100755 --- a/src/conf_mode/interfaces-virtual-ethernet.py +++ b/src/conf_mode/interfaces-virtual-ethernet.py @@ -53,6 +53,13 @@ def get_config(config=None): def verify(veth): if 'deleted' in veth: verify_bridge_delete(veth) + # Prevent to delete veth interface which used for another "vethX peer-name" + for iface, iface_config in veth['other_interfaces'].items(): + if veth['ifname'] in iface_config['peer_name']: + ifname = veth['ifname'] + raise ConfigError( + f'Cannot delete "{ifname}" used for "interface {iface} peer-name"' + ) return None verify_vrf(veth) -- cgit v1.2.3