summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraapostoliuk <108394744+aapostoliuk@users.noreply.github.com>2025-05-29 15:35:09 +0300
committerGitHub <noreply@github.com>2025-05-29 14:35:09 +0200
commita439be2447f5f7e8be19c6f5b86f8dcc3d056385 (patch)
tree6b1172c4e2b313eb9d9e2e709e3b5f3dcf0c0ed8
parent3e5eb3a4bd3935a7473b84558691f77793045021 (diff)
downloadvyos-1x-a439be2447f5f7e8be19c6f5b86f8dcc3d056385.tar.gz
vyos-1x-a439be2447f5f7e8be19c6f5b86f8dcc3d056385.zip
zebra: T7349: Added importing routes from non to the kernel routing table
* zebra: T7349: Added importing routes from non to the kernel routing table Added importing routes from non to the kernel routing table. --------- Co-authored-by: Christian Breunig <christian@breunig.cc>
-rw-r--r--data/templates/frr/zebra.route-map.frr.j26
-rw-r--r--interface-definitions/system_ip.xml.in16
-rwxr-xr-xsmoketest/scripts/cli/test_system_ip.py21
-rwxr-xr-xsrc/conf_mode/system_ip.py5
4 files changed, 48 insertions, 0 deletions
diff --git a/data/templates/frr/zebra.route-map.frr.j2 b/data/templates/frr/zebra.route-map.frr.j2
index 70a810f43..0d6d01930 100644
--- a/data/templates/frr/zebra.route-map.frr.j2
+++ b/data/templates/frr/zebra.route-map.frr.j2
@@ -1,6 +1,12 @@
!
{{ 'no ' if disable_forwarding is vyos_defined }}{{ afi }} forwarding
!
+{% if import_table is vyos_defined %}
+{% for table_num, table_config in import_table.items() %}
+ip import-table {{ table_num }} {{ 'distance ' ~ table_config.distance if table_config.distance is vyos_defined }} {{ 'route-map ' ~ table_config.route_map if table_config.route_map is vyos_defined }}
+{% endfor %}
+{% endif %}
+!
{% if nht.no_resolve_via_default is vyos_defined %}
no {{ afi }} nht resolve-via-default
{% endif %}
diff --git a/interface-definitions/system_ip.xml.in b/interface-definitions/system_ip.xml.in
index b4b5092fe..f2bb5bd8a 100644
--- a/interface-definitions/system_ip.xml.in
+++ b/interface-definitions/system_ip.xml.in
@@ -17,6 +17,22 @@
#include <include/arp-ndp-table-size.xml.i>
</children>
</node>
+ <tagNode name="import-table">
+ <properties>
+ <help>Routing table for import</help>
+ <valueHelp>
+ <format>u32:1-252</format>
+ <description>Table number</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-252"/>
+ </constraint>
+ </properties>
+ <children>
+ #include <include/static/static-route-distance.xml.i>
+ #include <include/route-map.xml.i>
+ </children>
+ </tagNode>
<leafNode name="disable-forwarding">
<properties>
<help>Disable IPv4 forwarding on all interfaces</help>
diff --git a/smoketest/scripts/cli/test_system_ip.py b/smoketest/scripts/cli/test_system_ip.py
index 5b6ef2046..a5d1f7743 100755
--- a/smoketest/scripts/cli/test_system_ip.py
+++ b/smoketest/scripts/cli/test_system_ip.py
@@ -128,5 +128,26 @@ class TestSystemIP(VyOSUnitTestSHIM.TestCase):
frrconfig = self.getFRRconfig('', end='')
self.assertNotIn(f'no ip nht resolve-via-default', frrconfig)
+ def test_system_ip_import_table(self):
+ table_num = '100'
+ distance = '200'
+ route_map_in = 'foo-map-in'
+ self.cli_set(['policy', 'route-map', route_map_in, 'rule', '10', 'action', 'permit'])
+ self.cli_set(base_path + ['import-table', table_num, 'distance', distance])
+ self.cli_set(base_path + ['import-table', table_num, 'route-map', route_map_in])
+
+ self.cli_commit()
+ # Verify CLI config applied to FRR
+ frrconfig = self.getFRRconfig('', end='')
+ self.assertIn(f'ip import-table {table_num} distance {distance} route-map {route_map_in}', frrconfig)
+
+ self.cli_delete(['policy', 'route-map', route_map_in])
+
+ self.cli_delete(base_path + ['import-table'])
+ self.cli_commit()
+ # Verify CLI config removed to FRR
+ frrconfig = self.getFRRconfig('', end='')
+ self.assertNotIn(f'ip import-table {table_num} distance {distance}', frrconfig)
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/conf_mode/system_ip.py b/src/conf_mode/system_ip.py
index 7f3796168..7f8b00ceb 100755
--- a/src/conf_mode/system_ip.py
+++ b/src/conf_mode/system_ip.py
@@ -53,6 +53,11 @@ def verify(config_dict):
for protocol, protocol_options in opt['protocol'].items():
if 'route_map' in protocol_options:
verify_route_map(protocol_options['route_map'], opt)
+
+ if dict_search('import_table', opt):
+ for table_num, import_config in opt['import_table'].items():
+ if dict_search('route_map', import_config):
+ verify_route_map(import_config['route_map'], opt)
return
def generate(config_dict):