Skip to content

Commit 2557eb4

Browse files
committed
confd: add support for toggling OSPF debug logs
Backported from origin/main 7edc3c1 Fixes #1281 Signed-off-by: Joachim Wiberg <[email protected]>
1 parent f71722c commit 2557eb4

File tree

4 files changed

+82
-11
lines changed

4 files changed

+82
-11
lines changed

src/confd/src/ietf-routing.c

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

131131
int parse_ospf(sr_session_ctx_t *session, struct lyd_node *ospf)
132132
{
133-
const char *static_debug = "! OSPF default debug\
134-
debug ospf bfd\n\
135-
debug ospf packet all detail\n\
136-
debug ospf ism\n\
137-
debug ospf nsm\n\
138-
debug ospf default-information\n\
139-
debug ospf nssa\n\
140-
! OSPF configuration\n";
141-
struct lyd_node *areas, *default_route;
133+
struct lyd_node *areas, *default_route, *debug;
142134
const char *router_id;
143135
int bfd_enabled = 0;
144136
int num_areas = 0;
@@ -151,7 +143,40 @@ debug ospf nssa\n\
151143
}
152144

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

156181
areas = lydx_get_child(ospf, "areas");
157182
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
@@ -22,7 +22,7 @@ MODULES=(
2222
2323
2424
25-
"infix-routing@2024-11-27.yang"
25+
"infix-routing@2025-12-02.yang"
2626
2727
2828

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ module infix-routing {
2020
contact "[email protected]";
2121
description "Deviations and augments for ietf-routing and ietf-ospf.";
2222

23+
revision 2025-12-02 {
24+
description "Add configurable OSPF debug logging container.
25+
Allows users to enable specific OSPF debug categories
26+
(bfd, packet, ism, nsm, default-information, nssa) for troubleshooting.
27+
All debug options default to disabled to prevent log flooding.";
28+
reference "Issue #1281";
29+
}
2330
revision 2024-11-27 {
2431
description "Deviate address-family in OSPF";
2532
reference "internal";
@@ -278,6 +285,45 @@ module infix-routing {
278285
}
279286
}
280287
}
288+
augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf" {
289+
description "Add support for configurable OSPF debug logging.
290+
Allows users to enable specific OSPF debug categories for troubleshooting.
291+
All debug options default to disabled to prevent log flooding in
292+
production environments.";
293+
container debug {
294+
description "OSPF debug logging configuration";
295+
leaf bfd {
296+
type boolean;
297+
default false;
298+
description "Enable OSPF BFD (Bidirectional Forwarding Detection) debug messages";
299+
}
300+
leaf packet {
301+
type boolean;
302+
default false;
303+
description "Enable detailed OSPF packet debug messages (all packet types)";
304+
}
305+
leaf ism {
306+
type boolean;
307+
default false;
308+
description "Enable OSPF Interface State Machine debug messages";
309+
}
310+
leaf nsm {
311+
type boolean;
312+
default false;
313+
description "Enable OSPF Neighbor State Machine debug messages";
314+
}
315+
leaf default-information {
316+
type boolean;
317+
default false;
318+
description "Enable OSPF default route origination debug messages";
319+
}
320+
leaf nssa {
321+
type boolean;
322+
default false;
323+
description "Enable OSPF NSSA (Not-So-Stubby Area) debug messages";
324+
}
325+
}
326+
}
281327
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface" {
282328
deviate add {
283329
must "count(../../../../ospf:areas/ospf:area/ospf:interfaces/ospf:interface[ospf:name=current()/name]) <= 1" {

0 commit comments

Comments
 (0)