summaryrefslogtreecommitdiff
path: root/python/vyos/defaults.py
diff options
context:
space:
mode:
authorAndrew Topp <atopp@aus-it.com.au>2024-07-30 13:48:18 +1000
committerAndrew Topp <atopp@aus-it.com.au>2024-07-30 13:48:18 +1000
commitadeac78ed6585b16102bd82581b54c75819714b2 (patch)
tree7111af3bb9bb6047db620f09d64fb261933efe72 /python/vyos/defaults.py
parentad0acad65051a449432f882edb60246cdfeeb8e5 (diff)
downloadvyos-1x-adeac78ed6585b16102bd82581b54c75819714b2.tar.gz
vyos-1x-adeac78ed6585b16102bd82581b54c75819714b2.zip
pbr: T6430: Allow forwarding into VRFs by name as well as route table IDs
* PBR can only target table IDs up to 200 and the previous PR to extend the range was rejected * PBR with this PR can now also target VRFs directly by name, working around targeting problems for VRF table IDs outside the overlapping 100-200 range * Validation ensures rules can't target both a table ID and a VRF name (internally they are handled the same) * Added a simple accessor (get_vrf_table_id) for runtime mapping a VRF name to table ID, based on vyos.ifconfig.interface._set_vrf_ct_zone(). It does not replace that usage, as it deliberately does not handle non-VRF interface lookups (would fail with a KeyError). * Added route table ID lookup dict, global route table and VRF table defs to vyos.defaults. Table ID references have been updated in code touched by this PR. * Added a simple smoketest to validate 'set vrf' usage in PBR rules
Diffstat (limited to 'python/vyos/defaults.py')
-rw-r--r--python/vyos/defaults.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py
index 9ccd925ce..25ee45391 100644
--- a/python/vyos/defaults.py
+++ b/python/vyos/defaults.py
@@ -50,3 +50,13 @@ commit_lock = os.path.join(directories['vyos_configdir'], '.lock')
component_version_json = os.path.join(directories['data'], 'component-versions.json')
config_default = os.path.join(directories['data'], 'config.boot.default')
+
+rt_symbolic_names = {
+ # Standard routing tables for Linux & reserved IDs for VyOS
+ 'default': 253, # Confusingly, a final fallthru, not the default.
+ 'main': 254, # The actual global table used by iproute2 unless told otherwise.
+ 'local': 255, # Special kernel loopback table.
+}
+
+rt_global_vrf = rt_symbolic_names['main']
+rt_global_table = rt_symbolic_names['main']