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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 /* For debug statement. */
27 unsigned long zebra_debug_event
;
28 unsigned long zebra_debug_packet
;
29 unsigned long zebra_debug_kernel
;
30 unsigned long zebra_debug_rib
;
31 unsigned long zebra_debug_fpm
;
32 unsigned long zebra_debug_nht
;
33 unsigned long zebra_debug_mpls
;
35 DEFUN (show_debugging_zebra
,
36 show_debugging_zebra_cmd
,
37 "show debugging zebra",
39 "Debugging information\n"
40 "Zebra configuration\n")
42 vty_out (vty
, "Zebra debugging status:%s", VTY_NEWLINE
);
44 if (IS_ZEBRA_DEBUG_EVENT
)
45 vty_out (vty
, " Zebra event debugging is on%s", VTY_NEWLINE
);
47 if (IS_ZEBRA_DEBUG_PACKET
)
49 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" : "",
57 if (IS_ZEBRA_DEBUG_SEND
)
58 vty_out (vty
, " Zebra packet send%s debugging is on%s",
59 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
62 vty_out (vty
, " 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
)
71 vty_out (vty
, " Zebra kernel netlink message dumps (send) are on%s", VTY_NEWLINE
);
72 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
73 vty_out (vty
, " Zebra kernel netlink message dumps (recv) are on%s", VTY_NEWLINE
);
75 /* Check here using flags as the 'macro' does an OR */
76 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
77 vty_out (vty
, " Zebra RIB debugging is on%s", VTY_NEWLINE
);
78 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
79 vty_out (vty
, " Zebra RIB detailed debugging is on%s", VTY_NEWLINE
);
81 if (IS_ZEBRA_DEBUG_FPM
)
82 vty_out (vty
, " Zebra FPM debugging is on%s", VTY_NEWLINE
);
83 if (IS_ZEBRA_DEBUG_NHT
)
84 vty_out (vty
, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE
);
85 if (IS_ZEBRA_DEBUG_MPLS
)
86 vty_out (vty
, " Zebra MPLS debugging is on%s", VTY_NEWLINE
);
91 DEFUN (debug_zebra_events
,
92 debug_zebra_events_cmd
,
95 "Zebra configuration\n"
96 "Debug option set for zebra events\n")
98 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
102 DEFUN (debug_zebra_nht
,
106 "Zebra configuration\n"
107 "Debug option set for zebra next hop tracking\n")
109 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
113 DEFUN (debug_zebra_mpls
,
114 debug_zebra_mpls_cmd
,
117 "Zebra configuration\n"
118 "Debug option set for zebra MPLS LSPs\n")
120 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
124 DEFUN (debug_zebra_packet
,
125 debug_zebra_packet_cmd
,
126 "debug zebra packet [<recv|send>] [detail]",
128 "Zebra configuration\n"
129 "Debug option set for zebra packet\n"
130 "Debug option set for receive packet\n"
131 "Debug option set for send packet\n"
132 "Debug option set for detailed info\n")
135 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
137 if (argv_find (argv
, argc
, "send", &idx
))
138 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
140 if (argv_find (argv
, argc
, "recv", &idx
))
141 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
143 if (argv_find (argv
, argc
, "detail", &idx
))
144 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
146 if (!(zebra_debug_packet
& ZEBRA_DEBUG_SEND
& ZEBRA_DEBUG_RECV
))
148 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
149 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
154 DEFUN (debug_zebra_kernel
,
155 debug_zebra_kernel_cmd
,
156 "debug zebra kernel",
158 "Zebra configuration\n"
159 "Debug option set for zebra between kernel interface\n")
161 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
165 DEFUN (debug_zebra_kernel_msgdump
,
166 debug_zebra_kernel_msgdump_cmd
,
167 "debug zebra kernel msgdump [<recv|send>]",
169 "Zebra configuration\n"
170 "Debug option set for zebra between kernel interface\n"
171 "Dump raw netlink messages, sent and received\n"
172 "Dump raw netlink messages received\n"
173 "Dump raw netlink messages sent\n")
176 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
177 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
178 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
179 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
184 DEFUN (debug_zebra_rib
,
188 "Zebra configuration\n"
189 "Debug RIB events\n")
191 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
195 DEFUN (debug_zebra_rib_detailed
,
196 debug_zebra_rib_detailed_cmd
,
197 "debug zebra rib detailed",
199 "Zebra configuration\n"
203 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
207 DEFUN (debug_zebra_fpm
,
211 "Zebra configuration\n"
212 "Debug zebra FPM events\n")
214 SET_FLAG (zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
218 DEFUN (no_debug_zebra_events
,
219 no_debug_zebra_events_cmd
,
220 "no debug zebra events",
223 "Zebra configuration\n"
224 "Debug option set for zebra events\n")
226 zebra_debug_event
= 0;
230 DEFUN (no_debug_zebra_nht
,
231 no_debug_zebra_nht_cmd
,
232 "no debug zebra nht",
235 "Zebra configuration\n"
236 "Debug option set for zebra next hop tracking\n")
242 DEFUN (no_debug_zebra_mpls
,
243 no_debug_zebra_mpls_cmd
,
244 "no debug zebra mpls",
247 "Zebra configuration\n"
248 "Debug option set for zebra MPLS LSPs\n")
250 zebra_debug_mpls
= 0;
254 DEFUN (no_debug_zebra_packet
,
255 no_debug_zebra_packet_cmd
,
256 "no debug zebra packet [<recv|send>]",
259 "Zebra configuration\n"
260 "Debug option set for zebra packet\n"
261 "Debug option set for receive packet\n"
262 "Debug option set for send packet\n")
265 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
266 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
267 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
268 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
272 DEFUN (no_debug_zebra_kernel
,
273 no_debug_zebra_kernel_cmd
,
274 "no debug zebra kernel",
277 "Zebra configuration\n"
278 "Debug option set for zebra between kernel interface\n")
280 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
284 DEFUN (no_debug_zebra_kernel_msgdump
,
285 no_debug_zebra_kernel_msgdump_cmd
,
286 "no debug zebra kernel msgdump [<recv|send>]",
289 "Zebra configuration\n"
290 "Debug option set for zebra between kernel interface\n"
291 "Dump raw netlink messages, sent and received\n"
292 "Dump raw netlink messages received\n"
293 "Dump raw netlink messages sent\n")
296 if (argc
== 5 || argv_find (argv
, argc
, "recv", &idx
))
297 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
298 if (argc
== 5 || argv_find (argv
, argc
, "send", &idx
))
299 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
304 DEFUN (no_debug_zebra_rib
,
305 no_debug_zebra_rib_cmd
,
306 "no debug zebra rib",
309 "Zebra configuration\n"
316 DEFUN (no_debug_zebra_rib_detailed
,
317 no_debug_zebra_rib_detailed_cmd
,
318 "no debug zebra rib detailed",
321 "Zebra configuration\n"
325 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
329 DEFUN (no_debug_zebra_fpm
,
330 no_debug_zebra_fpm_cmd
,
331 "no debug zebra fpm",
334 "Zebra configuration\n"
335 "Debug zebra FPM events\n")
342 struct cmd_node debug_node
=
345 "", /* Debug node has no interface. */
350 config_write_debug (struct vty
*vty
)
354 if (IS_ZEBRA_DEBUG_EVENT
)
356 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
359 if (IS_ZEBRA_DEBUG_PACKET
)
361 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
363 vty_out (vty
, "debug zebra packet%s%s",
364 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
370 if (IS_ZEBRA_DEBUG_SEND
)
371 vty_out (vty
, "debug zebra packet send%s%s",
372 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
375 vty_out (vty
, "debug zebra packet recv%s%s",
376 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
381 if (IS_ZEBRA_DEBUG_KERNEL
)
383 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
386 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
388 vty_out (vty
, "debug zebra kernel msgdump recv%s", VTY_NEWLINE
);
391 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
393 vty_out (vty
, "debug zebra kernel msgdump send%s", VTY_NEWLINE
);
396 /* Check here using flags as the 'macro' does an OR */
397 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
399 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
402 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
)
409 vty_out (vty
, "debug zebra fpm%s", VTY_NEWLINE
);
412 if (IS_ZEBRA_DEBUG_NHT
)
414 vty_out (vty
, "debug zebra nht%s", VTY_NEWLINE
);
417 if (IS_ZEBRA_DEBUG_MPLS
)
419 vty_out (vty
, "debug zebra mpls%s", VTY_NEWLINE
);
426 zebra_debug_init (void)
428 zebra_debug_event
= 0;
429 zebra_debug_packet
= 0;
430 zebra_debug_kernel
= 0;
433 zebra_debug_mpls
= 0;
435 install_node (&debug_node
, config_write_debug
);
437 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
439 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
440 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
441 install_element (ENABLE_NODE
, &debug_zebra_mpls_cmd
);
442 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
443 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
444 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
445 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
446 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
447 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
448 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
449 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
450 install_element (ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
451 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
452 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
453 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
454 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
455 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
456 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
458 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
459 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
460 install_element (CONFIG_NODE
, &debug_zebra_mpls_cmd
);
461 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
462 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
463 install_element (CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
464 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
465 install_element (CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
466 install_element (CONFIG_NODE
, &debug_zebra_fpm_cmd
);
467 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
468 install_element (CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
469 install_element (CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
470 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
471 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
472 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
473 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
474 install_element (CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
475 install_element (CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);