@@ -45,45 +45,80 @@ Earlier OSPF northbound work is useful context for future development:
4545 * Most callbacks are TODO/no-op stubs, so it should not be transplanted
4646 wholesale.
4747
48- Implementation Plan
49- -------------------
50-
51- 1. Do not register inert FRR-native OSPF modules. ``yang/frr-ospfd.yang ``
52- remains on disk for future work, but ``ospfd `` no longer links its generated
53- schema into the daemon binary or advertises it with no callbacks behind it.
54- Add ``frr-ospfd `` or future ``frr-ospf6d `` module registrations only when
55- there is a concrete FRR-specific augment or callback to expose.
56-
57- 2. Keep ``ietf-ospf `` loaded for both daemons and map FRR behavior toward the
58- RFC 9129
59- ``/ietf-routing:routing/control-plane-protocols/control-plane-protocol/ietf-ospf:ospf ``
60- tree. The first OSPFv2 and OSPFv3 operational callbacks now expose the RFC
61- ``control-plane-protocol `` list, router-id, instance LSA counters, area
62- SPF/ABR/ASBR/LSA counters, interface list, and neighbor list with neighbor
63- address and state. The default instance name is ``default `` for both daemons.
64- The OSPFv2 interface list currently exposes the first ``ospf_interface `` per
65- interface key because RFC 9129 keys the list by interface name while FRR can
66- hold multiple OSPFv2 interface objects for different addresses on the same
67- interface.
68-
69- 3. Add mgmtd backend registration after there is at least a narrow set of real
70- callbacks or an explicitly operational-only xpath set. ``ospfd `` and
71- ``ospf6d `` register as mgmtd backend clients for
72- ``/ietf-routing:routing/control-plane-protocols/control-plane-protocol ``.
73- ``mgmtd `` also loads the RFC OSPF modules so it can parse OSPF backend
74- replies in the merged operational datastore.
75-
76- 4. Port operational callbacks from PR #18401 into the current model, beginning
77- with OSPF instance and area statistics.
78-
79- 5. Convert configuration in narrow CLI-equivalent slices. For each leaf or list,
80- move existing CLI behavior into a northbound callback and make the CLI set
81- the YANG node. ``ietf-ospf `` should be the canonical configuration tree for
82- everything RFC 9129 models; ``frr-ospfd `` and future ``frr-ospf6d `` should
83- augment only FRR-specific behavior that the RFC model does not cover.
84-
85- 6. Add FRR-native OSPFv3 YANG only when a concrete FRR-specific augment is
86- needed.
48+ FRR also has an experimental YANG module translator for mapping non-native
49+ models onto native FRR models with deviation modules and XPath translation
50+ tables. This branch does not use that mechanism because OSPF does not yet have
51+ a complete callback-backed native OSPF YANG model to serve as the source of
52+ truth. Instead, RFC 9129 is implemented directly as the canonical northbound
53+ surface for the OSPF behavior it covers.
54+
55+ Current Implementation
56+ ----------------------
57+
58+ This branch implements the RFC 9129 ``ietf-ospf `` tree directly for OSPFv2 and
59+ OSPFv3 rather than adding an FRR-native OSPF model with parallel semantics.
60+ ``yang/frr-ospfd.yang `` remains on disk for future FRR-specific OSPFv2 work,
61+ but ``ospfd `` does not link its generated schema into the daemon binary or
62+ advertise it with no callbacks behind it.
63+
64+ Both daemons load ``ietf-ospf `` and map FRR behavior toward the RFC 9129
65+ ``/ietf-routing:routing/control-plane-protocols/control-plane-protocol/ietf-ospf:ospf ``
66+ tree. OSPFv2 and OSPFv3 operational callbacks expose the RFC
67+ ``control-plane-protocol `` list, router-id, instance LSA counters, area
68+ SPF/ABR/ASBR/LSA counters, interface list, and neighbor list with neighbor
69+ address and state. The default instance name is ``default `` for normal
70+ ``ospfd `` and ``ospf6d `` instances. In ``ospfd --instance N `` daemon-instance
71+ mode, the RFC 9129 ``control-plane-protocol `` name is the decimal instance ID
72+ (``N ``), matching the legacy ``router ospf N `` CLI. The OSPFv2 interface list
73+ exposes one entry per interface key because RFC 9129 keys the list by interface
74+ name while FRR can hold multiple OSPFv2 interface objects for different
75+ addresses on the same interface.
76+
77+ ``ospfd `` and ``ospf6d `` register as mgmtd backend clients for typed
78+ ``control-plane-protocol `` entries so OSPFv2 and OSPFv3 can share the standard
79+ ``ietf-routing `` list without one daemon claiming the other daemon's instance.
80+ Instanced ``ospfd `` backends further constrain their registration with the
81+ ``name `` key so ``ospfd-1 `` and ``ospfd-2 `` receive only edits for their own
82+ RFC 9129 protocol instance.
83+ ``mgmtd `` also loads the RFC OSPF modules so it can parse OSPF backend replies
84+ in the merged operational datastore.
85+
86+ The mgmtd backend matcher treats predicates in backend registrations as
87+ ownership constraints, not as a reason to hide unfiltered list data. A query
88+ with ``type='ietf-ospf:ospfv2' `` must dispatch only to ``ospfd `` and a query
89+ with ``type='ietf-ospf:ospfv3' `` must dispatch only to ``ospf6d ``. A query that
90+ omits the ``type `` predicate, such as a request for the whole
91+ ``control-plane-protocol `` list or one of its unkeyed descendants, still
92+ dispatches to both daemons so mgmtd can merge the OSPFv2 and OSPFv3 entries.
93+ This keeps shared IETF lists usable for current OSPF and future protocol
94+ families without special-casing OSPF in mgmtd.
95+
96+ Configuration write support is intentionally limited to CLI-equivalent RFC 9129
97+ leaves. The converted leaves are router-id, preference, area lifecycle,
98+ area-type, area summary, OSPFv2 default-cost, area ranges, per-interface area
99+ attachment, interface cost, hello-interval, dead-interval, retransmit-interval,
100+ priority, mtu-ignore, interface-type, and passive. Existing CLI commands for
101+ those leaves set the same YANG nodes as mgmtd writes.
102+
103+ Direct daemon config-file loads in ``ospfd `` and ``ospf6d `` opt in to batching
104+ for the process lifetime, so cross-leaf validation can evaluate any direct
105+ daemon config-file load as one northbound transaction. This is not a
106+ startup-only temporary flag; a later ``config_from_file() `` call in these
107+ daemons has the same cross-leaf validation requirements. Other daemons keep the
108+ legacy per-line config-file behavior.
109+
110+ Remaining Scope
111+ ---------------
112+
113+ ``ietf-ospf `` remains the canonical configuration tree for everything RFC 9129
114+ models. ``frr-ospfd `` and future ``frr-ospf6d `` should augment only
115+ FRR-specific behavior that the RFC model does not cover.
116+
117+ The current config-write scope deliberately does not include redistribution,
118+ default-information-originate, virtual links, per-address OSPFv2 interface
119+ overrides, OSPFv2 NSSA translator/suppress-fa knobs, or other FRR-specific
120+ extensions outside RFC 9129. A native OSPFv3 module should be added only when
121+ there is concrete FRR-specific state or configuration to expose.
87122
88123Test Coverage
89124-------------
@@ -94,6 +129,25 @@ neighbor state. It also checks that ``ospfd`` and ``ospf6d`` register with mgmtd
94129and that mgmtd's operational xpath registry includes the RFC 9129 control-plane
95130protocol subtree.
96131
132+ The operational tests also include a targeted mgmtd dispatch check. Predicate
133+ queries for ``ietf-ospf:ospfv2 `` and ``ietf-ospf:ospfv3 `` must return exactly
134+ one protocol entry from the correct backend, and the backend subscription check
135+ must show that the other OSPF daemon was not selected. Unfiltered parent/list
136+ queries must still select both OSPF daemons. A predicate query against
137+ ``ietf-interfaces `` verifies that untyped backend registrations still match.
138+
139+ The same test file includes config-write checks for the supported OSPFv2 and
140+ OSPFv3 leaves. The tests exercise mgmtd writes, legacy CLI writes routed through
141+ YANG, negative validation paths, and cleanup after deleting and recreating an
142+ area.
143+
144+ ``tests/topotests/ospf_yang_startup_config/test_ospf_yang_startup_config.py ``
145+ checks startup config-file batching in an isolated one-router topology. Its
146+ ``r1/ospfd.conf `` places an OSPFv2 ``default-cost `` line before the stub-area
147+ line that makes it valid; startup succeeds only when the whole daemon config
148+ file is committed as one northbound transaction. ``r1/ospf6d.conf `` keeps a
149+ matching OSPFv3 stub area in the startup path.
150+
97151The test queries the merged mgmtd operational datastore rather than daemon-local
98152``show yang operational-data `` output. Zebra supplies the narrow
99153``/ietf-interfaces:interfaces/interface `` operational state needed to satisfy RFC
0 commit comments