From 104791f05d493f4001ff092717f24bafbfae28e3 Mon Sep 17 00:00:00 2001 From: Robert Navarro Date: Thu, 8 Oct 2026 19:10:20 -0700 Subject: ospf: T9448: do not render metric-type when it is the default With metric-type 2 (the CLI default), every FRR reload deletes and re-adds "default-information originate" and every "redistribute" line under "router ospf". ospfd flushes the Type-5 LSAs on the delete and re-originates them right after, so neighbours can briefly lose the external routes on commits that do not touch OSPF. ospfd and ospf6d (for redistribute) write "metric-type 1" back to the running config and print nothing for type 2, their default. The templates render "metric-type 2", so frr-reload sees a different line on every reload. frrender now adds the XML default of metric-type to the OSPF and OSPFv3 dicts as xml_default_metric_type, for the default and every VRF instance. The templates render metric-type only when it differs from that default, so the generated config matches what FRR prints back. OSPFv3 default-information keeps rendering metric-type, as ospf6d prints it for both types. Add smoketests that read the generated config and vtysh for types 2, 1 and back to 2. Rename the "ptotocol" loop variable in test_protocols_ospf.py to "protocol", which the typos check flags on any change to this file. --- python/vyos/frrender.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python') diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py index 371ea95b5..7d1401d2c 100644 --- a/python/vyos/frrender.py +++ b/python/vyos/frrender.py @@ -120,6 +120,12 @@ def get_frrender_dict(conf: Config, argv=None) -> dict: # options which we need to update into the dictionary retrieved. default_values = conf.get_config_defaults(path, key_mangling=('-', '_'), get_first_key=True, recursive=True) + # The XML default of metric-type (shared by default-information and + # redistribute) is added to the dict, the template cannot query it + # while rendering. + xml_default_metric_type = dict_search( + 'default_information.originate.metric_type', default_values + ) # We have to cleanup the default dict, as default values could enable features # which are not explicitly enabled on the CLI. Example: default-information @@ -151,6 +157,7 @@ def get_frrender_dict(conf: Config, argv=None) -> dict: del default_values['interface'][interface]['dead_interval'] ospf = config_dict_merge(default_values, ospf) + ospf['xml_default_metric_type'] = xml_default_metric_type return ospf def dict_helper_ospfv3_defaults(ospfv3, path): @@ -158,6 +165,11 @@ def get_frrender_dict(conf: Config, argv=None) -> dict: # options which we need to update into the dictionary retrieved. default_values = conf.get_config_defaults(path, key_mangling=('-', '_'), get_first_key=True, recursive=True) + # The XML default of metric-type is added to the dict, the template + # cannot query it while rendering. + xml_default_metric_type = dict_search( + 'default_information.originate.metric_type', default_values + ) # We have to cleanup the default dict, as default values could enable features # which are not explicitly enabled on the CLI. Example: default-information @@ -179,6 +191,7 @@ def get_frrender_dict(conf: Config, argv=None) -> dict: # merge in remaining default values ospfv3 = config_dict_merge(default_values, ospfv3) + ospfv3['xml_default_metric_type'] = xml_default_metric_type return ospfv3 def dict_helper_pim_defaults(pim, path): -- cgit v1.2.3