diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/configdict.py | 13 | ||||
| -rw-r--r-- | python/vyos/configverify.py | 18 |
2 files changed, 28 insertions, 3 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index d52a3940e..8c311616c 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -604,6 +604,10 @@ def get_interface_dict(config, base, ifname='', recursive_defaults=True, with_pk bridge = is_member(config, f'{ifname}.{vif}', 'bridge') if bridge: dict['vif'][vif].update({'is_bridge_member' : bridge}) + # Check if it is a monitor interface + mirror = is_mirror_intf(config, f'{ifname}.{vif}') + if mirror: dict['vif'][vif].update({'is_mirror_intf' : mirror}) + # Check if any DHCP options changed which require a client restart dhcp = is_node_changed(config, base + [ifname, 'vif', vif, 'dhcp-options']) if dhcp: dict['vif'][vif].update({'dhcp_options_changed' : {}}) @@ -634,6 +638,10 @@ def get_interface_dict(config, base, ifname='', recursive_defaults=True, with_pk bridge = is_member(config, f'{ifname}.{vif_s}', 'bridge') if bridge: dict['vif_s'][vif_s].update({'is_bridge_member' : bridge}) + # Check if it is a monitor interface + mirror = is_mirror_intf(config, f'{ifname}.{vif_s}') + if mirror: dict['vif_s'][vif_s].update({'is_mirror_intf' : mirror}) + # Check if any DHCP options changed which require a client restart dhcp = is_node_changed(config, base + [ifname, 'vif-s', vif_s, 'dhcp-options']) if dhcp: dict['vif_s'][vif_s].update({'dhcp_options_changed' : {}}) @@ -666,6 +674,11 @@ def get_interface_dict(config, base, ifname='', recursive_defaults=True, with_pk if bridge: dict['vif_s'][vif_s]['vif_c'][vif_c].update( {'is_bridge_member' : bridge}) + # Check if it is a monitor interface + mirror = is_mirror_intf(config, f'{ifname}.{vif_s}.{vif_c}') + if mirror: dict['vif_s'][vif_s]['vif_c'][vif_c].update( + {'is_mirror_intf' : mirror}) + # Check if any DHCP options changed which require a client restart dhcp = is_node_changed(config, base + [ifname, 'vif-s', vif_s, 'vif-c', vif_c, 'dhcp-options']) if dhcp: dict['vif_s'][vif_s]['vif_c'][vif_c].update({'dhcp_options_changed' : {}}) diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 0c2e2f62b..714f544f0 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -188,18 +188,30 @@ def verify_mirror_redirect(config): # limitation from the past raise ConfigError('Cannot use QoS together with mirror!') + def vlan_configured(interface, vlan): + # vif or vif-s, or a vif-c below a vif-s + if len(vlan) == 1: + return (('vif' in interface and vlan[0] in interface['vif']) or + ('vif-s' in interface and vlan[0] in interface['vif-s'])) + if len(vlan) == 2 and 'vif-s' in interface and vlan[0] in interface['vif-s']: + vif_s = interface['vif-s'][vlan[0]] + return 'vif-c' in vif_s and vlan[1] in vif_s['vif-c'] + return False + def verify_target(kind, target): # T6393: interface types are committed in priority order, the target # may only be defined on the CLI and not (yet) exist in the Kernel. # tc(8) can not reach a target in another netns + ifname, *vlan = target.split('.') for interfaces in getattr(config, 'interfaces_root', {}).values(): - if target in interfaces: - if 'netns' in interfaces[target]: + if ifname in interfaces: + if 'netns' in interfaces[ifname]: raise ConfigError( f'Requested {kind} interface "{target}" is in a ' 'network namespace!' ) - return + if not vlan or vlan_configured(interfaces[ifname], vlan): + return if not interface_exists(target): raise ConfigError(f'Requested {kind} interface "{target}" does not exist!') |
