diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-04-11 19:36:17 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-04-12 21:16:19 +0200 |
commit | 262d119196c4366f5f330fffe85ac7399b13db7a (patch) | |
tree | f9ae5dafd19d5a99e183f9e43b178cc8bfd58a30 /src/conf_mode | |
parent | 5d9238f1d7f8d19893537a8076031903e8fea271 (diff) | |
download | vyos-1x-262d119196c4366f5f330fffe85ac7399b13db7a.tar.gz vyos-1x-262d119196c4366f5f330fffe85ac7399b13db7a.zip |
static: T3328: route-map to zebra/kernel can not be removed
Removing the Zebra/Linux Kernel route-map added by "set protocols static route-map"
was not removed once applied. This was because the removal must happen within
the zebra daemon and not staticd.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/protocols_static.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/conf_mode/protocols_static.py b/src/conf_mode/protocols_static.py index b5b2d6641..a1560afe8 100755 --- a/src/conf_mode/protocols_static.py +++ b/src/conf_mode/protocols_static.py @@ -20,6 +20,7 @@ from sys import exit from sys import argv from vyos.config import Config +from vyos.configdict import dict_merge from vyos.configverify import verify_common_route_maps from vyos.configverify import verify_vrf from vyos.template import render_to_string @@ -29,8 +30,6 @@ from vyos import frr from vyos import airbag airbag.enable() -frr_daemon = 'staticd' - def get_config(config=None): if config: conf = config @@ -49,6 +48,15 @@ def get_config(config=None): # Assign the name of our VRF context if vrf: static['vrf'] = vrf + # We also need some additional information from the config, prefix-lists + # and route-maps for instance. They will be used in verify(). + # + # XXX: one MUST always call this without the key_mangling() option! See + # vyos.configverify.verify_common_route_maps() for more information. + tmp = conf.get_config_dict(['policy']) + # Merge policy dict into "regular" config dict + static = dict_merge(tmp, static) + return static def verify(static): @@ -77,9 +85,18 @@ def generate(static): return None def apply(static): + static_daemon = 'staticd' + 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 static route-map [-a-zA-Z0-9.]+$', '') + frr_cfg.commit_configuration(zebra_daemon) + + frr_cfg.load_configuration(static_daemon) if 'vrf' in static: vrf = static['vrf'] @@ -89,13 +106,13 @@ def apply(static): frr_cfg.modify_section(r'^ipv6 route .*', '') frr_cfg.add_before(r'(interface .*|line vty)', static['new_frr_config']) - frr_cfg.commit_configuration(frr_daemon) + frr_cfg.commit_configuration(static_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 static['new_frr_config'] == '': for a in range(5): - frr_cfg.commit_configuration(frr_daemon) + frr_cfg.commit_configuration(static_daemon) # Save configuration to /run/frr/config/frr.conf frr.save_configuration() |