@@ -133,15 +133,7 @@ int parse_ospf_areas(sr_session_ctx_t *session, struct lyd_node *areas, FILE *fp
133133
134134int 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" );
0 commit comments