summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorl0crian1 <ryan.claridge13@gmail.com>2026-08-23 21:03:29 -0400
committerl0crian1 <ryan.claridge13@gmail.com>2026-08-23 21:03:29 -0400
commit3641d61b317a6c6ef99bb2fa1a1fa348e48f934e (patch)
treed74f015f4b21d3f83dae2e19f3bf9c1b7db63fc2 /python
parent0712fac9dddb4dbfede4409867d2973ccbfb5aa2 (diff)
downloadvyos-1x-3641d61b317a6c6ef99bb2fa1a1fa348e48f934e.tar.gz
vyos-1x-3641d61b317a6c6ef99bb2fa1a1fa348e48f934e.zip
firewall: T9242: Add mac-address-mask support
- Add mac-address-mask support to firewall rules - Add smoketest for mac-address-mask
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']