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
)
51 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
53 vty_out (vty
, " Zebra packet%s debugging is on%s",
54 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
59 if (IS_ZEBRA_DEBUG_SEND
)
60 vty_out (vty
, " Zebra packet send%s debugging is on%s",
61 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
64 vty_out (vty
, " Zebra packet receive%s debugging is on%s",
65 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
70 if (IS_ZEBRA_DEBUG_KERNEL
)
71 vty_out (vty
, " Zebra kernel debugging is on%s", VTY_NEWLINE
);
72 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
73 vty_out (vty
, " Zebra kernel netlink message dumps (send) are on%s", VTY_NEWLINE
);
74 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
75 vty_out (vty
, " Zebra kernel netlink message dumps (recv) are on%s", VTY_NEWLINE
);
77 /* Check here using flags as the 'macro' does an OR */
78 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
79 vty_out (vty
, " Zebra RIB debugging is on%s", VTY_NEWLINE
);
80 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
81 vty_out (vty
, " Zebra RIB detailed debugging is on%s", VTY_NEWLINE
);
83 if (IS_ZEBRA_DEBUG_FPM
)
84 vty_out (vty
, " Zebra FPM debugging is on%s", VTY_NEWLINE
);
85 if (IS_ZEBRA_DEBUG_NHT
)
86 vty_out (vty
, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE
);
87 if (IS_ZEBRA_DEBUG_MPLS
)
88 vty_out (vty
, " Zebra MPLS debugging is on%s", VTY_NEWLINE
);
89 if (IS_ZEBRA_DEBUG_PW
)
90 vty_out (vty
, " Zebra pseudowire debugging is on%s", VTY_NEWLINE
);
95 DEFUN (debug_zebra_events
,
96 debug_zebra_events_cmd
,
99 "Zebra configuration\n"
100 "Debug option set for zebra events\n")
102 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
106 DEFUN (debug_zebra_nht
,
110 "Zebra configuration\n"
111 "Debug option set for zebra next hop tracking\n")
113 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
117 DEFUN (debug_zebra_mpls
,
118 debug_zebra_mpls_cmd
,
121 "Zebra configuration\n"
122 "Debug option set for zebra MPLS LSPs\n")
124 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
128 DEFUN (debug_zebra_pw
,
130 "[no] debug zebra pseudowires",
131 "Negate a command or set its defaults\n"
133 "Zebra configuration\n"
134 "Debug option set for zebra pseudowires\n")
136 if (strmatch (argv
[0]->text
, "no"))
137 UNSET_FLAG (zebra_debug_pw
, ZEBRA_DEBUG_PW
);
139 SET_FLAG (zebra_debug_pw
, ZEBRA_DEBUG_PW
);
143 DEFUN (debug_zebra_packet
,
144 debug_zebra_packet_cmd
,
145 "debug zebra packet [<recv|send>] [detail]",
147 "Zebra configuration\n"
148 "Debug option set for zebra packet\n"
149 "Debug option set for receive packet\n"
150 "Debug option set for send packet\n"
151 "Debug option set for detailed info\n")
154 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
156 if (argv_find (argv
, argc
, "send", &idx
))
157 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
159 if (argv_find (argv
, argc
, "recv", &idx
))
160 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
162 if (argv_find (argv
, argc
, "detail", &idx
))
163 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
165 if (!(zebra_debug_packet
& ZEBRA_DEBUG_SEND
& ZEBRA_DEBUG_RECV
))
167 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
168 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
173 DEFUN (debug_zebra_kernel
,
174 debug_zebra_kernel_cmd
,
175 "debug zebra kernel",
177 "Zebra configuration\n"
178 "Debug option set for zebra between kernel interface\n")
180 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
184 DEFUN (debug_zebra_kernel_msgdump
,
185 debug_zebra_kernel_msgdump_cmd
,
186 "debug zebra kernel msgdump [<recv|send>]",
188 "Zebra configuration\n"
189 "Debug option set for zebra between kernel interface\n"
190 "Dump raw netlink messages, sent and received\n"
191 "Dump raw netlink messages received\n"
192 "Dump raw netlink messages sent\n")
195 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
196 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
197 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
198 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
203 DEFUN (debug_zebra_rib
,
207 "Zebra configuration\n"
208 "Debug RIB events\n")
210 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
214 DEFUN (debug_zebra_rib_detailed
,
215 debug_zebra_rib_detailed_cmd
,
216 "debug zebra rib detailed",
218 "Zebra configuration\n"
222 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
226 DEFUN (debug_zebra_fpm
,
230 "Zebra configuration\n"
231 "Debug zebra FPM events\n")
233 SET_FLAG (zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
237 DEFUN (no_debug_zebra_events
,
238 no_debug_zebra_events_cmd
,
239 "no debug zebra events",
242 "Zebra configuration\n"
243 "Debug option set for zebra events\n")
245 zebra_debug_event
= 0;
249 DEFUN (no_debug_zebra_nht
,
250 no_debug_zebra_nht_cmd
,
251 "no debug zebra nht",
254 "Zebra configuration\n"
255 "Debug option set for zebra next hop tracking\n")
261 DEFUN (no_debug_zebra_mpls
,
262 no_debug_zebra_mpls_cmd
,
263 "no debug zebra mpls",
266 "Zebra configuration\n"
267 "Debug option set for zebra MPLS LSPs\n")
269 zebra_debug_mpls
= 0;
273 DEFUN (no_debug_zebra_packet
,
274 no_debug_zebra_packet_cmd
,
275 "no debug zebra packet [<recv|send>]",
278 "Zebra configuration\n"
279 "Debug option set for zebra packet\n"
280 "Debug option set for receive packet\n"
281 "Debug option set for send packet\n")
284 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
285 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
286 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
287 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
291 DEFUN (no_debug_zebra_kernel
,
292 no_debug_zebra_kernel_cmd
,
293 "no debug zebra kernel",
296 "Zebra configuration\n"
297 "Debug option set for zebra between kernel interface\n")
299 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
303 DEFUN (no_debug_zebra_kernel_msgdump
,
304 no_debug_zebra_kernel_msgdump_cmd
,
305 "no debug zebra kernel msgdump [<recv|send>]",
308 "Zebra configuration\n"
309 "Debug option set for zebra between kernel interface\n"
310 "Dump raw netlink messages, sent and received\n"
311 "Dump raw netlink messages received\n"
312 "Dump raw netlink messages sent\n")
315 if (argc
== 5 || argv_find (argv
, argc
, "recv", &idx
))
316 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
317 if (argc
== 5 || argv_find (argv
, argc
, "send", &idx
))
318 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
323 DEFUN (no_debug_zebra_rib
,
324 no_debug_zebra_rib_cmd
,
325 "no debug zebra rib",
328 "Zebra configuration\n"
335 DEFUN (no_debug_zebra_rib_detailed
,
336 no_debug_zebra_rib_detailed_cmd
,
337 "no debug zebra rib detailed",
340 "Zebra configuration\n"
344 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
348 DEFUN (no_debug_zebra_fpm
,
349 no_debug_zebra_fpm_cmd
,
350 "no debug zebra fpm",
353 "Zebra configuration\n"
354 "Debug zebra FPM events\n")
361 struct cmd_node debug_node
=
364 "", /* Debug node has no interface. */
369 config_write_debug (struct vty
*vty
)
373 if (IS_ZEBRA_DEBUG_EVENT
)
375 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
378 if (IS_ZEBRA_DEBUG_PACKET
)
380 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
382 vty_out (vty
, "debug zebra packet%s%s",
383 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
389 if (IS_ZEBRA_DEBUG_SEND
)
390 vty_out (vty
, "debug zebra packet send%s%s",
391 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
394 vty_out (vty
, "debug zebra packet recv%s%s",
395 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
400 if (IS_ZEBRA_DEBUG_KERNEL
)
402 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
405 /* Check here using flags as the 'macro' does an OR */
406 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
408 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
411 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
413 vty_out (vty
, "debug zebra rib detailed%s", VTY_NEWLINE
);
416 if (IS_ZEBRA_DEBUG_FPM
)
418 vty_out (vty
, "debug zebra fpm%s", VTY_NEWLINE
);
421 if (IS_ZEBRA_DEBUG_NHT
)
423 vty_out (vty
, "debug zebra nht%s", VTY_NEWLINE
);
426 if (IS_ZEBRA_DEBUG_MPLS
)
428 vty_out (vty
, "debug zebra mpls%s", VTY_NEWLINE
);
431 if (IS_ZEBRA_DEBUG_PW
)
433 vty_out (vty
, "debug zebra pseudowires%s", VTY_NEWLINE
);
440 zebra_debug_init (void)
442 zebra_debug_event
= 0;
443 zebra_debug_packet
= 0;
444 zebra_debug_kernel
= 0;
447 zebra_debug_mpls
= 0;
450 install_node (&debug_node
, config_write_debug
);
452 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
454 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
455 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
456 install_element (ENABLE_NODE
, &debug_zebra_mpls_cmd
);
457 install_element (ENABLE_NODE
, &debug_zebra_pw_cmd
);
458 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
459 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
460 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
461 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
462 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
463 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
464 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
465 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
466 install_element (ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
467 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
468 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
469 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
470 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
471 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
472 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
474 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
475 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
476 install_element (CONFIG_NODE
, &debug_zebra_mpls_cmd
);
477 install_element (CONFIG_NODE
, &debug_zebra_pw_cmd
);
478 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
479 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
480 install_element (CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
481 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
482 install_element (CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
483 install_element (CONFIG_NODE
, &debug_zebra_fpm_cmd
);
484 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
485 install_element (CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
486 install_element (CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
487 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
488 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
489 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
490 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
491 install_element (CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
492 install_element (CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);