summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2026-02-11 10:28:14 +0200
committerNataliia Solomko <natalirs1985@gmail.com>2026-02-11 12:37:12 +0200
commiteee03985388eb43396559d551e0bf678568e89fd (patch)
tree2b39d6cea2cf9fe665c0e72b482fbd6bbf070db0 /src
parentf1ebc7820a54d7300e6b6e857be47a6dca289f54 (diff)
downloadvyos-1x-eee03985388eb43396559d551e0bf678568e89fd.tar.gz
vyos-1x-eee03985388eb43396559d551e0bf678568e89fd.zip
vpp: T8252: Change ACL node 'macip' to 'mac'
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces_ethernet.py2
-rw-r--r--src/conf_mode/vpp_acl.py48
-rw-r--r--src/migration-scripts/vpp/6-to-725
-rw-r--r--src/op_mode/vpp_acl.py34
4 files changed, 67 insertions, 42 deletions
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