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
;
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
);
89 DEFUN (debug_zebra_events
,
90 debug_zebra_events_cmd
,
93 "Zebra configuration\n"
94 "Debug option set for zebra events\n")
96 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
100 DEFUN (debug_zebra_nht
,
104 "Zebra configuration\n"
105 "Debug option set for zebra next hop tracking\n")
107 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
111 DEFUN (debug_zebra_packet
,
112 debug_zebra_packet_cmd
,
113 "debug zebra packet",
115 "Zebra configuration\n"
116 "Debug option set for zebra packet\n")
118 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
119 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
120 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
124 DEFUN (debug_zebra_packet_direct
,
125 debug_zebra_packet_direct_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")
133 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
134 if (strncmp ("send", argv
[3]->arg
, strlen (argv
[3]->arg
)) == 0)
135 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
136 if (strncmp ("recv", argv
[3]->arg
, strlen (argv
[3]->arg
)) == 0)
137 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
138 if (strncmp ("detail", argv
[3]->arg
, strlen (argv
[3]->arg
)) == 0)
139 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
143 DEFUN (debug_zebra_packet_detail
,
144 debug_zebra_packet_detail_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 detailed information\n")
153 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
154 if (strncmp ("send", argv
[3]->arg
, strlen (argv
[3]->arg
)) == 0)
155 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
156 if (strncmp ("recv", argv
[3]->arg
, strlen (argv
[3]->arg
)) == 0)
157 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
158 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
162 DEFUN (debug_zebra_kernel
,
163 debug_zebra_kernel_cmd
,
164 "debug zebra kernel",
166 "Zebra configuration\n"
167 "Debug option set for zebra between kernel interface\n")
169 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
173 DEFUN (debug_zebra_kernel_msgdump
,
174 debug_zebra_kernel_msgdump_cmd
,
175 "debug zebra kernel msgdump {recv|send}",
177 "Zebra configuration\n"
178 "Debug option set for zebra between kernel interface\n"
179 "Dump raw netlink messages, sent and received\n"
180 "Dump raw netlink messages received\n"
181 "Dump raw netlink messages sent\n")
183 if (argv
[4]->arg
&& strncmp(argv
[4]->arg
, "recv", strlen(argv
[4]->arg
)) == 0)
184 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
185 if (!argv
[4]->arg
|| strncmp(argv
[4]->arg
, "send", strlen(argv
[4]->arg
)) == 0)
186 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
190 DEFUN (debug_zebra_rib
,
194 "Zebra configuration\n"
195 "Debug RIB events\n")
197 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
201 DEFUN (debug_zebra_rib_detailed
,
202 debug_zebra_rib_detailed_cmd
,
203 "debug zebra rib detailed",
205 "Zebra configuration\n"
209 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
213 DEFUN (debug_zebra_fpm
,
217 "Zebra configuration\n"
218 "Debug zebra FPM events\n")
220 SET_FLAG (zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
224 DEFUN (no_debug_zebra_events
,
225 no_debug_zebra_events_cmd
,
226 "no debug zebra events",
229 "Zebra configuration\n"
230 "Debug option set for zebra events\n")
232 zebra_debug_event
= 0;
236 DEFUN (no_debug_zebra_nht
,
237 no_debug_zebra_nht_cmd
,
238 "no debug zebra nht",
241 "Zebra configuration\n"
242 "Debug option set for zebra next hop tracking\n")
248 DEFUN (no_debug_zebra_packet
,
249 no_debug_zebra_packet_cmd
,
250 "no debug zebra packet",
253 "Zebra configuration\n"
254 "Debug option set for zebra packet\n")
256 zebra_debug_packet
= 0;
260 DEFUN (no_debug_zebra_packet_direct
,
261 no_debug_zebra_packet_direct_cmd
,
262 "no debug zebra packet (recv|send)",
265 "Zebra configuration\n"
266 "Debug option set for zebra packet\n"
267 "Debug option set for receive packet\n"
268 "Debug option set for send packet\n")
270 if (strncmp ("send", argv
[4]->arg
, strlen (argv
[4]->arg
)) == 0)
271 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
272 if (strncmp ("recv", argv
[4]->arg
, strlen (argv
[4]->arg
)) == 0)
273 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
277 DEFUN (no_debug_zebra_kernel
,
278 no_debug_zebra_kernel_cmd
,
279 "no debug zebra kernel",
282 "Zebra configuration\n"
283 "Debug option set for zebra between kernel interface\n")
285 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
289 DEFUN (no_debug_zebra_kernel_msgdump
,
290 no_debug_zebra_kernel_msgdump_cmd
,
291 "no debug zebra kernel msgdump {recv|send}",
293 "Zebra configuration\n"
294 "Debug option set for zebra between kernel interface\n"
295 "Dump raw netlink messages, sent and received\n"
296 "Dump raw netlink messages received\n"
297 "Dump raw netlink messages sent\n")
299 if (!argv
[1] || (argv
[5]->arg
&& strncmp(argv
[5]->arg
, "recv", strlen(argv
[5]->arg
)) == 0))
300 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
301 if (!argv
[5]->arg
|| (argv
[5]->arg
&& strncmp(argv
[5]->arg
, "send", strlen(argv
[5]->arg
)) == 0))
302 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
306 DEFUN (no_debug_zebra_rib
,
307 no_debug_zebra_rib_cmd
,
308 "no debug zebra rib",
311 "Zebra configuration\n"
318 DEFUN (no_debug_zebra_rib_detailed
,
319 no_debug_zebra_rib_detailed_cmd
,
320 "no debug zebra rib detailed",
323 "Zebra configuration\n"
327 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
331 DEFUN (no_debug_zebra_fpm
,
332 no_debug_zebra_fpm_cmd
,
333 "no debug zebra fpm",
336 "Zebra configuration\n"
337 "Debug zebra FPM events\n")
344 struct cmd_node debug_node
=
347 "", /* Debug node has no interface. */
352 config_write_debug (struct vty
*vty
)
356 if (IS_ZEBRA_DEBUG_EVENT
)
358 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
361 if (IS_ZEBRA_DEBUG_PACKET
)
363 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
365 vty_out (vty
, "debug zebra packet%s%s",
366 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
372 if (IS_ZEBRA_DEBUG_SEND
)
373 vty_out (vty
, "debug zebra packet send%s%s",
374 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
377 vty_out (vty
, "debug zebra packet recv%s%s",
378 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
383 if (IS_ZEBRA_DEBUG_KERNEL
)
385 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
388 /* Check here using flags as the 'macro' does an OR */
389 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
391 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
394 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
396 vty_out (vty
, "debug zebra rib detailed%s", VTY_NEWLINE
);
399 if (IS_ZEBRA_DEBUG_FPM
)
401 vty_out (vty
, "debug zebra fpm%s", VTY_NEWLINE
);
408 zebra_debug_init (void)
410 zebra_debug_event
= 0;
411 zebra_debug_packet
= 0;
412 zebra_debug_kernel
= 0;
416 install_node (&debug_node
, config_write_debug
);
418 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
420 install_element (ENABLE_NODE
, &show_debugging_zebra_cmd
);
421 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
422 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
423 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
424 install_element (ENABLE_NODE
, &debug_zebra_packet_direct_cmd
);
425 install_element (ENABLE_NODE
, &debug_zebra_packet_detail_cmd
);
426 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
427 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
428 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
429 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
430 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
431 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
432 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
433 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
434 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
435 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
436 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
437 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
438 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
440 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
441 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
442 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
443 install_element (CONFIG_NODE
, &debug_zebra_packet_direct_cmd
);
444 install_element (CONFIG_NODE
, &debug_zebra_packet_detail_cmd
);
445 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
446 install_element (CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
447 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
448 install_element (CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
449 install_element (CONFIG_NODE
, &debug_zebra_fpm_cmd
);
450 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
451 install_element (CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
452 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
453 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
454 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
455 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
456 install_element (CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
457 install_element (CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);