diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-02-11 11:43:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-11 11:43:56 +0100 |
| commit | c12ecacffc3418c56103a6df0209652feca74225 (patch) | |
| tree | 2b39d6cea2cf9fe665c0e72b482fbd6bbf070db0 | |
| parent | f1ebc7820a54d7300e6b6e857be47a6dca289f54 (diff) | |
| parent | eee03985388eb43396559d551e0bf678568e89fd (diff) | |
| download | vyos-1x-c12ecacffc3418c56103a6df0209652feca74225.tar.gz vyos-1x-c12ecacffc3418c56103a6df0209652feca74225.zip | |
Merge pull request #4982 from natali-rs1985/T8252
vpp: T8252: Change ACL node 'macip' to 'mac'
| -rw-r--r-- | interface-definitions/include/version/vpp-version.xml.i | 2 | ||||
| -rw-r--r-- | interface-definitions/vpp.xml.in | 4 | ||||
| -rw-r--r-- | op-mode-definitions/vpp_acl.xml.in | 12 | ||||
| -rw-r--r-- | python/vyos/vpp/acl/acl.py | 26 | ||||
| -rwxr-xr-x | src/conf_mode/interfaces_ethernet.py | 2 | ||||
| -rw-r--r-- | src/conf_mode/vpp_acl.py | 48 | ||||
| -rw-r--r-- | src/migration-scripts/vpp/6-to-7 | 25 | ||||
| -rw-r--r-- | src/op_mode/vpp_acl.py | 34 |
8 files changed, 89 insertions, 64 deletions
diff --git a/interface-definitions/include/version/vpp-version.xml.i b/interface-definitions/include/version/vpp-version.xml.i index c12e3786c..d8dd517bd 100644 --- a/interface-definitions/include/version/vpp-version.xml.i +++ b/interface-definitions/include/version/vpp-version.xml.i @@ -1,3 +1,3 @@ <!-- include start from include/version/vpp-version.xml.i --> -<syntaxVersion component='vpp' version='6'></syntaxVersion> +<syntaxVersion component='vpp' version='7'></syntaxVersion> <!-- include end --> diff --git a/interface-definitions/vpp.xml.in b/interface-definitions/vpp.xml.in index 14a869849..b9ce1949f 100644 --- a/interface-definitions/vpp.xml.in +++ b/interface-definitions/vpp.xml.in @@ -1561,7 +1561,7 @@ </tagNode> </children> </node> - <node name="macip"> + <node name="mac"> <properties> <help>Access Control List by mac address</help> </properties> @@ -1656,7 +1656,7 @@ <properties> <help>ACL tag name</help> <completionHelp> - <path>vpp acl macip tag-name</path> + <path>vpp acl mac tag-name</path> </completionHelp> </properties> </leafNode> diff --git a/op-mode-definitions/vpp_acl.xml.in b/op-mode-definitions/vpp_acl.xml.in index a901a537d..20b7746db 100644 --- a/op-mode-definitions/vpp_acl.xml.in +++ b/op-mode-definitions/vpp_acl.xml.in @@ -32,28 +32,28 @@ </children> <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_ip_acls</command> </node> - <node name="macip"> + <node name="mac"> <properties> - <help>Show VPP ACL by macip</help> + <help>Show VPP ACL by mac</help> </properties> <children> <tagNode name="tag-name"> <properties> <help>Show specified VPP ACL</help> <completionHelp> - <path>vpp acl macip tag-name</path> + <path>vpp acl mac tag-name</path> </completionHelp> </properties> - <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_macip_acls --tag-name="$6"</command> + <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_mac_acls --tag-name="$6"</command> </tagNode> <node name="interface"> <properties> <help>Show VPP ACL interfaces</help> </properties> - <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_macip_interfaces</command> + <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_mac_interfaces</command> </node> </children> - <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_macip_acls</command> + <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_mac_acls</command> </node> </children> <command>sudo ${vyos_op_scripts_dir}/vpp_acl.py show_all_acls</command> diff --git a/python/vyos/vpp/acl/acl.py b/python/vyos/vpp/acl/acl.py index 57d36ac91..c70b3484c 100644 --- a/python/vyos/vpp/acl/acl.py +++ b/python/vyos/vpp/acl/acl.py @@ -70,36 +70,36 @@ class Acl: count=0, ) - def get_macip_acl_index_by_tag(self, tag): - """Get macip ACL by tag name""" + def get_mac_acl_index_by_tag(self, tag): + """Get mac ACL by tag name""" for acl in self.vpp.api.macip_acl_dump(): if acl.tag == tag: return acl.acl_index return NO_ACL_INDEX - def add_replace_acl_macip(self, tag, rules): - """Add or replace existing macip ACL""" + def add_replace_acl_mac(self, tag, rules): + """Add or replace existing mac ACL""" self.vpp.api.macip_acl_add_replace( tag=tag, - acl_index=self.get_macip_acl_index_by_tag(tag), + acl_index=self.get_mac_acl_index_by_tag(tag), count=len(rules), r=rules, ) - def delete_acl_macip(self, tag): - """Delete existing macip ACL""" - self.vpp.api.macip_acl_del(acl_index=self.get_macip_acl_index_by_tag(tag)) + def delete_acl_mac(self, tag): + """Delete existing mac ACL""" + self.vpp.api.macip_acl_del(acl_index=self.get_mac_acl_index_by_tag(tag)) - def add_acl_macip_interface(self, interface, tag): - """Add or replace macip ACLs on interface""" + def add_acl_mac_interface(self, interface, tag): + """Add or replace mac ACLs on interface""" self.vpp.api.macip_acl_interface_add_del( sw_if_index=self.vpp.get_sw_if_index(interface), - acl_index=self.get_macip_acl_index_by_tag(tag), + acl_index=self.get_mac_acl_index_by_tag(tag), is_add=True, ) - def delete_acl_macip_interface(self, interface): - """Delete macip ACLs from interface""" + def delete_acl_mac_interface(self, interface): + """Delete mac ACLs from interface""" self.vpp.api.macip_acl_interface_add_del( sw_if_index=self.vpp.get_sw_if_index(interface), is_add=False, diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py index 2a65855a4..97902c6e4 100755 --- a/src/conf_mode/interfaces_ethernet.py +++ b/src/conf_mode/interfaces_ethernet.py @@ -367,7 +367,7 @@ def verify_vpp_remove_vif(ethernet: dict): r'(interfaces\.bridge\.br(\d)+\.member\.interface)|' r'(interfaces\.xconnect\.xcon(\d)+\.member\.interface)|' r'(acl\.ip\.interface)|' - r'(acl\.macip\.interface)' + r'(acl\.mac\.interface)' ) ifname = ethernet['ifname'] diff --git a/src/conf_mode/vpp_acl.py b/src/conf_mode/vpp_acl.py index f075f9f5e..4d9ada4a1 100644 --- a/src/conf_mode/vpp_acl.py +++ b/src/conf_mode/vpp_acl.py @@ -115,7 +115,7 @@ def create_ip_rules_list(rules): return rules_list -def create_macip_rules_list(rules): +def create_mac_rules_list(rules): rules_list = [] for rule in rules.values(): r = { @@ -171,9 +171,9 @@ def get_config(config=None) -> dict: expand_nodes=Diff.DELETE | Diff.ADD, ) - changed_macip_ifaces = node_changed( + changed_mac_ifaces = node_changed( conf, - base + ['macip', 'interface'], + base + ['mac', 'interface'], key_mangling=('-', '_'), recursive=True, expand_nodes=Diff.DELETE | Diff.ADD, @@ -182,7 +182,7 @@ def get_config(config=None) -> dict: config.update( { 'changed_ip_ifaces': changed_ip_ifaces, - 'changed_macip_ifaces': changed_macip_ifaces, + 'changed_mac_ifaces': changed_mac_ifaces, 'vpp_ifaces': cli_ifaces_list(conf), } ) @@ -197,7 +197,7 @@ def verify(config): if 'remove' in config or 'remove_vpp' in config: return None - for acl_type in ['ip', 'macip']: + for acl_type in ['ip', 'mac']: if acl_type in config: acl = config.get(acl_type) if 'tag_name' not in acl: @@ -306,8 +306,8 @@ def verify(config): ) used_names.append(name) - if 'macip' in config: - acl = config.get('macip') + if 'mac' in config: + acl = config.get('mac') for iface, iface_config in acl.get('interface', {}).items(): if 'tag_name' not in iface_config: raise ConfigError(f'"tag-name" is required for interface {iface}') @@ -342,18 +342,18 @@ def apply(config): if acl_name not in config.get('ip', {}).get('tag_name', {}): acl.delete_acl(acl_name) - # Delete ACL macip - if 'macip' in config.get('effective'): - remove_config_macip = config.get('effective').get('macip') + # Delete ACL mac + if 'mac' in config.get('effective'): + remove_config_mac = config.get('effective').get('mac') # Delete ACL interfaces - for interface in config.get('changed_macip_ifaces'): - acl.delete_acl_macip_interface(interface) + for interface in config.get('changed_mac_ifaces'): + acl.delete_acl_mac_interface(interface) - # Delete ACL macip - for acl_name in remove_config_macip.get('tag_name'): - if acl_name not in config.get('macip', {}).get('tag_name', {}): - acl.delete_acl_macip(acl_name) + # Delete ACL mac + for acl_name in remove_config_mac.get('tag_name'): + if acl_name not in config.get('mac', {}).get('tag_name', {}): + acl.delete_acl_mac(acl_name) if 'remove' in config: return None @@ -377,16 +377,16 @@ def apply(config): ] acl.add_acl_interface(iface, input_tags, output_tags) - # Add or replace ACL macip - config_macip = config.get('macip', {}) - for acl_name in config_macip.get('tag_name', {}): - rules = create_macip_rules_list( - config_macip.get('tag_name').get(acl_name).get('rule') + # Add or replace ACL mac + config_mac = config.get('mac', {}) + for acl_name in config_mac.get('tag_name', {}): + rules = create_mac_rules_list( + config_mac.get('tag_name').get(acl_name).get('rule') ) - acl.add_replace_acl_macip(acl_name, rules) + acl.add_replace_acl_mac(acl_name, rules) - for iface, iface_config in config_macip.get('interface', {}).items(): - acl.add_acl_macip_interface(iface, iface_config.get('tag_name')) + for iface, iface_config in config_mac.get('interface', {}).items(): + acl.add_acl_mac_interface(iface, iface_config.get('tag_name')) if __name__ == '__main__': diff --git a/src/migration-scripts/vpp/6-to-7 b/src/migration-scripts/vpp/6-to-7 new file mode 100644 index 000000000..4cb4b07fa --- /dev/null +++ b/src/migration-scripts/vpp/6-to-7 @@ -0,0 +1,25 @@ +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see <http://www.gnu.org/licenses/>. + +# Rename acl 'macip' node to 'mac' (T8252) + + +from vyos.configtree import ConfigTree + +base = ['vpp', 'acl'] + +def migrate(config: ConfigTree) -> None: + if config.exists(base + ['macip']): + config.rename(base + ['macip'], 'mac') diff --git a/src/op_mode/vpp_acl.py b/src/op_mode/vpp_acl.py index ed9b35ef6..6d5daba06 100644 --- a/src/op_mode/vpp_acl.py +++ b/src/op_mode/vpp_acl.py @@ -54,7 +54,7 @@ def _verify(target): """Decorator checks if config for VPP NAT CGNAT exists""" from functools import wraps - if target not in ['ip', 'macip', 'no_target']: + if target not in ['ip', 'mac', 'no_target']: raise ValueError('Invalid target') def _verify_target(func): @@ -64,8 +64,8 @@ def _verify(target): path = 'vpp acl' if target == 'ip': path += ' ip' - elif target == 'macip': - path += ' macip' + elif target == 'mac': + path += ' mac' if not config.exists(path): raise vyos.opmode.UnconfiguredSubsystem(f'"{path}" is not configured') return func(*args, **kwargs) @@ -83,7 +83,7 @@ def _get_acl_tag_by_index(vpp, acl_index): return None -def _get_macip_acl_tag_by_index(vpp, acl_index): +def _get_mac_acl_tag_by_index(vpp, acl_index): acl = vpp.api.macip_acl_dump(acl_index=acl_index) if acl: return acl[0].tag @@ -147,11 +147,11 @@ def _get_formatted_output_interfaces(vpp, interfaces): return tabulate(data_entries, headers=headers, tablefmt='simple') -def _get_formatted_output_macip_interfaces(vpp, interfaces): +def _get_formatted_output_mac_interfaces(vpp, interfaces): data_entries = [] for interface in interfaces: name = vpp.get_interface_name(interface.get('sw_if_index')) - acl = _get_macip_acl_tag_by_index(vpp, int(interface.get('acls')[0])) + acl = _get_mac_acl_tag_by_index(vpp, int(interface.get('acls')[0])) data_entries.append([name, acl]) headers = ['Interface', 'ACL'] @@ -218,7 +218,7 @@ def _get_formatted_output_acls(acls_list): print('\n') -def _get_formatted_output_macip_acls(acls_list): +def _get_formatted_output_mac_acls(acls_list): conf = Config() for acl in acls_list: @@ -230,7 +230,7 @@ def _get_formatted_output_macip_acls(acls_list): f'MACIP ACL "tag-name {tag}" acl_index {acl_index}\n' ) - path = ['vpp', 'acl', 'macip', 'tag-name', tag, 'rule'] + path = ['vpp', 'acl', 'mac', 'tag-name', tag, 'rule'] conf_rules = conf.list_nodes(path) data_entries = [] for rule_index, rule in enumerate(rules): @@ -274,8 +274,8 @@ def show_ip_acls(raw: bool, tag_name: typing.Optional[str]): return _get_formatted_output_acls(acls) -@_verify('macip') -def show_macip_acls(raw: bool, tag_name: typing.Optional[str]): +@_verify('mac') +def show_mac_acls(raw: bool, tag_name: typing.Optional[str]): vpp = VPPControl() acls_dump = vpp.api.macip_acl_dump(acl_index=NO_ACL_INDEX) acls: list[dict] = _get_raw_output_acls(acls_dump) @@ -287,7 +287,7 @@ def show_macip_acls(raw: bool, tag_name: typing.Optional[str]): return acls else: - return _get_formatted_output_macip_acls(acls) + return _get_formatted_output_mac_acls(acls) @_verify('ip') @@ -303,8 +303,8 @@ def show_interfaces(raw: bool): return _get_formatted_output_interfaces(vpp, interfaces) -@_verify('macip') -def show_macip_interfaces(raw: bool): +@_verify('mac') +def show_mac_interfaces(raw: bool): vpp = VPPControl() interfaces_dump = vpp.api.macip_acl_interface_list_dump() interfaces: list[dict] = _get_raw_output_interfaces(interfaces_dump) @@ -313,7 +313,7 @@ def show_macip_interfaces(raw: bool): return interfaces else: - return _get_formatted_output_macip_interfaces(vpp, interfaces) + return _get_formatted_output_mac_interfaces(vpp, interfaces) @_verify('no_target') @@ -324,9 +324,9 @@ def show_all_acls(raw: bool): if conf.exists(path + ['ip']): ip_acls = show_ip_acls(raw, tag_name=None) acls_all['ip'] = ip_acls - if conf.exists(path + ['macip']): - macip_acls = show_macip_acls(raw, tag_name=None) - acls_all['macip'] = macip_acls + if conf.exists(path + ['mac']): + mac_acls = show_mac_acls(raw, tag_name=None) + acls_all['mac'] = mac_acls if raw: return acls_all |
