summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2026-08-25 13:37:41 +0300
committerGitHub <noreply@github.com>2026-08-25 13:37:41 +0300
commitd4a14ce67f83062871783045c4ce98f2214888ba (patch)
tree59a687f431f49b620f7f1849d0f5d977ec937f74 /python
parent1817a4dc2f871f7b3b3f125991e41eab90bd0d64 (diff)
parent3641d61b317a6c6ef99bb2fa1a1fa348e48f934e (diff)
downloadvyos-1x-d4a14ce67f83062871783045c4ce98f2214888ba.tar.gz
vyos-1x-d4a14ce67f83062871783045c4ce98f2214888ba.zip
Merge pull request #5425 from l0crian1/mac-mask-add
firewall: T9242: Add mac-address-mask support
Diffstat (limited to 'python')
-rwxr-xr-xpython/vyos/firewall.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index 729af8c57..68ef3cac4 100755
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -170,6 +170,7 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
prefix = side[0]
side_conf = rule_conf[side]
address_mask = side_conf.get('address_mask', None)
+ mac_address_mask = side_conf.get('mac_address_mask', None)
if 'address' in side_conf:
suffix = side_conf['address']
@@ -237,10 +238,16 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
output.append(f'{ip_name} {prefix}addr {operator} @GEOIP_{geoip_prefix}{def_suffix}_{hook_name}_{fw_name}_{rule_id}')
if 'mac_address' in side_conf:
- suffix = side_conf["mac_address"]
- if suffix[0] == '!':
- suffix = f'!= {suffix[1:]}'
- output.append(f'ether {prefix}addr {suffix}')
+ suffix = side_conf['mac_address']
+ operator = ''
+ exclude = suffix[0] == '!'
+ if exclude:
+ operator = '!= '
+ suffix = suffix[1:]
+ if mac_address_mask:
+ operator = '!=' if exclude else '=='
+ operator = f'& {mac_address_mask} {operator} '
+ output.append(f'ether {prefix}addr {operator}{suffix}')
if 'port' in side_conf:
proto = rule_conf['protocol']