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
;
36 DEFUN (show_debugging_zebra
,
37 show_debugging_zebra_cmd
,
38 "show debugging zebra",
40 "Debugging information\n"
41 "Zebra configuration\n")
43 vty_out (vty
, "Zebra debugging status:%s", VTY_NEWLINE
);
45 if (IS_ZEBRA_DEBUG_EVENT
)
46 vty_out (vty
, " Zebra event debugging is on%s", VTY_NEWLINE
);
48 if (IS_ZEBRA_DEBUG_PACKET
)
50 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
52 vty_out (vty
, " Zebra packet%s debugging is on%s",
53 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
58 if (IS_ZEBRA_DEBUG_SEND
)
59 vty_out (vty
, " Zebra packet send%s debugging is on%s",
60 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
63 vty_out (vty
, " Zebra packet receive%s debugging is on%s",
64 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
69 if (IS_ZEBRA_DEBUG_KERNEL
)
70 vty_out (vty
, " Zebra kernel debugging is on%s", VTY_NEWLINE
);
71 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
72 vty_out (vty
, " Zebra kernel netlink message dumps (send) are on%s", VTY_NEWLINE
);
73 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
74 vty_out (vty
, " Zebra kernel netlink message dumps (recv) are on%s", VTY_NEWLINE
);
76 /* Check here using flags as the 'macro' does an OR */
77 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
78 vty_out (vty
, " Zebra RIB debugging is on%s", VTY_NEWLINE
);
79 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
80 vty_out (vty
, " Zebra RIB detailed debugging is on%s", VTY_NEWLINE
);
82 if (IS_ZEBRA_DEBUG_FPM
)
83 vty_out (vty
, " Zebra FPM debugging is on%s", VTY_NEWLINE
);
84 if (IS_ZEBRA_DEBUG_NHT
)
85 vty_out (vty
, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE
);
86 if (IS_ZEBRA_DEBUG_MPLS
)
87 vty_out (vty
, " Zebra MPLS debugging is on%s", VTY_NEWLINE
);
92 DEFUN (debug_zebra_events
,
93 debug_zebra_events_cmd
,
96 "Zebra configuration\n"
97 "Debug option set for zebra events\n")
99 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
103 DEFUN (debug_zebra_nht
,
107 "Zebra configuration\n"
108 "Debug option set for zebra next hop tracking\n")
110 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
114 DEFUN (debug_zebra_mpls
,
115 debug_zebra_mpls_cmd
,
118 "Zebra configuration\n"
119 "Debug option set for zebra MPLS LSPs\n")
121 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
125 DEFUN (debug_zebra_packet
,
126 debug_zebra_packet_cmd
,
127 "debug zebra packet",
129 "Zebra configuration\n"
130 "Debug option set for zebra packet\n")
132 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
133 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
134 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
138 DEFUN (debug_zebra_packet_direct
,
139 debug_zebra_packet_direct_cmd
,
140 "debug zebra packet (recv|send|detail)",
142 "Zebra configuration\n"
143 "Debug option set for zebra packet\n"
144 "Debug option set for receive packet\n"
145 "Debug option set for send packet\n")
147 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
148 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
149 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
150 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
151 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
152 if (strncmp ("detail", argv
[0], strlen (argv
[0])) == 0)
153 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
157 DEFUN (debug_zebra_packet_detail
,
158 debug_zebra_packet_detail_cmd
,
159 "debug zebra packet (recv|send) detail",
161 "Zebra configuration\n"
162 "Debug option set for zebra packet\n"
163 "Debug option set for receive packet\n"
164 "Debug option set for send packet\n"
165 "Debug option set detailed information\n")
167 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
168 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
169 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
170 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
171 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
172 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
176 DEFUN (debug_zebra_kernel
,
177 debug_zebra_kernel_cmd
,
178 "debug zebra kernel",
180 "Zebra configuration\n"
181 "Debug option set for zebra between kernel interface\n")
183 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
187 DEFUN (debug_zebra_kernel_msgdump
,
188 debug_zebra_kernel_msgdump_cmd
,
189 "debug zebra kernel msgdump {recv|send}",
191 "Zebra configuration\n"
192 "Debug option set for zebra between kernel interface\n"
193 "Dump raw netlink messages, sent and received\n"
194 "Dump raw netlink messages received\n"
195 "Dump raw netlink messages sent\n")
197 if (!argv
[1] || (argv
[0] && strncmp(argv
[0], "recv", strlen(argv
[0])) == 0))
198 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
199 if (!argv
[0] || (argv
[1] && strncmp(argv
[1], "send", strlen(argv
[1])) == 0))
200 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
204 DEFUN (debug_zebra_rib
,
208 "Zebra configuration\n"
209 "Debug RIB events\n")
211 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
215 DEFUN (debug_zebra_rib_detailed
,
216 debug_zebra_rib_detailed_cmd
,
217 "debug zebra rib detailed",
219 "Zebra configuration\n"
223 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
227 DEFUN (debug_zebra_fpm
,
231 "Zebra configuration\n"
232 "Debug zebra FPM events\n")
234 SET_FLAG (zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
238 DEFUN (no_debug_zebra_events
,
239 no_debug_zebra_events_cmd
,
240 "no debug zebra events",
243 "Zebra configuration\n"
244 "Debug option set for zebra events\n")
246 zebra_debug_event
= 0;
250 DEFUN (no_debug_zebra_nht
,
251 no_debug_zebra_nht_cmd
,
252 "no debug zebra nht",
255 "Zebra configuration\n"
256 "Debug option set for zebra next hop tracking\n")
262 DEFUN (no_debug_zebra_mpls
,
263 no_debug_zebra_mpls_cmd
,
264 "no debug zebra mpls",
267 "Zebra configuration\n"
268 "Debug option set for zebra MPLS LSPs\n")
270 zebra_debug_mpls
= 0;
274 DEFUN (no_debug_zebra_packet
,
275 no_debug_zebra_packet_cmd
,
276 "no debug zebra packet",
279 "Zebra configuration\n"
280 "Debug option set for zebra packet\n")
282 zebra_debug_packet
= 0;
286 DEFUN (no_debug_zebra_packet_direct
,
287 no_debug_zebra_packet_direct_cmd
,
288 "no debug zebra packet (recv|send)",
291 "Zebra configuration\n"
292 "Debug option set for zebra packet\n"
293 "Debug option set for receive packet\n"
294 "Debug option set for send packet\n")
296 if (strncmp ("send", argv
[0], strlen (argv
[0])) == 0)
297 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
298 if (strncmp ("recv", argv
[0], strlen (argv
[0])) == 0)
299 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
303 DEFUN (no_debug_zebra_kernel
,
304 no_debug_zebra_kernel_cmd
,
305 "no debug zebra kernel",
308 "Zebra configuration\n"
309 "Debug option set for zebra between kernel interface\n")
311 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
315 DEFUN (no_debug_zebra_kernel_msgdump
,
316 no_debug_zebra_kernel_msgdump_cmd
,
317 "no debug zebra kernel msgdump {recv|send}",
319 "Zebra configuration\n"
320 "Debug option set for zebra between kernel interface\n"
321 "Dump raw netlink messages, sent and received\n"
322 "Dump raw netlink messages received\n"
323 "Dump raw netlink messages sent\n")
325 if (!argv
[1] || (argv
[0] && strncmp(argv
[0], "recv", strlen(argv
[0])) == 0))
326 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
327 if (!argv
[0] || (argv
[1] && strncmp(argv
[1], "send", strlen(argv
[1])) == 0))
328 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
332 DEFUN (no_debug_zebra_rib
,
333 no_debug_zebra_rib_cmd
,
334 "no debug zebra rib",
337 "Zebra configuration\n"
344 DEFUN (no_debug_zebra_rib_detailed
,
345 no_debug_zebra_rib_detailed_cmd
,
346 "no debug zebra rib detailed",
349 "Zebra configuration\n"
353 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
357 DEFUN (no_debug_zebra_fpm
,
358 no_debug_zebra_fpm_cmd
,
359 "no debug zebra fpm",
362 "Zebra configuration\n"
363 "Debug zebra FPM events\n")
370 struct cmd_node debug_node
=
373 "", /* Debug node has no interface. */
378 config_write_debug (struct vty
*vty
)
382 if (IS_ZEBRA_DEBUG_EVENT
)
384 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
387 if (IS_ZEBRA_DEBUG_PACKET
)
389 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
391 vty_out (vty
, "debug zebra packet%s%s",
392 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
398 if (IS_ZEBRA_DEBUG_SEND
)
399 vty_out (vty
, "debug zebra packet send%s%s",
400 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
403 vty_out (vty
, "debug zebra packet recv%s%s",
404 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
409 if (IS_ZEBRA_DEBUG_KERNEL
)
411 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
414 /* Check here using flags as the 'macro' does an OR */
415 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
417 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
420 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
422 vty_out (vty
, "debug zebra rib detailed%s", VTY_NEWLINE
);
425 if (IS_ZEBRA_DEBUG_FPM
)
427 vty_out (vty
, "debug zebra fpm%s", VTY_NEWLINE
);
430 if (IS_ZEBRA_DEBUG_MPLS
)
432 vty_out (vty
, "debug zebra mpls%s", VTY_NEWLINE
);
439 zebra_debug_init (void)
441 zebra_debug_event
= 0;
442 zebra_debug_packet
= 0;
443 zebra_debug_kernel
= 0;
446 zebra_debug_mpls
= 0;
448 install_node (&debug_node
, config_write_debug
);
450 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
452 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
453 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
454 install_element (ENABLE_NODE
, &debug_zebra_mpls_cmd
);
455 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
456 install_element (ENABLE_NODE
, &debug_zebra_packet_direct_cmd
);
457 install_element (ENABLE_NODE
, &debug_zebra_packet_detail_cmd
);
458 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
459 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
460 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
461 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
462 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
463 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
464 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
465 install_element (ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
466 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
467 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
468 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
469 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
470 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
471 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
473 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
474 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
475 install_element (CONFIG_NODE
, &debug_zebra_mpls_cmd
);
476 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
477 install_element (CONFIG_NODE
, &debug_zebra_packet_direct_cmd
);
478 install_element (CONFIG_NODE
, &debug_zebra_packet_detail_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
);