diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-12-02 20:00:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 20:00:46 +0100 |
commit | 1c792052d435f33a3ef634b57f780e3f00909a9f (patch) | |
tree | 400f9b91fe8154842d67d6808e82cd4fe9c0a8a8 /src/conf_mode/interfaces-virtual-ethernet.py | |
parent | 8cdc6aea127c455c0aef36ab6d93ec050cbf04aa (diff) | |
parent | 94f345340f69333dbb06fcf5f59caa8176ebecc6 (diff) | |
download | vyos-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-x | src/conf_mode/interfaces-virtual-ethernet.py | 13 |
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 |