Skip to content

Commit 9def1e6

Browse files
authored
Merge pull request #1297 from kernelkit/ospf-debug
Configurable support for OSPF debug
2 parents 19a09a8 + 39ffad6 commit 9def1e6

File tree

11 files changed

+432
-11
lines changed

11 files changed

+432
-11
lines changed

doc/ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ Change Log
33

44
All notable changes to the project are documented in this file.
55

6+
[v26.01.0][UNRELEASED]
7+
-------------------------
8+
9+
### Changes
10+
11+
- Add support for configurable OSPF debug logging, issue #1281. Debug options
12+
can now be enabled per category (bfd, packet, ism, nsm, default-information,
13+
nssa). All debug options are disabled by default to prevent log flooding in
14+
production environments. See the documentation for usage examples
15+
616
[v25.11.0][] - 2025-12-02
717
-------------------------
818

doc/networking.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,48 @@ routes`.
15021502

15031503
admin@example:/>
15041504

1505+
For more detailed troubleshooting, OSPF debug logging can be enabled to
1506+
capture specific protocol events. Debug messages are written to the
1507+
routing log file (`/var/log/routing`).
1508+
1509+
> [!CAUTION]
1510+
> Debug logging significantly increases log output and may impact
1511+
> performance. Only enable debug categories needed for troubleshooting,
1512+
> and disable them when done.
1513+
1514+
To enable specific OSPF debug categories:
1515+
1516+
admin@example:/> configure
1517+
admin@example:/config/> edit routing control-plane-protocol ospfv2 name default ospf debug
1518+
admin@example:/config/routing/…/ospf/debug/> set bfd true
1519+
admin@example:/config/routing/…/ospf/debug/> set nsm true
1520+
admin@example:/config/routing/…/ospf/debug/> leave
1521+
admin@example:/>
1522+
1523+
Available debug categories include:
1524+
1525+
- `bfd`: BFD (Bidirectional Forwarding Detection) events
1526+
- `packet`: Detailed packet debugging (all OSPF packets)
1527+
- `ism`: Interface State Machine events
1528+
- `nsm`: Neighbor State Machine events
1529+
- `default-information`: Default route origination
1530+
- `nssa`: Not-So-Stubby Area events
1531+
1532+
All debug options are disabled by default. Refer to the `infix-routing`
1533+
YANG model for the complete list of available debug options.
1534+
1535+
To view current debug settings:
1536+
1537+
admin@example:/> show running-config routing control-plane-protocol
1538+
1539+
To disable all debug logging, simply delete the debug settings or set
1540+
all options back to `false`:
1541+
1542+
admin@example:/> configure
1543+
admin@example:/config/> delete routing control-plane-protocol ospfv2 name default ospf debug
1544+
admin@example:/config/> leave
1545+
admin@example:/>
1546+
15051547

15061548
### View routing table
15071549

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
2727
2828
29-
"infix-routing@2025-11-12.yang"
29+
"infix-routing@2025-12-02.yang"
3030
3131
3232

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 "[email protected]";
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.

test/case/routing/Readme.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Tests verifying standard routing protocols and configuration:
99
- OSPF multi-area configuration and inter-area routing
1010
- OSPF with BFD (Bidirectional Forwarding Detection)
1111
- OSPF default route advertisement and propagation
12+
- OSPF debug logging configuration and verification
1213
- Route preference handling for OSPF routes
1314
- Route preference handling for DHCP-learned routes
1415
- Administrative distance configuration (route preference 255)
@@ -37,6 +38,10 @@ include::ospf_default_route_advertise/Readme.adoc[]
3738

3839
<<<
3940

41+
include::ospf_debug/Readme.adoc[]
42+
43+
<<<
44+
4045
include::route_pref_ospf/Readme.adoc[]
4146

4247
<<<

test/case/routing/all.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525

2626
- name: OSPF Default route advertise
2727
case: ospf_default_route_advertise/test.py
28+
29+
- name: OSPF Debug Logging
30+
case: ospf_debug/test.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.adoc

0 commit comments

Comments
 (0)