summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-virtual-ethernet.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-12-02 20:00:46 +0100
committerGitHub <noreply@github.com>2022-12-02 20:00:46 +0100
commit1c792052d435f33a3ef634b57f780e3f00909a9f (patch)
tree400f9b91fe8154842d67d6808e82cd4fe9c0a8a8 /src/conf_mode/interfaces-virtual-ethernet.py
parent8cdc6aea127c455c0aef36ab6d93ec050cbf04aa (diff)
parent94f345340f69333dbb06fcf5f59caa8176ebecc6 (diff)
downloadvyos-1x-1c792052d435f33a3ef634b57f780e3f00909a9f.tar.gz
vyos-1x-1c792052d435f33a3ef634b57f780e3f00909a9f.zip
Merge pull request #1687 from sever-sever/T4825
T4825: Verify if you are trying to add a new vethX to exists pair
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