diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-04-11 19:23:10 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-04-12 21:16:19 +0200 |
commit | 5d9238f1d7f8d19893537a8076031903e8fea271 (patch) | |
tree | 213fd704444a8ecdd75fc7c7b083adacab0870b4 | |
parent | 46391367806834f0f8e60f0894da6b91711d51bc (diff) | |
download | vyos-1x-5d9238f1d7f8d19893537a8076031903e8fea271.tar.gz vyos-1x-5d9238f1d7f8d19893537a8076031903e8fea271.zip |
rip: T3328: route-map to zebra/kernel can not be removed
Removing the Zebra/Linux Kernel route-map added by "set protocols rip route-map"
was not removed once applied. This was because the removal must happen within
the zebra daemon and not ripd.
-rw-r--r-- | data/templates/frr/rip.frr.tmpl | 4 | ||||
-rw-r--r-- | interface-definitions/protocols-rip.xml.in | 1 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_rip.py | 24 | ||||
-rwxr-xr-x | src/conf_mode/protocols_rip.py | 20 |
4 files changed, 41 insertions, 8 deletions
diff --git a/data/templates/frr/rip.frr.tmpl b/data/templates/frr/rip.frr.tmpl index bc92bddf9..cabc236f0 100644 --- a/data/templates/frr/rip.frr.tmpl +++ b/data/templates/frr/rip.frr.tmpl @@ -90,3 +90,7 @@ router rip {% endif %} {% include 'frr/rip_ripng.frr.j2' %} ! +{% if route_map is defined and route_map is not none %} +ip protocol rip route-map {{ route_map }} +{% endif %} +! diff --git a/interface-definitions/protocols-rip.xml.in b/interface-definitions/protocols-rip.xml.in index fd1a84bb8..4fcfcfc27 100644 --- a/interface-definitions/protocols-rip.xml.in +++ b/interface-definitions/protocols-rip.xml.in @@ -225,6 +225,7 @@ </properties> </leafNode> #include <include/rip/rip-timers.xml.i> + #include <include/route-map.xml.i> </children> </node> </children> diff --git a/smoketest/scripts/cli/test_protocols_rip.py b/smoketest/scripts/cli/test_protocols_rip.py index 3406688c5..423cd811a 100755 --- a/smoketest/scripts/cli/test_protocols_rip.py +++ b/smoketest/scripts/cli/test_protocols_rip.py @@ -57,7 +57,7 @@ class TestProtocolsRIP(VyOSUnitTestSHIM.TestCase): # Check for running process self.assertTrue(process_named_running(PROCESS_NAME)) - def test_rip(self): + def test_rip_01_parameters(self): distance = '40' network_distance = '66' metric = '8' @@ -100,7 +100,7 @@ class TestProtocolsRIP(VyOSUnitTestSHIM.TestCase): # commit changes self.cli_commit() - # Verify FRR ospfd configuration + # Verify FRR ripd configuration frrconfig = self.getFRRconfig('router rip') self.assertIn(f'router rip', frrconfig) self.assertIn(f' distance {distance}', frrconfig) @@ -127,5 +127,25 @@ class TestProtocolsRIP(VyOSUnitTestSHIM.TestCase): for proto in redistribute: self.assertIn(f' redistribute {proto} metric {metric} route-map {route_map}', frrconfig) + def test_rip_02_zebra_route_map(self): + # Implemented because of T3328 + self.cli_set(base_path + ['route-map', route_map]) + # commit changes + self.cli_commit() + + # Verify FRR configuration + zebra_route_map = f'ip protocol rip route-map {route_map}' + frrconfig = self.getFRRconfig(zebra_route_map) + self.assertIn(zebra_route_map, frrconfig) + + # Remove the route-map again + self.cli_delete(base_path + ['route-map']) + # commit changes + self.cli_commit() + + # Verify FRR configuration + frrconfig = self.getFRRconfig(zebra_route_map) + self.assertNotIn(zebra_route_map, frrconfig) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py index b48289dec..c1bf2c9dd 100755 --- a/src/conf_mode/protocols_rip.py +++ b/src/conf_mode/protocols_rip.py @@ -32,8 +32,6 @@ from vyos import frr from vyos import airbag airbag.enable() -frr_daemon = 'ripd' - def get_config(config=None): if config: conf = config @@ -101,20 +99,30 @@ def generate(rip): return None def apply(rip): + rip_daemon = 'ripd' + zebra_daemon = 'zebra' + # Save original configuration prior to starting any commit actions frr_cfg = frr.FRRConfig() - frr_cfg.load_configuration(frr_daemon) + + # The route-map used for the FIB (zebra) is part of the zebra daemon + frr_cfg.load_configuration(zebra_daemon) + frr_cfg.modify_section(r'^ip protocol rip route-map [-a-zA-Z0-9.]+$', '') + frr_cfg.commit_configuration(zebra_daemon) + + frr_cfg.load_configuration(rip_daemon) frr_cfg.modify_section(r'key chain \S+', '') frr_cfg.modify_section(r'interface \S+', '') - frr_cfg.modify_section('router rip', '') + frr_cfg.modify_section('^router rip$', '') + frr_cfg.add_before(r'(ip prefix-list .*|route-map .*|line vty)', rip['new_frr_config']) - frr_cfg.commit_configuration(frr_daemon) + frr_cfg.commit_configuration(rip_daemon) # If FRR config is blank, rerun the blank commit x times due to frr-reload # behavior/bug not properly clearing out on one commit. if rip['new_frr_config'] == '': for a in range(5): - frr_cfg.commit_configuration(frr_daemon) + frr_cfg.commit_configuration(rip_daemon) # Save configuration to /run/frr/config/frr.conf frr.save_configuration() |