From c9e1a3b357f2e145a85ff4f7e92ee680937561a3 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 2 Feb 2021 22:57:49 +0100 Subject: ospf: T3263: support hello sub-second timer Added "set protocols ospf interface eth1 hello-multiplier " CLI command. This is mutually exclusive to "set protocols ospf interface eth1 dead-interval ". --- data/templates/frr/ospf.frr.tmpl | 3 +++ interface-definitions/include/ospf-intervals.xml.i | 12 ++++++++++++ src/conf_mode/protocols_ospf.py | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/data/templates/frr/ospf.frr.tmpl b/data/templates/frr/ospf.frr.tmpl index 37c21e146..7ca69eee6 100644 --- a/data/templates/frr/ospf.frr.tmpl +++ b/data/templates/frr/ospf.frr.tmpl @@ -31,6 +31,8 @@ interface {{ iface }} {% endif %} {% if iface_config.dead_interval is defined and iface_config.dead_interval is not none %} ip ospf dead-interval {{ iface_config.dead_interval }} +{% elif iface_config.hello_multiplier is defined and iface_config.hello_multiplier is not none %} + ip ospf dead-interval minimal hello-multiplier {{ iface_config.hello_multiplier }} {% endif %} {% if iface_config.bfd is defined %} ip ospf bfd @@ -44,6 +46,7 @@ interface {{ iface }} {% if iface_config.bandwidth is defined and iface_config.bandwidth is not none %} bandwidth {{ iface_config.bandwidth }} {% endif %} +! {% endfor %} {% endif %} ! diff --git a/interface-definitions/include/ospf-intervals.xml.i b/interface-definitions/include/ospf-intervals.xml.i index e532bd14b..d91b2bc34 100644 --- a/interface-definitions/include/ospf-intervals.xml.i +++ b/interface-definitions/include/ospf-intervals.xml.i @@ -25,6 +25,18 @@ 10 + + + Hello multiplier factor + + u32:1-10 + Number of Hellos to send each second + + + + + + Interval between retransmitting lost link state advertisements (default: 5) diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py index 866b2db62..3310fac5a 100755 --- a/src/conf_mode/protocols_ospf.py +++ b/src/conf_mode/protocols_ospf.py @@ -97,8 +97,15 @@ def get_config(config=None): default_values, ospf['area'][area]['virtual_link'][virtual_link]) if 'interface' in ospf: - default_values = defaults(base + ['interface']) for interface in ospf['interface']: + # We need to reload the defaults on every pass b/c of + # hello-multiplier dependency on dead-interval + default_values = defaults(base + ['interface']) + # If hello-multiplier is set, we need to remove the default from + # dead-interval. + if 'hello_multiplier' in ospf['interface'][interface]: + del default_values['dead_interval'] + ospf['interface'][interface] = dict_merge(default_values, ospf['interface'][interface]) @@ -120,6 +127,11 @@ def verify(ospf): if 'interface' in ospf: for interface in ospf['interface']: verify_interface_exists(interface) + # One can not use dead-interval and hello-multiplier at the same + # time. FRR will only activate the last option set via CLI. + if {'hello_multiplier', 'dead_interval'} <= set(ospf['interface'][interface]): + raise ConfigError(f'Can not use hello-multiplier and dead-interval ' \ + f'concurrently for "{interface}"!') return None -- cgit v1.2.3