summaryrefslogtreecommitdiff
path: root/python/vyos/firewall.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-07-30 08:10:24 +0200
committerGitHub <noreply@github.com>2024-07-30 08:10:24 +0200
commit8b0f36ea908f12525512b7408e60da9508fcd6bd (patch)
tree5228b3ef3c66fd6fa78678d71b5b4ef1d8c7dde3 /python/vyos/firewall.py
parentad0acad65051a449432f882edb60246cdfeeb8e5 (diff)
parent9b99a01653e3315b1abc9ef98824ca71bd283047 (diff)
downloadveeos-1x-8b0f36ea908f12525512b7408e60da9508fcd6bd.tar.gz
veeos-1x-8b0f36ea908f12525512b7408e60da9508fcd6bd.zip
Merge pull request #3740 from talmakion/feature/T6430-vrf-direct
pbr: T6430: Allow forwarding into VRFs by name as well as route table IDs
Diffstat (limited to 'python/vyos/firewall.py')
-rw-r--r--python/vyos/firewall.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/vyos/firewall.py b/python/vyos/firewall.py
index 40399f481..facd498ca 100644
--- a/python/vyos/firewall.py
+++ b/python/vyos/firewall.py
@@ -30,6 +30,9 @@ from vyos.utils.dict import dict_search_args
from vyos.utils.dict import dict_search_recursive
from vyos.utils.process import cmd
from vyos.utils.process import run
+from vyos.utils.network import get_vrf_tableid
+from vyos.defaults import rt_global_table
+from vyos.defaults import rt_global_vrf
# Conntrack
def conntrack_required(conf):
@@ -473,11 +476,20 @@ def parse_rule(rule_conf, hook, fw_name, rule_id, ip_name):
if 'mark' in rule_conf['set']:
mark = rule_conf['set']['mark']
output.append(f'meta mark set {mark}')
+ if 'vrf' in rule_conf['set']:
+ set_table = True
+ vrf_name = rule_conf['set']['vrf']
+ if vrf_name == 'default':
+ table = rt_global_vrf
+ else:
+ # NOTE: VRF->table ID lookup depends on the VRF iface already existing.
+ table = get_vrf_tableid(vrf_name)
if 'table' in rule_conf['set']:
set_table = True
table = rule_conf['set']['table']
if table == 'main':
- table = '254'
+ table = rt_global_table
+ if set_table:
mark = 0x7FFFFFFF - int(table)
output.append(f'meta mark set {mark}')
if 'tcp_mss' in rule_conf['set']: