ospf: RFC 9129 ietf-ospf YANG support (operational state + config-write)#22058
ospf: RFC 9129 ietf-ospf YANG support (operational state + config-write)#22058lamestllama wants to merge 45 commits into
Conversation
|
Please stop closing/opening PRs for the same changes. Update your branch and force push to the same PR. |
Greptile SummaryThis PR adds RFC 9129
Confidence Score: 5/5Safe to merge; all previously-flagged blocking issues (area-ranges use-after-free, virtual-link VALIDATE bypass, atomic interface-area moves for both v2 and v3, northbound null guards, multi-instance XPath) are resolved in this version. The core correctness fixes are present and the new infrastructure (predicate-aware XPath dispatch, per-node cfg_opt_in, batch startup config, instance-aware client names) is sound. Remaining findings are defensive inconsistencies in a new helper function and a fragile relative XPath depth — neither causes wrong behaviour with today's schema. ospfd/ospf_nb_config.c (ospf_apply_interface_type missing IF_OSPF_IF_INFO guard); ospf6d/ospf6_nb_config.c (same pattern inherited for any future interface-type callback). Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as vtysh / mgmt CLI
participant mgmtd
participant BE as mgmt_be_adapter
participant ospfd
participant ospf6d
CLI->>mgmtd: set-config / commit apply
mgmtd->>BE: xpath dispatch
BE->>BE: "mgmt_be_xpath_prefix()<br/>(predicate-aware if '[' in map_path)"
alt "type='ietf-ospf:ospfv2'"
BE->>ospfd: NB_EV_VALIDATE → NB_EV_APPLY callbacks
ospfd-->>BE: NB_OK
else "type='ietf-ospf:ospfv3'"
BE->>ospf6d: NB_EV_VALIDATE → NB_EV_APPLY callbacks
ospf6d-->>BE: NB_OK
end
BE-->>mgmtd: commit result
mgmtd-->>CLI: success / error
CLI->>mgmtd: mgmt rpc clear-neighbor
mgmtd->>ospfd: ospfd_ietf_ospf_clear_neighbor_rpc
mgmtd->>ospf6d: ospf6d_ietf_ospf_clear_neighbor_rpc
Note over ospfd,ospf6d: Non-owner returns NB_OK silently
ospfd->>mgmtd: nb_notification_send(nbr-state-change)
ospfd->>mgmtd: nb_notification_send(if-state-change)
ospfd->>mgmtd: nb_notification_send(restart-status-change)
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
ospfd/ospf_nb_config.c:1386-1390
`ospf_apply_interface_type` accesses `IF_DEF_PARAMS(ifp)` and `IF_OIFS(ifp)` without first checking `IF_OSPF_IF_INFO(ifp)` for NULL. Both macros dereference `ifp->info` as a `struct ospf_if_info *`, so if the ospf if-hook hasn't yet allocated the info struct for this interface (e.g. an interface that arrived between VALIDATE and APPLY), the function will crash. The sibling helpers `ospfd_ietf_ospf_priority_update` and `ospfd_ietf_ospf_nbr_timer_update` in the same file both add this guard explicitly.
```suggestion
static void ospf_apply_interface_type(struct interface *ifp, int new_type)
{
struct ospf_if_params *params;
struct route_node *rn;
int old_type;
if (!IF_OSPF_IF_INFO(ifp) || !IF_OIFS(ifp))
return;
params = IF_DEF_PARAMS(ifp);
old_type = params->type;
```
### Issue 2 of 2
ospfd/ospf_nb_config.c:2612-2625
**Hardcoded 6-level relative XPath is fragile**
The XPath `../../../../../../areas/area/interfaces/interface/static-neighbors/neighbor[identifier='%s']` hard-codes 6 `..` hops up to the `ospf` subtree. If the YANG tree nesting ever changes (e.g. an extra grouping or augment is introduced between `ospf` and `areas`), this silently finds the wrong scope and the uniqueness check either always passes or always fails. Using `yang_dnode_get_parent(neigh, "ospf")` to first anchor to the `ospf` node and then a relative XPath like `areas/area/interfaces/interface/static-neighbors/neighbor[identifier='%s']` would be more robust.
Reviews (30): Last reviewed commit: "ospfd,ospf6d: harden OSPF notification m..." | Re-trigger Greptile |
5b9699b to
4b9886d
Compare
4b9886d to
1bfe80e
Compare
ed9b4d6 to
05b4fac
Compare
32dcdb3 to
c48c147
Compare
c1ac4db to
af790dd
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
777454f to
ada554e
Compare
e5b76ea to
2a634e7
Compare
Implement RFC 9129 spf-control path limit writes for both OSPF daemons. The callbacks map the standard leaves to FRR maximum-paths state. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Add OSPFv2 config-write support for RFC 9129 MPLS LDP IGP sync. The leaf maps to ospfd's existing LDP sync integration. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the RFC 9129 stub-router always knob for OSPFv2. The callback updates the native state used to advertise the router as non-transit. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Add config-write support for prefix suppression on OSPF interfaces. The callbacks update the existing daemon interface state that controls prefix advertisement. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement RFC 9129 auto-cost reference-bandwidth writes for both OSPF daemons. The deviation module pins enabled to true, matching FRR's runtime auto-cost behaviour. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Add OSPFv2 config-write support for the RFC 9129 MPLS TE router ID leaf. The callback maps the standard node to ospfd's traffic-engineering router-id state. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the RFC 9129 graceful-restart restarter configuration for OSPFv2 and OSPFv3. The callbacks update the native restart support, grace period and reason fields. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the RFC 9129 graceful-restart helper configuration for both OSPF daemons. The callbacks map helper enablement and strict LSA checking onto FRR helper state. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Document the RFC 9129 nodes outside this config-write slice. The list records which nodes need daemon support, deviations or later schema work. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
ospf6_route_remove_all() can trigger hooks while walking route tables. Snapshot the routes before applying removals so hook re-entry cannot invalidate the iterator being used by the removal pass. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the RFC 9129 ietf-bfd-types client-cfg-parms surface for per-interface OSPF BFD configuration. The callbacks map enablement, local multiplier, desired transmit interval and required receive interval onto the existing daemon BFD state. ospfd stores the configured parameters separately from the active BFD session options, while ospf6d embeds its BFD configuration in the interface object. Promote the needed helper entry points so both daemons can update their native state through the same YANG container apply_finish pattern. Keep `[quick]` and `[profile X]` as legacy-CLI-only forms for now. They do not have an RFC 9129 equivalent in this subtree and need a future FRR-native augment if they are to become standard northbound configuration. Convert the RFC millisecond values to the daemon-side units used by each implementation, clamp the supported interval range in the deviation module, and mark the unsupported single-interval form not-supported. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement RFC 9129 NBMA static-neighbor writes for ospfd. The model keys neighbours by area, interface and identifier, while FRR stores NBMA neighbours per OSPF instance and IPv4 address. Keep the area and interface labels in the YANG subtree but apply only the identifier, poll-interval and priority to the daemon's native neighbour entry. VALIDATE rejects duplicate identifiers across the instance because they would collapse onto the same FRR-side neighbour. Mark cost not-supported in the deviation module, since FRR has no NBMA cost knob. Leave the legacy `neighbor A.B.C.D` CLI on its direct mutation path because it is instance-level and cannot manufacture a credible RFC 9129 area or interface key. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the key-chain case of RFC 9129 per-interface authentication for OSPFv2 and OSPFv3. The callbacks map the standard key-chain leaves to the existing FRR authentication command state and rely on the RFC leafrefs to validate that the referenced key chain exists. Leave the explicit-key triplet, IPsec SA and auth-trailer-rfc branches out of this slice. They are still accepted by mgmtd where the current libyang and pyang deviation path handling cannot reliably reject the unsupported choice cases without breaking the supported key-chain case. For OSPFv3, reject key-chain writes at VALIDATE when a manual key is already configured. This matches the legacy CLI conflict rule in ospf_vty.c and keeps CLI and mgmtd writes on the same daemon contract. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Publish the shared ietf-bfd-types module information from lib. Backends that use the same standard typedefs can reuse the common module registration. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Extend the developer notes with RFC 9129 nodes that lack matching FRR daemon support or need later schema work. This records the intended branch boundary for reviewers. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Centralise repeated instance and interface callback resolution for the OSPF YANG config callbacks. Use container apply_finish for BFD and list-entry apply_finish for static-neighbors. Keep destroy callbacks away from defaulted leaves, clear both regular and NSSA ranges before area teardown, and preserve the RFC 9129 deviations for unsupported leaves. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Implement the RFC 9129 clear-neighbor and clear-database RPCs for both OSPF daemons. RPC dispatch resolves the routing protocol and optional interface before invoking the native clear operation. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Emit RFC 9129 nbr-state-change notifications from the existing OSPFv2 and OSPFv3 neighbour state transition paths. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Emit RFC 9129 if-state-change notifications from the existing OSPF interface state transition paths. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Emit RFC 9129 graceful-restart restart-status-change and restart-helper-status-change notifications from the existing graceful restart paths. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
Emit RFC 9129 if-rx-bad-packet and if-config-error notifications from the existing packet receive and configuration mismatch paths. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
956eff7 to
03c3ccf
Compare
|
@greptile[bot] review |
03c3ccf to
b822e44
Compare
|
@greptile[bot] review |
Emit the RFC 9129 NSSA translator status notification from the OSPFv2 translator path and tighten the shared notification state mappings. Use table-driven translations for neighbour, interface and graceful restart helper states while preserving the daemon-specific lifecycle, DR/BDR and graceful-restart values required by RFC 9129. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
b822e44 to
f8c37ef
Compare
|
CI:rerun |
|
@greptile[bot] review |
Overview
Adds RFC 9129
ietf-ospfYANG support for the implemented FRR-backedOSPFv2 and OSPFv3 subset through mgmtd.
The implementation is anchored on the IETF model. FRR-specific behaviour stays
on the existing CLI surface unless there is a concrete FRR-native augment with
callbacks.
This PR provides the OSPF YANG model integration, callback wiring, mgmtd
dispatch support needed for the shared OSPFv2/OSPFv3 subtree, RPC callbacks,
notifications, user documentation and developer notes.
Generic gRPC
ExecuteandSubscribesupport through mgmtd is handled in#22158. When #22158 is present, external gRPC clients can use the same mgmtd
frontend/backend machinery for OSPF RPCs and notifications. This PR does not
depend on #22158.
What This PR Provides
Operators get broad RFC 9129 YANG configuration, RPC and operational state
coverage for the implemented FRR-backed OSPF subset.
The supported mgmtd-facing surfaces are:
vtyshthroughmgmt set-config,mgmt rpcandmgmt commit applywith mgmtd
The OSPFv2 and OSPFv3 implementations share the RFC 9129
control-plane-protocolsubtree. Requests are routed to the correct daemon bymatching the predicated protocol entry, for example the OSPFv2 or OSPFv3
typeandnamekeys.Architecture
RFC 9129 puts OSPFv2 and OSPFv3 under the shared RFC 8349
control-plane-protocollist, distinguished bytypeandnamekeys. That isthe standard shape, but it means
ospfdandospf6dshare one schema subtreeand must receive only the requests that belong to their daemon and instance.
The series adds reusable infrastructure for that shape:
control-plane-protocol[type='ietf-ospf:ospfv2'].For multi-instance OSPFv2, backend client names are made instance-aware:
non-instanced daemons keep their existing names, while instanced daemons append
the decimal instance ID, such as
ospfd-1orospfd-2. The RFC 9129 protocolnamein instance mode is the decimal instance ID.Configuration Coverage
Per-instance leaves:
explicit-router-idpreference/{all,intra-area,inter-area,internal,external}internalmaps onto intra/inter-area distances.spf-control/pathsMULTIPATH_NUM.auto-cost/{enabled,reference-bandwidth}enabled=falseis rejected at validation.mpls/ldp/igp-syncospf6dhas no LDP/IGP-sync.mpls/te-rid/ipv4-router-idospf6dhas no MPLS-TE.graceful-restart/{enabled,restart-interval,helper-enabled,helper-strict-lsa-checking}stub-router/alwaysospf6dhas no stub-router.Per-area:
areas/arealifecyclearea/area-typenormal, stub and NSSAarea/summaryarea/default-costarea/ranges/range,advertiseandcostPer-interface:
interfaces/interfacearea attachmentinterface/costinterface/{hello,dead,retransmit}-intervalinterface/priorityinterface/mtu-ignoreinterface/transmit-delayinterface/interface-typeinterface/passiveinterface/prefix-suppressioninterface/bfd/{enabled,local-multiplier,desired-min-tx-interval,required-min-rx-interval}interface/static-neighbors/neighbor,poll-intervalandpriorityinterface/authentication/ospfv2-key-chain/ospfv3-key-chainRPCs
clear-neighborclear-databaseospf{,6}_process_reset.Notifications
nbr-state-changeospf_nsm_change/ospf6_neighbor_changehooksif-state-changeospf_ism_change/ospf6_interface_changehooksrestart-status-changenbr-restart-helper-status-changeif-rx-bad-packetif-config-errornssa-translator-status-changelsdb-{approaching-,}overflowOut of Scope
Documented in
doc/developer/ospf-yang-northbound-notes.rst.Deferred because there is no matching FRR surface, the FRR surface has a
different shape, or the RFC 9129 path needs a separate future mapping:
ospf/nsrdatabase-control/max-lsaspf-control/ietf-spf-delaynode-tag-configinterface/{enabled,multi-areas,ttl-security}ospf/enabledaddress-familyfast-reroute/lfacurrent deviation paths
Related Work
Two earlier OSPF YANG attempts shaped the choices here:
It was useful as a state-callback reference, but its paths do not map onto
the current RFC 9129 surface.
frr-ospfd.yang. It was useful as a coverage map, but most callbacks werestubs.
FRR also has an experimental YANG-module translator for mapping non-native
models onto native FRR models via deviation modules and XPath translation
tables. This PR does not use it because OSPF does not yet have a complete
callback-backed native OSPF YANG model to serve as the source of truth. RFC
9129 is implemented directly as the canonical northbound surface for the OSPF
behaviour it covers.
Documentation
doc/user/ospfd.rstanddoc/user/ospf6d.rst: supported leaves,daemon-instance naming and worked
mgmt set-config/mgmt commit applyexamples.
doc/developer/ospf-yang-northbound-notes.rst: RFC 9129 design choice,predicate-aware dispatch, startup batching, validation approach,
notification wiring and future FRR-native augment boundaries.
IETF Module Sources
ietf-ospf.yang,ietf-routing.yang,ietf-bfd-types.yang,iana-routing-types.yangandiana-bfd-types.yangare pulled from theirrespective RFCs unchanged, with the IETF Trust BSD licence text.
This follows the existing handling of
ietf-interfaces.yang,ietf-key-chain.yangandietf-routing-types.yangalready inyang/ietf/.Commit Organisation
The series is organised so that reusable infrastructure lands before the OSPF
callbacks that depend on it:
Each commit is intended to be reviewable in isolation.