summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-virtual-ethernet.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-11-25 17:13:24 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-11-25 17:13:24 +0000
commitad8f5762234d6b482b40b574d97fc51f6557daff (patch)
tree446f1382783447b5dc8191ed3f812ab37b347d2e /src/conf_mode/interfaces-virtual-ethernet.py
parente0182613a2013ed7efa5bf99766c89cddefc1b29 (diff)
downloadvyos-1x-ad8f5762234d6b482b40b574d97fc51f6557daff.tar.gz
vyos-1x-ad8f5762234d6b482b40b574d97fc51f6557daff.zip
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
Diffstat (limited to 'src/conf_mode/interfaces-virtual-ethernet.py')
-rwxr-xr-xsrc/conf_mode/interfaces-virtual-ethernet.py7
1 files changed, 7 insertions, 0 deletions
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)