summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2023-10-24 19:53:24 +0100
committerGitHub <noreply@github.com>2023-10-24 19:53:24 +0100
commitcb912e98de3b17611fc5259bf755ce9eafa7ec18 (patch)
treeed39ace611c6358fea8d5d81a63c3d4a778860f9 /python
parentb15dbec9b5df507ee31f8e029c5a1c58762a6e43 (diff)
parenta9e93ef54bd38fd86268ce9e1c581a3852692280 (diff)
downloadvyos-1x-cb912e98de3b17611fc5259bf755ce9eafa7ec18.tar.gz
vyos-1x-cb912e98de3b17611fc5259bf755ce9eafa7ec18.zip
Merge pull request #2399 from nicolas-fort/T5637-sagitta
T5637: Firewall: add new rule at the end of base chains for default-a…
Diffstat (limited to 'python')
-rw-r--r--python/vyos/firewall.py11
-rw-r--r--python/vyos/template.py3
2 files changed, 11 insertions, 3 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index 7de268a00..59e02a2f1 100644
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -87,7 +87,13 @@ def nft_action(vyos_action):
def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
output = []
- def_suffix = '6' if ip_name == 'ip6' else ''
+ #def_suffix = '6' if ip_name == 'ip6' else ''
+ if ip_name == 'ip6':
+ def_suffix = '6'
+ family = 'ipv6'
+ else:
+ def_suffix = ''
+ family = 'bri' if ip_name == 'bri' else 'ipv4'
if 'state' in rule_conf and rule_conf['state']:
states = ",".join([s for s, v in rule_conf['state'].items() if v == 'enable'])
@@ -258,7 +264,8 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
if 'log' in rule_conf and rule_conf['log'] == 'enable':
action = rule_conf['action'] if 'action' in rule_conf else 'accept'
- output.append(f'log prefix "[{fw_name[:19]}-{rule_id}-{action[:1].upper()}]"')
+ #output.append(f'log prefix "[{fw_name[:19]}-{rule_id}-{action[:1].upper()}]"')
+ output.append(f'log prefix "[{family}-{hook}-{fw_name}-{rule_id}-{action[:1].upper()}]"')
if 'log_options' in rule_conf:
diff --git a/python/vyos/template.py b/python/vyos/template.py
index e167488c6..320abe256 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -582,10 +582,11 @@ def nft_rule(rule_conf, fw_hook, fw_name, rule_id, ip_name='ip'):
def nft_default_rule(fw_conf, fw_name, ipv6=False):
output = ['counter']
default_action = fw_conf['default_action']
+ family = 'ipv6' if ipv6 else 'ipv4'
if 'enable_default_log' in fw_conf:
action_suffix = default_action[:1].upper()
- output.append(f'log prefix "[{fw_name[:19]}-default-{action_suffix}]"')
+ output.append(f'log prefix "[{family}-{fw_name[:19]}-default-{action_suffix}]"')
#output.append(nft_action(default_action))
output.append(f'{default_action}')