2 * Zebra debug related function
3 * Copyright (C) 1999 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 /* For debug statement. */
28 unsigned long zebra_debug_event
;
29 unsigned long zebra_debug_packet
;
30 unsigned long zebra_debug_kernel
;
31 unsigned long zebra_debug_rib
;
32 unsigned long zebra_debug_fpm
;
33 unsigned long zebra_debug_nht
;
34 unsigned long zebra_debug_mpls
;
35 unsigned long zebra_debug_pw
;
37 DEFUN (show_debugging_zebra
,
38 show_debugging_zebra_cmd
,
39 "show debugging zebra",
41 "Debugging information\n"
42 "Zebra configuration\n")
44 vty_out(vty
, "Zebra debugging status:%s", VTY_NEWLINE
);
46 if (IS_ZEBRA_DEBUG_EVENT
)
47 vty_out(vty
, " Zebra event debugging is on%s", VTY_NEWLINE
);
49 if (IS_ZEBRA_DEBUG_PACKET
) {
50 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
51 vty_out(vty
, " Zebra packet%s debugging is on%s",
52 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
55 if (IS_ZEBRA_DEBUG_SEND
)
57 " Zebra packet send%s debugging is on%s",
58 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
62 " Zebra packet receive%s debugging is on%s",
63 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
68 if (IS_ZEBRA_DEBUG_KERNEL
)
69 vty_out(vty
, " Zebra kernel debugging is on%s", VTY_NEWLINE
);
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
72 " Zebra kernel netlink message dumps (send) are on%s",
74 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
76 " Zebra kernel netlink message dumps (recv) are on%s",
79 /* Check here using flags as the 'macro' does an OR */
80 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
81 vty_out(vty
, " Zebra RIB debugging is on%s", VTY_NEWLINE
);
82 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
83 vty_out(vty
, " Zebra RIB detailed debugging is on%s",
86 if (IS_ZEBRA_DEBUG_FPM
)
87 vty_out(vty
, " Zebra FPM debugging is on%s", VTY_NEWLINE
);
88 if (IS_ZEBRA_DEBUG_NHT
)
89 vty_out(vty
, " Zebra next-hop tracking debugging is on%s",
91 if (IS_ZEBRA_DEBUG_MPLS
)
92 vty_out(vty
, " Zebra MPLS debugging is on%s", VTY_NEWLINE
);
93 if (IS_ZEBRA_DEBUG_PW
)
94 vty_out(vty
, " Zebra pseudowire debugging is on%s",
100 DEFUN (debug_zebra_events
,
101 debug_zebra_events_cmd
,
102 "debug zebra events",
104 "Zebra configuration\n"
105 "Debug option set for zebra events\n")
107 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
111 DEFUN (debug_zebra_nht
,
115 "Zebra configuration\n"
116 "Debug option set for zebra next hop tracking\n")
118 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
122 DEFUN (debug_zebra_mpls
,
123 debug_zebra_mpls_cmd
,
126 "Zebra configuration\n"
127 "Debug option set for zebra MPLS LSPs\n")
129 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
133 DEFUN (debug_zebra_pw
,
135 "[no] debug zebra pseudowires",
136 "Negate a command or set its defaults\n"
138 "Zebra configuration\n"
139 "Debug option set for zebra pseudowires\n")
141 if (strmatch(argv
[0]->text
, "no"))
142 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
144 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
148 DEFUN (debug_zebra_packet
,
149 debug_zebra_packet_cmd
,
150 "debug zebra packet [<recv|send>] [detail]",
152 "Zebra configuration\n"
153 "Debug option set for zebra packet\n"
154 "Debug option set for receive packet\n"
155 "Debug option set for send packet\n"
156 "Debug option set for detailed info\n")
159 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
161 if (argv_find(argv
, argc
, "send", &idx
))
162 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
164 if (argv_find(argv
, argc
, "recv", &idx
))
165 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
167 if (argv_find(argv
, argc
, "detail", &idx
))
168 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
170 if (!(zebra_debug_packet
& ZEBRA_DEBUG_SEND
& ZEBRA_DEBUG_RECV
)) {
171 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
172 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
177 DEFUN (debug_zebra_kernel
,
178 debug_zebra_kernel_cmd
,
179 "debug zebra kernel",
181 "Zebra configuration\n"
182 "Debug option set for zebra between kernel interface\n")
184 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
188 DEFUN (debug_zebra_kernel_msgdump
,
189 debug_zebra_kernel_msgdump_cmd
,
190 "debug zebra kernel msgdump [<recv|send>]",
192 "Zebra configuration\n"
193 "Debug option set for zebra between kernel interface\n"
194 "Dump raw netlink messages, sent and received\n"
195 "Dump raw netlink messages received\n"
196 "Dump raw netlink messages sent\n")
199 if (argc
== 4 || argv_find(argv
, argc
, "recv", &idx
))
200 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
201 if (argc
== 4 || argv_find(argv
, argc
, "send", &idx
))
202 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
207 DEFUN (debug_zebra_rib
,
211 "Zebra configuration\n"
212 "Debug RIB events\n")
214 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
218 DEFUN (debug_zebra_rib_detailed
,
219 debug_zebra_rib_detailed_cmd
,
220 "debug zebra rib detailed",
222 "Zebra configuration\n"
226 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
230 DEFUN (debug_zebra_fpm
,
234 "Zebra configuration\n"
235 "Debug zebra FPM events\n")
237 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
241 DEFUN (no_debug_zebra_events
,
242 no_debug_zebra_events_cmd
,
243 "no debug zebra events",
246 "Zebra configuration\n"
247 "Debug option set for zebra events\n")
249 zebra_debug_event
= 0;
253 DEFUN (no_debug_zebra_nht
,
254 no_debug_zebra_nht_cmd
,
255 "no debug zebra nht",
258 "Zebra configuration\n"
259 "Debug option set for zebra next hop tracking\n")
265 DEFUN (no_debug_zebra_mpls
,
266 no_debug_zebra_mpls_cmd
,
267 "no debug zebra mpls",
270 "Zebra configuration\n"
271 "Debug option set for zebra MPLS LSPs\n")
273 zebra_debug_mpls
= 0;
277 DEFUN (no_debug_zebra_packet
,
278 no_debug_zebra_packet_cmd
,
279 "no debug zebra packet [<recv|send>]",
282 "Zebra configuration\n"
283 "Debug option set for zebra packet\n"
284 "Debug option set for receive packet\n"
285 "Debug option set for send packet\n")
288 if (argc
== 4 || argv_find(argv
, argc
, "send", &idx
))
289 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
290 if (argc
== 4 || argv_find(argv
, argc
, "recv", &idx
))
291 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
295 DEFUN (no_debug_zebra_kernel
,
296 no_debug_zebra_kernel_cmd
,
297 "no debug zebra kernel",
300 "Zebra configuration\n"
301 "Debug option set for zebra between kernel interface\n")
303 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
307 DEFUN (no_debug_zebra_kernel_msgdump
,
308 no_debug_zebra_kernel_msgdump_cmd
,
309 "no debug zebra kernel msgdump [<recv|send>]",
312 "Zebra configuration\n"
313 "Debug option set for zebra between kernel interface\n"
314 "Dump raw netlink messages, sent and received\n"
315 "Dump raw netlink messages received\n"
316 "Dump raw netlink messages sent\n")
319 if (argc
== 5 || argv_find(argv
, argc
, "recv", &idx
))
320 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
321 if (argc
== 5 || argv_find(argv
, argc
, "send", &idx
))
322 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
327 DEFUN (no_debug_zebra_rib
,
328 no_debug_zebra_rib_cmd
,
329 "no debug zebra rib",
332 "Zebra configuration\n"
339 DEFUN (no_debug_zebra_rib_detailed
,
340 no_debug_zebra_rib_detailed_cmd
,
341 "no debug zebra rib detailed",
344 "Zebra configuration\n"
348 UNSET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
352 DEFUN (no_debug_zebra_fpm
,
353 no_debug_zebra_fpm_cmd
,
354 "no debug zebra fpm",
357 "Zebra configuration\n"
358 "Debug zebra FPM events\n")
365 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
368 static int config_write_debug(struct vty
*vty
)
372 if (IS_ZEBRA_DEBUG_EVENT
) {
373 vty_out(vty
, "debug zebra events%s", VTY_NEWLINE
);
376 if (IS_ZEBRA_DEBUG_PACKET
) {
377 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
378 vty_out(vty
, "debug zebra packet%s%s",
379 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
383 if (IS_ZEBRA_DEBUG_SEND
)
384 vty_out(vty
, "debug zebra packet send%s%s",
385 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
388 vty_out(vty
, "debug zebra packet recv%s%s",
389 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
394 if (IS_ZEBRA_DEBUG_KERNEL
) {
395 vty_out(vty
, "debug zebra kernel%s", VTY_NEWLINE
);
398 /* Check here using flags as the 'macro' does an OR */
399 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
400 vty_out(vty
, "debug zebra rib%s", VTY_NEWLINE
);
403 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
404 vty_out(vty
, "debug zebra rib detailed%s", VTY_NEWLINE
);
407 if (IS_ZEBRA_DEBUG_FPM
) {
408 vty_out(vty
, "debug zebra fpm%s", VTY_NEWLINE
);
411 if (IS_ZEBRA_DEBUG_NHT
) {
412 vty_out(vty
, "debug zebra nht%s", VTY_NEWLINE
);
415 if (IS_ZEBRA_DEBUG_MPLS
) {
416 vty_out(vty
, "debug zebra mpls%s", VTY_NEWLINE
);
419 if (IS_ZEBRA_DEBUG_PW
) {
420 vty_out(vty
, "debug zebra pseudowires%s", VTY_NEWLINE
);
426 void zebra_debug_init(void)
428 zebra_debug_event
= 0;
429 zebra_debug_packet
= 0;
430 zebra_debug_kernel
= 0;
433 zebra_debug_mpls
= 0;
436 install_node(&debug_node
, config_write_debug
);
438 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
440 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
441 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
442 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
443 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
444 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
445 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
446 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
447 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
448 install_element(ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
449 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
450 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
451 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
452 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
453 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
454 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
455 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
456 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
457 install_element(ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
458 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
460 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
461 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
462 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
463 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
464 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
465 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
466 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
467 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
468 install_element(CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
469 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
470 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
471 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
472 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
473 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
474 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
475 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
476 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
477 install_element(CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
478 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);