Skip to content

Commit ad59bc0

Browse files
committed
Refine FortiOS OSPF GR handling
1 parent 3efab53 commit ad59bc0

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

docs/caveats.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,6 @@ Device-specific parameters:
353353
* FortiOS accepts the graceful restart timers in the 1-3600 second range. A value of 0 (allowed by the _netlab_ schema) is rejected by the device during configuration deployment.
354354
* Enabling graceful restart on any BGP neighbor also enables the global FortiOS **graceful-restart** switch, which preserves the forwarding state across a routing restart. Advertising the capability without it would announce forwarding-state preservation the device does not deliver.
355355

356-
OSPF graceful restart (**ospf.gr**):
357-
358-
* FortiOS enables OSPF graceful restart with a single `set restart-mode graceful-restart` keyword in each of its two OSPF processes — `config router ospf` (OSPFv2) and `config router ospf6` (OSPFv3), which _netlab_ addresses as the IPv4 and IPv6 address families of its OSPF module. That one switch makes the device both a restarting router and a helper; the two roles cannot be configured independently.
359-
* Because the roles are coupled, _netlab_ rejects two combinations on FortiOS: enabling **ospf.gr.helper** without **ospf.gr.restart** (FortiOS cannot act as a helper without also promising to preserve its own forwarding state across a restart), and enabling **ospf.gr.restart** while explicitly disabling **ospf.gr.helper**. A node that enables **ospf.gr.restart** therefore also acts as a graceful-restart helper.
360-
* **ospf.gr.restart.grace_period** maps to the FortiOS **restart-period** keyword (range 1-3600 seconds, device default 120) — the grace period the restarting router advertises in its Grace-LSA (RFC 3623 for OSPFv2, RFC 5187 for OSPFv3). **ospf.gr.helper.grace_period** has no standard counterpart: those RFCs define only the restarting router's grace period, not a helper-side limit, so it is an FRR-specific extension (FRR's **supported-grace-time**) with nothing to map to on FortiOS, and it is not rendered.
361-
362356
Device configuration:
363357

364358
* Use a recent version of Ansible and **fortinet.fortios** Ansible Galaxy collection (version 2.3.6 or later)

netsim/devices/fortios.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,38 @@ def check_bgp_gr_restart_time(node: Box) -> None:
2323

2424

2525
def check_ospf_gr(node: Box) -> None:
26-
"""
27-
FortiOS drives OSPF graceful restart from a single 'set restart-mode graceful-restart'
28-
keyword per address family. That switch makes the device both a restarting router and a
29-
helper; the two roles cannot be configured independently. Reject the combinations the
30-
device cannot honour, leaving the restart role (which a helper rides along with) to render.
31-
"""
3226
for o_data,_,vname in _routing.rp_data(node,'ospf'):
3327
gr = o_data.get('gr',None)
34-
restart_on = isinstance(gr,dict) and 'restart' in gr # restart role explicitly enabled
35-
helper_on = isinstance(gr,dict) and 'helper' in gr # helper role explicitly enabled
36-
helper_off = removed_attributes(o_data,'gr.helper') # helper role explicitly disabled
28+
if not isinstance(gr,dict):
29+
continue
30+
31+
restart_on = 'restart' in gr
32+
helper_on = 'helper' in gr
33+
helper_off = removed_attributes(o_data,'gr.helper')
3734
vrf_info = f' in VRF {vname}' if vname else ''
3835

39-
if helper_on and not restart_on: # Helper without restart: FortiOS would
40-
log.error( # ... have to make the restart promise too
36+
# FortiOS has one OSPF GR switch. Restart implies helper on FortiOS,
37+
# but helper-only input must not enable forwarding-state preservation.
38+
if helper_on and not restart_on:
39+
log.error(
4140
f'FortiOS cannot enable the OSPF graceful-restart helper role without restart '
4241
f'(set ospf.gr.restart) on node {node.name}{vrf_info}',
4342
log.IncorrectValue,
4443
'fortios')
45-
elif restart_on and helper_off: # Restart with helper explicitly off:
46-
log.error( # ... the two roles share one switch
44+
elif restart_on and helper_off:
45+
log.error(
4746
f'FortiOS cannot enable OSPF graceful-restart restart while ospf.gr.helper is disabled '
4847
f'on node {node.name}{vrf_info}',
4948
log.IncorrectValue,
5049
'fortios')
5150

51+
helper_data = gr.get('helper',{})
52+
if isinstance(helper_data,dict) and 'grace_period' in helper_data:
53+
log.warning(
54+
text=f'FortiOS cannot limit OSPF graceful-restart helper grace period on node {node.name}{vrf_info}',
55+
flag='gr_helper_grace',
56+
module='ospf')
57+
5258

5359
class FortiOS(_Quirks):
5460

netsim/modules/ospf.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ features:
113113

114114
warnings:
115115
inactive: True
116+
gr_helper_grace: True

0 commit comments

Comments
 (0)