diff --git a/src/confd/share/migrate/1.6/30-ospf-backbone-area-type.sh b/src/confd/share/migrate/1.6/30-ospf-backbone-area-type.sh new file mode 100755 index 00000000..55567982 --- /dev/null +++ b/src/confd/share/migrate/1.6/30-ospf-backbone-area-type.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Remove area-type from OSPF backbone area (0.0.0.0) +# The backbone area cannot be configured as stub or NSSA per RFC 2328/3101 +# Silently drop any area-type setting for area 0.0.0.0 + +file=$1 +temp=${file}.tmp + +jq ' +if .["ietf-routing:routing"]?."control-plane-protocols"?."control-plane-protocol" then + .["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol" |= map( + if .["ietf-ospf:ospf"]?.areas?.area then + .["ietf-ospf:ospf"].areas.area |= map( + if (.["area-id"] == "0.0.0.0") and .["area-type"] then + # Remove area-type from backbone area + del(.["area-type"]) + else + . + end + ) + else + . + end + ) +else + . +end +' "$file" > "$temp" && mv "$temp" "$file" diff --git a/src/confd/share/migrate/1.6/Makefile.am b/src/confd/share/migrate/1.6/Makefile.am index c3a250a5..fdb2b6a0 100644 --- a/src/confd/share/migrate/1.6/Makefile.am +++ b/src/confd/share/migrate/1.6/Makefile.am @@ -1,3 +1,4 @@ migratedir = $(pkgdatadir)/migrate/1.6 dist_migrate_DATA = 10-dhcp-client-to-ipv4.sh \ - 20-autoconf-to-presence.sh + 20-autoconf-to-presence.sh \ + 30-ospf-backbone-area-type.sh diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index bc747889..c771153d 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -22,7 +22,7 @@ MODULES=( "ieee802-dot1q-types@2022-10-29.yang" "infix-ip@2025-11-02.yang" "infix-if-type@2025-02-12.yang" - "infix-routing@2024-11-27.yang" + "infix-routing@2025-11-10.yang" "ieee802-dot1ab-lldp@2022-03-15.yang" "infix-lldp@2025-05-05.yang" "infix-dhcp-common@2025-01-29.yang" diff --git a/src/confd/yang/confd/infix-routing.yang b/src/confd/yang/confd/infix-routing.yang index effdcff5..2856c5f4 100644 --- a/src/confd/yang/confd/infix-routing.yang +++ b/src/confd/yang/confd/infix-routing.yang @@ -20,6 +20,10 @@ module infix-routing { contact "kernelkit@googlegroups.com"; description "Deviations and augments for ietf-routing and ietf-ospf."; + revision 2025-11-10 { + description "Add must constraint to prevent backbone area as stub/NSSA"; + reference "RFC 2328, RFC 3101"; + } revision 2024-11-27 { description "Deviate address-family in OSPF"; reference "internal"; @@ -348,6 +352,19 @@ module infix-routing { } /* OSPF Area */ + deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:area-type" { + deviate add { + must "(../ospf:area-id != '0.0.0.0') or " + + "(derived-from-or-self(., 'ospf:normal-area'))" { + error-message "Area 0.0.0.0 (backbone) cannot be configured as " + + "stub or NSSA."; + description + "The backbone area (area 0.0.0.0) must be a normal area. " + + "It cannot be configured as a stub area or NSSA as per " + + "RFC 2328 and RFC 3101."; + } + } + } deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:virtual-links" { deviate not-supported; } diff --git a/src/confd/yang/confd/infix-routing@2024-11-27.yang b/src/confd/yang/confd/infix-routing@2025-11-10.yang similarity index 100% rename from src/confd/yang/confd/infix-routing@2024-11-27.yang rename to src/confd/yang/confd/infix-routing@2025-11-10.yang