diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-01-01 12:21:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-01 12:21:40 +0200 |
commit | 4519506c6f5360c73c0342e049d716465857802e (patch) | |
tree | 55464d0c6e1b632c2ba384e47fd9b568f8d11958 /python | |
parent | 15e55e4ea9201d9cb2e64c63fd109c9b98509947 (diff) | |
parent | 66ce19058b7b8597536ddf63bbca027add2ca8a1 (diff) | |
download | vyos-1x-4519506c6f5360c73c0342e049d716465857802e.tar.gz vyos-1x-4519506c6f5360c73c0342e049d716465857802e.zip |
Merge pull request #2728 from c-po/verify-T5880
T5880: verify_source_interface() should not allow dynamic interfaces like ppp, l2tp, ipoe or sstpc client interfaces
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configverify.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 27055c863..85423142d 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -281,16 +281,22 @@ def verify_source_interface(config): perform recurring validation of the existence of a source-interface required by e.g. peth/MACvlan, MACsec ... """ + import re from netifaces import interfaces - if 'source_interface' not in config: - raise ConfigError('Physical source-interface required for ' - 'interface "{ifname}"'.format(**config)) - if config['source_interface'] not in interfaces(): - raise ConfigError('Specified source-interface {source_interface} does ' - 'not exist'.format(**config)) + ifname = config['ifname'] + if 'source_interface' not in config: + raise ConfigError(f'Physical source-interface required for "{ifname}"!') src_ifname = config['source_interface'] + # We do not allow sourcing other interfaces (e.g. tunnel) from dynamic interfaces + tmp = re.compile(r'(ppp|pppoe|sstpc|l2tp|ipoe)[0-9]+') + if tmp.match(src_ifname): + raise ConfigError(f'Can not source "{ifname}" from dynamic interface "{src_ifname}"!') + + if src_ifname not in interfaces(): + raise ConfigError(f'Specified source-interface {src_ifname} does not exist') + if 'source_interface_is_bridge_member' in config: bridge_name = next(iter(config['source_interface_is_bridge_member'])) raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface ' @@ -303,7 +309,6 @@ def verify_source_interface(config): if 'is_source_interface' in config: tmp = config['is_source_interface'] - src_ifname = config['source_interface'] raise ConfigError(f'Can not use source-interface "{src_ifname}", it already ' \ f'belongs to interface "{tmp}"!') |