From 7edc3c19f7c63eca08018984d6e3487a7b465107 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 2 Dec 2025 13:35:56 +0100 Subject: [PATCH] confd: add support for toggling OSPF debug logs Fixes #1281 Signed-off-by: Joachim Wiberg --- src/confd/src/routing.c | 45 ++++++++++++++---- src/confd/yang/confd.inc | 2 +- src/confd/yang/confd/infix-routing.yang | 47 +++++++++++++++++++ ...-12.yang => infix-routing@2025-12-02.yang} | 0 4 files changed, 83 insertions(+), 11 deletions(-) rename src/confd/yang/confd/{infix-routing@2025-11-12.yang => infix-routing@2025-12-02.yang} (100%) diff --git a/src/confd/src/routing.c b/src/confd/src/routing.c index f1400d6c..db0797a0 100644 --- a/src/confd/src/routing.c +++ b/src/confd/src/routing.c @@ -133,15 +133,7 @@ int parse_ospf_areas(sr_session_ctx_t *session, struct lyd_node *areas, FILE *fp int parse_ospf(sr_session_ctx_t *session, struct lyd_node *ospf) { - const char *static_debug = "! OSPF default debug\ -debug ospf bfd\n\ -debug ospf packet all detail\n\ -debug ospf ism\n\ -debug ospf nsm\n\ -debug ospf default-information\n\ -debug ospf nssa\n\ -! OSPF configuration\n"; - struct lyd_node *areas, *default_route; + struct lyd_node *areas, *default_route, *debug; const char *router_id; int bfd_enabled = 0; int num_areas = 0; @@ -154,7 +146,40 @@ debug ospf nssa\n\ } fputs(FRR_STATIC_CONFIG, fp); - fputs(static_debug, fp); + + /* Handle OSPF debug configuration */ + debug = lydx_get_child(ospf, "debug"); + if (debug) { + int any_debug = 0; + + if (lydx_get_bool(debug, "bfd")) { + fputs("debug ospf bfd\n", fp); + any_debug = 1; + } + if (lydx_get_bool(debug, "packet")) { + fputs("debug ospf packet all detail\n", fp); + any_debug = 1; + } + if (lydx_get_bool(debug, "ism")) { + fputs("debug ospf ism\n", fp); + any_debug = 1; + } + if (lydx_get_bool(debug, "nsm")) { + fputs("debug ospf nsm\n", fp); + any_debug = 1; + } + if (lydx_get_bool(debug, "default-information")) { + fputs("debug ospf default-information\n", fp); + any_debug = 1; + } + if (lydx_get_bool(debug, "nssa")) { + fputs("debug ospf nssa\n", fp); + any_debug = 1; + } + + if (any_debug) + fputs("!\n", fp); + } areas = lydx_get_child(ospf, "areas"); router_id = lydx_get_cattr(ospf, "explicit-router-id"); diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index 3e102c98..c9bb5e53 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -26,7 +26,7 @@ MODULES=( "ieee802-dot1q-types@2022-10-29.yang" "infix-ip@2025-11-02.yang" "infix-if-type@2025-02-12.yang" - "infix-routing@2025-11-12.yang" + "infix-routing@2025-12-02.yang" "ieee802-dot1ab-lldp@2022-03-15.yang" "infix-lldp@2025-05-05.yang" "infix-dhcp-common@2025-11-09.yang" diff --git a/src/confd/yang/confd/infix-routing.yang b/src/confd/yang/confd/infix-routing.yang index 34224a53..3a75db09 100644 --- a/src/confd/yang/confd/infix-routing.yang +++ b/src/confd/yang/confd/infix-routing.yang @@ -23,6 +23,14 @@ module infix-routing { contact "kernelkit@googlegroups.com"; description "Deviations and augments for ietf-routing and ietf-ospf."; + revision 2025-12-02 { + description "Add configurable OSPF debug logging container. + Allows users to enable specific OSPF debug categories + (bfd, packet, ism, nsm, default-information, nssa) for troubleshooting. + All debug options default to disabled to prevent log flooding."; + reference "Issue #1281"; + } + revision 2025-11-12 { description "Add area-id augmentation to OSPF local-rib routes. Add uptime, role, and interface-name augmentations to OSPF neighbor state. @@ -306,6 +314,45 @@ module infix-routing { } } } + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf" { + description "Add support for configurable OSPF debug logging. + Allows users to enable specific OSPF debug categories for troubleshooting. + All debug options default to disabled to prevent log flooding in + production environments."; + container debug { + description "OSPF debug logging configuration"; + leaf bfd { + type boolean; + default false; + description "Enable OSPF BFD (Bidirectional Forwarding Detection) debug messages"; + } + leaf packet { + type boolean; + default false; + description "Enable detailed OSPF packet debug messages (all packet types)"; + } + leaf ism { + type boolean; + default false; + description "Enable OSPF Interface State Machine debug messages"; + } + leaf nsm { + type boolean; + default false; + description "Enable OSPF Neighbor State Machine debug messages"; + } + leaf default-information { + type boolean; + default false; + description "Enable OSPF default route origination debug messages"; + } + leaf nssa { + type boolean; + default false; + description "Enable OSPF NSSA (Not-So-Stubby Area) debug messages"; + } + } + } deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface" { deviate add { must "count(../../../../ospf:areas/ospf:area/ospf:interfaces/ospf:interface[ospf:name=current()/name]) <= 1" { diff --git a/src/confd/yang/confd/infix-routing@2025-11-12.yang b/src/confd/yang/confd/infix-routing@2025-12-02.yang similarity index 100% rename from src/confd/yang/confd/infix-routing@2025-11-12.yang rename to src/confd/yang/confd/infix-routing@2025-12-02.yang