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);
71 if (IS_ZEBRA_DEBUG_RIB)
72 vty_out (vty, " Zebra RIB debugging is on%s", VTY_NEWLINE);
73 if (IS_ZEBRA_DEBUG_RIB_Q)
74 vty_out (vty, " Zebra RIB queue debugging is on%s", VTY_NEWLINE);
76 if (IS_ZEBRA_DEBUG_FPM)
77 vty_out (vty, " Zebra FPM debugging is on%s", VTY_NEWLINE);
78 if (IS_ZEBRA_DEBUG_NHT)
79 vty_out (vty, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE);
84 DEFUN (debug_zebra_events,
85 debug_zebra_events_cmd,
88 "Zebra configuration\n"
89 "Debug option set for zebra events\n")
91 zebra_debug_event = ZEBRA_DEBUG_EVENT;
95 DEFUN (debug_zebra_nht,
99 "Zebra configuration\n"
100 "Debug option set for zebra next hop tracking\n")
102 zebra_debug_nht = ZEBRA_DEBUG_NHT;
106 DEFUN (debug_zebra_packet,
107 debug_zebra_packet_cmd,
108 "debug zebra packet",
110 "Zebra configuration\n"
111 "Debug option set for zebra packet\n")
113 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
114 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
115 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
119 DEFUN (debug_zebra_packet_direct,
120 debug_zebra_packet_direct_cmd,
121 "debug zebra packet (recv|send|detail)",
123 "Zebra configuration\n"
124 "Debug option set for zebra packet\n"
125 "Debug option set for receive packet\n"
126 "Debug option set for send packet\n")
128 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
129 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
130 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
131 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
132 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
133 if (strncmp ("detail", argv[0], strlen (argv[0])) == 0)
134 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
138 DEFUN (debug_zebra_packet_detail,
139 debug_zebra_packet_detail_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"
146 "Debug option set detailed information\n")
148 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
149 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
150 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
151 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
152 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
153 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
157 DEFUN (debug_zebra_kernel,
158 debug_zebra_kernel_cmd,
159 "debug zebra kernel",
161 "Zebra configuration\n"
162 "Debug option set for zebra between kernel interface\n")
164 zebra_debug_kernel = ZEBRA_DEBUG_KERNEL;
168 DEFUN (debug_zebra_rib,
172 "Zebra configuration\n"
173 "Debug RIB events\n")
175 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB);
179 DEFUN (debug_zebra_rib_q,
180 debug_zebra_rib_q_cmd,
181 "debug zebra rib queue",
183 "Zebra configuration\n"
185 "Debug RIB queueing\n")
187 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
191 DEFUN (debug_zebra_fpm,
195 "Zebra configuration\n"
196 "Debug zebra FPM events\n")
198 SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM);
202 DEFUN (no_debug_zebra_events,
203 no_debug_zebra_events_cmd,
204 "no debug zebra events",
207 "Zebra configuration\n"
208 "Debug option set for zebra events\n")
210 zebra_debug_event = 0;
214 DEFUN (no_debug_zebra_nht,
215 no_debug_zebra_nht_cmd,
216 "no debug zebra nht",
219 "Zebra configuration\n"
220 "Debug option set for zebra next hop tracking\n")
226 DEFUN (no_debug_zebra_packet,
227 no_debug_zebra_packet_cmd,
228 "no debug zebra packet",
231 "Zebra configuration\n"
232 "Debug option set for zebra packet\n")
234 zebra_debug_packet = 0;
238 DEFUN (no_debug_zebra_packet_direct,
239 no_debug_zebra_packet_direct_cmd,
240 "no debug zebra packet (recv|send)",
243 "Zebra configuration\n"
244 "Debug option set for zebra packet\n"
245 "Debug option set for receive packet\n"
246 "Debug option set for send packet\n")
248 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
249 UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
250 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
251 UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
255 DEFUN (no_debug_zebra_kernel,
256 no_debug_zebra_kernel_cmd,
257 "no debug zebra kernel",
260 "Zebra configuration\n"
261 "Debug option set for zebra between kernel interface\n")
263 zebra_debug_kernel = 0;
267 DEFUN (no_debug_zebra_rib,
268 no_debug_zebra_rib_cmd,
269 "no debug zebra rib",
272 "Zebra configuration\n"
279 DEFUN (no_debug_zebra_rib_q,
280 no_debug_zebra_rib_q_cmd,
281 "no debug zebra rib queue",
284 "Zebra configuration\n"
286 "Debug RIB queueing\n")
288 UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
292 DEFUN (no_debug_zebra_fpm,
293 no_debug_zebra_fpm_cmd,
294 "no debug zebra fpm",
297 "Zebra configuration\n"
298 "Debug zebra FPM events\n")
305 struct cmd_node debug_node =
308 "", /* Debug node has no interface. */
313 config_write_debug (struct vty *vty)
317 if (IS_ZEBRA_DEBUG_EVENT)
319 vty_out (vty, "debug zebra events%s", VTY_NEWLINE);
322 if (IS_ZEBRA_DEBUG_PACKET)
324 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
326 vty_out (vty, "debug zebra packet%s%s",
327 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
333 if (IS_ZEBRA_DEBUG_SEND)
334 vty_out (vty, "debug zebra packet send%s%s",
335 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
338 vty_out (vty, "debug zebra packet recv%s%s",
339 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
344 if (IS_ZEBRA_DEBUG_KERNEL)
346 vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
349 if (IS_ZEBRA_DEBUG_RIB)
351 vty_out (vty, "debug zebra rib%s", VTY_NEWLINE);
354 if (IS_ZEBRA_DEBUG_RIB_Q)
356 vty_out (vty, "debug zebra rib queue%s", VTY_NEWLINE);
359 if (IS_ZEBRA_DEBUG_FPM)
361 vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE);
368 zebra_debug_init (void)
370 zebra_debug_event = 0;
371 zebra_debug_packet = 0;
372 zebra_debug_kernel = 0;
376 install_node (&debug_node, config_write_debug);
378 install_element (VIEW_NODE, &show_debugging_zebra_cmd);
380 install_element (ENABLE_NODE, &debug_zebra_events_cmd);
381 install_element (ENABLE_NODE, &debug_zebra_nht_cmd);
382 install_element (ENABLE_NODE, &debug_zebra_packet_cmd);
383 install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd);
384 install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd);
385 install_element (ENABLE_NODE, &debug_zebra_kernel_cmd);
386 install_element (ENABLE_NODE, &debug_zebra_rib_cmd);
387 install_element (ENABLE_NODE, &debug_zebra_rib_q_cmd);
388 install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
389 install_element (ENABLE_NODE, &no_debug_zebra_events_cmd);
390 install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd);
391 install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd);
392 install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd);
393 install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd);
394 install_element (ENABLE_NODE, &no_debug_zebra_rib_q_cmd);
395 install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
397 install_element (CONFIG_NODE, &debug_zebra_events_cmd);
398 install_element (CONFIG_NODE, &debug_zebra_nht_cmd);
399 install_element (CONFIG_NODE, &debug_zebra_packet_cmd);
400 install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd);
401 install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd);
402 install_element (CONFIG_NODE, &debug_zebra_kernel_cmd);
403 install_element (CONFIG_NODE, &debug_zebra_rib_cmd);
404 install_element (CONFIG_NODE, &debug_zebra_rib_q_cmd);
405 install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
406 install_element (CONFIG_NODE, &no_debug_zebra_events_cmd);
407 install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd);
408 install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd);
409 install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd);
410 install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd);
411 install_element (CONFIG_NODE, &no_debug_zebra_rib_q_cmd);
412 install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);