summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-virtual-ethernet.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-12-02 14:16:18 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-12-02 14:16:18 +0000
commit94f345340f69333dbb06fcf5f59caa8176ebecc6 (patch)
tree7364ee9ccea6f8ecc51d4b93ef75cc0e20519e52 /src/conf_mode/interfaces-virtual-ethernet.py
parentc2a5957a942c8f6070b8f6ff12764e90c1a4c237 (diff)
downloadvyos-1x-94f345340f69333dbb06fcf5f59caa8176ebecc6.tar.gz
vyos-1x-94f345340f69333dbb06fcf5f59caa8176ebecc6.zip
T4825: Verify if you are trying to add a new vethX to exists pair
Verify if you are trying to add a new vethX to exists pair: set int virtual-ethernet veth0 peer-name 'veth1' set int virtual-ethernet veth1 peer-name 'veth0' set int virtual-ethernet veth12 peer-name 'veth0' Verify veth-name and peer-name cannot be the same: set interfaces virtual-ethernet veth0 peer-name veth0
Diffstat (limited to 'src/conf_mode/interfaces-virtual-ethernet.py')
-rwxr-xr-xsrc/conf_mode/interfaces-virtual-ethernet.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/conf_mode/interfaces-virtual-ethernet.py b/src/conf_mode/interfaces-virtual-ethernet.py
index 53422ad2d..8efe89c41 100755
--- a/src/conf_mode/interfaces-virtual-ethernet.py
+++ b/src/conf_mode/interfaces-virtual-ethernet.py
@@ -68,12 +68,21 @@ def verify(veth):
if 'peer_name' not in veth:
raise ConfigError(f'Remote peer name must be set for "{veth["ifname"]}"!')
+ peer_name = veth['peer_name']
+ ifname = veth['ifname']
+
if veth['peer_name'] not in veth['other_interfaces']:
- peer_name = veth['peer_name']
- ifname = veth['ifname']
raise ConfigError(f'Used peer-name "{peer_name}" on interface "{ifname}" ' \
'is not configured!')
+ if veth['other_interfaces'][peer_name]['peer_name'] != ifname:
+ raise ConfigError(
+ f'Configuration mismatch between "{ifname}" and "{peer_name}"!')
+
+ if peer_name == ifname:
+ raise ConfigError(
+ f'Peer-name "{peer_name}" cannot be the same as interface "{ifname}"!')
+
return None