Skip to content

Commit 7edc3c1

Browse files
committed
confd: add support for toggling OSPF debug logs
Fixes #1281 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 19a09a8 commit 7edc3c1

File tree

4 files changed

+83
-11
lines changed

4 files changed

+83
-11
lines changed

src/confd/src/routing.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,7 @@ int parse_ospf_areas(sr_session_ctx_t *session, struct lyd_node *areas, FILE *fp
133133

134134
int parse_ospf(sr_session_ctx_t *session, struct lyd_node *ospf)
135135
{
136-
const char *static_debug = "! OSPF default debug\
137-
debug ospf bfd\n\
138-
debug ospf packet all detail\n\
139-
debug ospf ism\n\
140-
debug ospf nsm\n\
141-
debug ospf default-information\n\
142-
debug ospf nssa\n\
143-
! OSPF configuration\n";
144-
struct lyd_node *areas, *default_route;
136+
struct lyd_node *areas, *default_route, *debug;
145137
const char *router_id;
146138
int bfd_enabled = 0;
147139
int num_areas = 0;
@@ -154,7 +146,40 @@ debug ospf nssa\n\
154146
}
155147

156148
fputs(FRR_STATIC_CONFIG, fp);
157-
fputs(static_debug, fp);
149+
150+
/* Handle OSPF debug configuration */
151+
debug = lydx_get_child(ospf, "debug");
152+
if (debug) {
153+
int any_debug = 0;
154+
155+
if (lydx_get_bool(debug, "bfd")) {
156+
fputs("debug ospf bfd\n", fp);
157+
any_debug = 1;
158+
}
159+
if (lydx_get_bool(debug, "packet")) {
160+
fputs("debug ospf packet all detail\n", fp);
161+
any_debug = 1;
162+
}
163+
if (lydx_get_bool(debug, "ism")) {
164+
fputs("debug ospf ism\n", fp);
165+
any_debug = 1;
166+
}
167+
if (lydx_get_bool(debug, "nsm")) {
168+
fputs("debug ospf nsm\n", fp);
169+
any_debug = 1;
170+
}
171+
if (lydx_get_bool(debug, "default-information")) {
172+
fputs("debug ospf default-information\n", fp);
173+
any_debug = 1;
174+
}
175+
if (lydx_get_bool(debug, "nssa")) {
176+
fputs("debug ospf nssa\n", fp);
177+
any_debug = 1;
178+
}
179+
180+
if (any_debug)
181+
fputs("!\n", fp);
182+
}
158183

159184
areas = lydx_get_child(ospf, "areas");
160185
router_id = lydx_get_cattr(ospf, "explicit-router-id");

src/confd/yang/confd.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MODULES=(
2626
"ieee802-dot1q-types@2022-10-29.yang"
2727
"infix-ip@2025-11-02.yang"
2828
"infix-if-type@2025-02-12.yang"
29-
"infix-routing@2025-11-12.yang"
29+
"infix-routing@2025-12-02.yang"
3030
"ieee802-dot1ab-lldp@2022-03-15.yang"
3131
"infix-lldp@2025-05-05.yang"
3232
"infix-dhcp-common@2025-11-09.yang"

src/confd/yang/confd/infix-routing.yang

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ module infix-routing {
2323
contact "kernelkit@googlegroups.com";
2424
description "Deviations and augments for ietf-routing and ietf-ospf.";
2525

26+
revision 2025-12-02 {
27+
description "Add configurable OSPF debug logging container.
28+
Allows users to enable specific OSPF debug categories
29+
(bfd, packet, ism, nsm, default-information, nssa) for troubleshooting.
30+
All debug options default to disabled to prevent log flooding.";
31+
reference "Issue #1281";
32+
}
33+
2634
revision 2025-11-12 {
2735
description "Add area-id augmentation to OSPF local-rib routes.
2836
Add uptime, role, and interface-name augmentations to OSPF neighbor state.
@@ -306,6 +314,45 @@ module infix-routing {
306314
}
307315
}
308316
}
317+
augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf" {
318+
description "Add support for configurable OSPF debug logging.
319+
Allows users to enable specific OSPF debug categories for troubleshooting.
320+
All debug options default to disabled to prevent log flooding in
321+
production environments.";
322+
container debug {
323+
description "OSPF debug logging configuration";
324+
leaf bfd {
325+
type boolean;
326+
default false;
327+
description "Enable OSPF BFD (Bidirectional Forwarding Detection) debug messages";
328+
}
329+
leaf packet {
330+
type boolean;
331+
default false;
332+
description "Enable detailed OSPF packet debug messages (all packet types)";
333+
}
334+
leaf ism {
335+
type boolean;
336+
default false;
337+
description "Enable OSPF Interface State Machine debug messages";
338+
}
339+
leaf nsm {
340+
type boolean;
341+
default false;
342+
description "Enable OSPF Neighbor State Machine debug messages";
343+
}
344+
leaf default-information {
345+
type boolean;
346+
default false;
347+
description "Enable OSPF default route origination debug messages";
348+
}
349+
leaf nssa {
350+
type boolean;
351+
default false;
352+
description "Enable OSPF NSSA (Not-So-Stubby Area) debug messages";
353+
}
354+
}
355+
}
309356
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface" {
310357
deviate add {
311358
must "count(../../../../ospf:areas/ospf:area/ospf:interfaces/ospf:interface[ospf:name=current()/name]) <= 1" {
File renamed without changes.

0 commit comments

Comments
 (0)