Skip to content

ospf6d: implement instance shutdown command#21925

Open
rzalamena wants to merge 3 commits into
FRRouting:masterfrom
opensourcerouting:ospf6-shutdown
Open

ospf6d: implement instance shutdown command#21925
rzalamena wants to merge 3 commits into
FRRouting:masterfrom
opensourcerouting:ospf6-shutdown

Conversation

@rzalamena
Copy link
Copy Markdown
Member

This is a continuation of #21759.

Add new command to shut down the OSPFv3 instance while still retaining its configuration. It also triggers the OSPFv3 graceful restart if configured.

Also add the missing documentation for the OSPFv2 shutdown.

@frrbot frrbot Bot added documentation ospfv3 tests Topotests, make check, etc labels May 13, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR implements an administrative shutdown command for OSPFv3 instances that disables OSPF while retaining configuration, mirroring the existing OSPFv2 feature. When graceful restart is configured, the shutdown triggers Grace-LSA flooding via raw socket before tearing down adjacencies, allowing helper neighbours to continue forwarding traffic during the grace window.

  • Core logic (ospf6_top.c): ospf6_shutdown() handles both directions — shutdown disables all areas, clears the LSDB, and optionally floods Grace-LSAs via the unplanned-outage raw-socket path before disabling; no shutdown re-enables areas and reoriginates AS-External/NSSA LSAs.
  • GR integration (ospf6_gr.c/h): The enum value 3 is renamed from OSPF6_GR_SWITCH_REDUNDANT_CARD to OSPF6_GR_SWITCH_CONTROL_PROCESSOR and its raw-socket send path is activated for the shutdown case; the grace-period timer is cancelled immediately after flooding to avoid a stale callback against a fully disabled instance.
  • Tests (tests/topotests/ospf6_shutdown/): A new topotest covers plain shutdown/re-enable and GR-assisted shutdown with route-preservation checks on helper routers.

Confidence Score: 5/5

The change is safe to merge; the shutdown/re-enable paths are properly guarded against double-invocation, the grace-period timer is cancelled immediately after Grace-LSA flooding, and the hello-delay timer is cleaned up by the existing interface-disable path.

The core ospf6_shutdown() logic correctly sequences GR setup, Grace-LSA flooding, timer cancellation, area disable, and DB clear. The no-shutdown path properly re-enables areas and reoriginates redistributed routes. The only finding is a wrong RFC number in a code comment, which has no runtime effect.

ospf6d/ospf6_top.c — the RFC citation in the GR shutdown comment should reference RFC 5187 (OSPFv3) rather than RFC 3623 (OSPFv2).

Important Files Changed

Filename Overview
ospf6d/ospf6_top.c New ospf6_shutdown() function; core logic is sound but the in-code RFC citation is wrong (RFC 3623 is OSPFv2; RFC 5187 is the OSPFv3 GR reference)
ospf6d/ospf6_gr.c Adds OSPF6_GR_SWITCH_CONTROL_PROCESSOR to the raw-socket send path; change is minimal and consistent with existing OSPF6_GR_UNKNOWN_RESTART handling
ospf6d/ospf6_gr.h Renames enum value 3 from OSPF6_GR_SWITCH_REDUNDANT_CARD to OSPF6_GR_SWITCH_CONTROL_PROCESSOR (wire value unchanged, no existing callers of old name)
ospf6d/ospf6_top.h Adds OSPF6_FLAG_SHUTDOWN (0x10) flag and exports ospf6_shutdown(); no conflicts with existing flag bits
tests/topotests/ospf6_shutdown/test_ospf6_shutdown.py New topotest covering plain shutdown/re-enable and GR-assisted shutdown; verifies Grace-LSA presence, route preservation on helpers, and post-re-enable convergence

Sequence Diagram

sequenceDiagram
    participant Op as Operator
    participant R1 as R1 (ospf6d)
    participant R2 as R2 (helper)
    participant R3 as R3 (helper)

    Op->>R1: shutdown (with graceful-restart)
    R1->>R1: ospf6_gr_restart_enter(SWITCH_CONTROL_PROCESSOR)
    R1-->>R2: Grace-LSA (raw socket, allspfrouters6)
    R1-->>R3: Grace-LSA (raw socket, allspfrouters6)
    R1->>R1: "cancel t_grace_period, restart_in_progress=false"
    R1->>R1: ospf6_area_disable() → adjacencies drop
    R1->>R1: ospf6_db_clear()
    R2->>R2: Enter helper mode (forward R1 routes)
    R3->>R3: Enter helper mode (forward R1 routes)

    Op->>R1: no shutdown
    R1->>R1: ospf6_area_enable()
    R1->>R1: reoriginate AS-External LSAs
    R1-->>R2: Hello → Full adjacency
    R1-->>R3: Hello → Full adjacency
    R2->>R2: Exit helper mode
    R3->>R3: Exit helper mode
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
ospf6d/ospf6_top.c:248-254
The code comment cites RFC 3623, which is the OSPFv2 Graceful Restart specification. The OSPFv3 equivalent is RFC 5187; Section 4 of that RFC covers unplanned outages and the procedure of flooding Grace-LSAs before the instance goes down.

```suggestion
		/*
		 * RFC 5187 - Section 4 ("Unplanned Outages"):
		 * "The grace-LSAs are encapsulated in Link State Update
		 * Packets and sent out to all interfaces, even though
		 * the restarted router has no adjacencies and no
		 * knowledge of previous adjacencies".
		 */
```

Reviews (2): Last reviewed commit: "doc: OSPFv2 and OSPFv3 shutdown command" | Re-trigger Greptile

Comment thread ospf6d/ospf6_top.c Outdated
Comment thread ospf6d/ospf6_top.c Outdated
rzalamena added 3 commits May 13, 2026 11:44
Add new command to shut down the OSPFv3 instance while still retaining
its configuration. It also triggers the OSPFv3 graceful restart if
configured.

Rename the definition `OSPF_GR_SWITCH_REDUNDANT_CARD` to
`OSPF_GR_SWITCH_CONTROL_PROCESSOR` to match the RFC 3623 specification.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Test the new OSPFv3 shutdown feature. The topology tests the following
cases:
 1. Regular OSPFv3 instance shutdown
 2. OSPFv3 instance shutdown with graceful restart

The difference between the cases is that when graceful restart is
enabled the OSPFv3 instance sends a grace LSA in all OSPF enabled
interfaces so the helper routers keep the routes until the instance
is not shutdown anymore.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Document the new OSPFv2 and OSPFv3 shutdown commands.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
@rzalamena
Copy link
Copy Markdown
Member Author

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant