summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNicolas Fort <nicolasfort1988@gmail.com>2022-09-16 16:35:11 +0000
committerNicolas Fort <nicolasfort1988@gmail.com>2022-09-16 16:35:11 +0000
commit99155150df9ceed0be4df46351844451b0683b3b (patch)
treef9f080672486ffa2cf04e60d098b941a05f1789c /python
parentd41909874a6a7e2264e0a89928885b491efd9851 (diff)
downloadvyos-1x-99155150df9ceed0be4df46351844451b0683b3b.tar.gz
vyos-1x-99155150df9ceed0be4df46351844451b0683b3b.zip
T4699: Firewall: Add jump action in firewall rulest
Diffstat (limited to 'python')
-rw-r--r--python/vyos/firewall.py4
-rw-r--r--python/vyos/template.py7
2 files changed, 10 insertions, 1 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index b56caef71..f9b7222fd 100644
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -326,6 +326,10 @@ def parse_rule(rule_conf, fw_name, rule_id, ip_name):
if 'action' in rule_conf:
output.append(nft_action(rule_conf['action']))
+ if 'jump' in rule_conf['action']:
+ target = rule_conf['jump_target']
+ output.append(f'NAME{def_suffix}_{target}')
+
else:
output.append('return')
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 9804308c1..2bad6df06 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -548,7 +548,7 @@ def nft_rule(rule_conf, fw_name, rule_id, ip_name='ip'):
return parse_rule(rule_conf, fw_name, rule_id, ip_name)
@register_filter('nft_default_rule')
-def nft_default_rule(fw_conf, fw_name):
+def nft_default_rule(fw_conf, fw_name, ipv6=False):
output = ['counter']
default_action = fw_conf['default_action']
@@ -557,6 +557,11 @@ def nft_default_rule(fw_conf, fw_name):
output.append(f'log prefix "[{fw_name[:19]}-default-{action_suffix}]"')
output.append(nft_action(default_action))
+ if 'default_jump_target' in fw_conf:
+ target = fw_conf['default_jump_target']
+ def_suffix = '6' if ipv6 else ''
+ output.append(f'NAME{def_suffix}_{target}')
+
output.append(f'comment "{fw_name} default-action {default_action}"')
return " ".join(output)