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 int idx_recv_send
= 3;
134 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
135 if (strncmp ("send", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
136 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
137 if (strncmp ("recv", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
138 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
139 if (strncmp ("detail", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
140 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
144 DEFUN (debug_zebra_packet_detail
,
145 debug_zebra_packet_detail_cmd
,
146 "debug zebra packet <recv|send> detail",
148 "Zebra configuration\n"
149 "Debug option set for zebra packet\n"
150 "Debug option set for receive packet\n"
151 "Debug option set for send packet\n"
152 "Debug option set detailed information\n")
154 int idx_recv_send
= 3;
155 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
156 if (strncmp ("send", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
157 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
158 if (strncmp ("recv", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
159 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
160 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
164 DEFUN (debug_zebra_kernel
,
165 debug_zebra_kernel_cmd
,
166 "debug zebra kernel",
168 "Zebra configuration\n"
169 "Debug option set for zebra between kernel interface\n")
171 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
175 DEFUN (debug_zebra_kernel_msgdump
,
176 debug_zebra_kernel_msgdump_cmd
,
177 "debug zebra kernel msgdump [<recv|send>]",
179 "Zebra configuration\n"
180 "Debug option set for zebra between kernel interface\n"
181 "Dump raw netlink messages, sent and received\n"
182 "Dump raw netlink messages received\n"
183 "Dump raw netlink messages sent\n")
185 int idx_recv_send
= 4;
186 if (argv
[idx_recv_send
]->arg
&& strncmp(argv
[idx_recv_send
]->arg
, "recv", strlen(argv
[idx_recv_send
]->arg
)) == 0)
187 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
188 if (!argv
[idx_recv_send
]->arg
|| strncmp(argv
[idx_recv_send
]->arg
, "send", strlen(argv
[idx_recv_send
]->arg
)) == 0)
189 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
193 DEFUN (debug_zebra_rib
,
197 "Zebra configuration\n"
198 "Debug RIB events\n")
200 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
204 DEFUN (debug_zebra_rib_detailed
,
205 debug_zebra_rib_detailed_cmd
,
206 "debug zebra rib detailed",
208 "Zebra configuration\n"
212 SET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
216 DEFUN (debug_zebra_fpm
,
220 "Zebra configuration\n"
221 "Debug zebra FPM events\n")
223 SET_FLAG (zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
227 DEFUN (no_debug_zebra_events
,
228 no_debug_zebra_events_cmd
,
229 "no debug zebra events",
232 "Zebra configuration\n"
233 "Debug option set for zebra events\n")
235 zebra_debug_event
= 0;
239 DEFUN (no_debug_zebra_nht
,
240 no_debug_zebra_nht_cmd
,
241 "no debug zebra nht",
244 "Zebra configuration\n"
245 "Debug option set for zebra next hop tracking\n")
251 DEFUN (no_debug_zebra_packet
,
252 no_debug_zebra_packet_cmd
,
253 "no debug zebra packet",
256 "Zebra configuration\n"
257 "Debug option set for zebra packet\n")
259 zebra_debug_packet
= 0;
263 DEFUN (no_debug_zebra_packet_direct
,
264 no_debug_zebra_packet_direct_cmd
,
265 "no debug zebra packet <recv|send>",
268 "Zebra configuration\n"
269 "Debug option set for zebra packet\n"
270 "Debug option set for receive packet\n"
271 "Debug option set for send packet\n")
273 int idx_recv_send
= 4;
274 if (strncmp ("send", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
275 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
276 if (strncmp ("recv", argv
[idx_recv_send
]->arg
, strlen (argv
[idx_recv_send
]->arg
)) == 0)
277 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
281 DEFUN (no_debug_zebra_kernel
,
282 no_debug_zebra_kernel_cmd
,
283 "no debug zebra kernel",
286 "Zebra configuration\n"
287 "Debug option set for zebra between kernel interface\n")
289 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
293 DEFUN (no_debug_zebra_kernel_msgdump
,
294 no_debug_zebra_kernel_msgdump_cmd
,
295 "no debug zebra kernel msgdump [<recv|send>]",
297 "Zebra configuration\n"
298 "Debug option set for zebra between kernel interface\n"
299 "Dump raw netlink messages, sent and received\n"
300 "Dump raw netlink messages received\n"
301 "Dump raw netlink messages sent\n")
303 int idx_recv_send
= 5;
304 if (!argv
[1] || (argv
[idx_recv_send
]->arg
&& strncmp(argv
[idx_recv_send
]->arg
, "recv", strlen(argv
[idx_recv_send
]->arg
)) == 0))
305 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
306 if (!argv
[idx_recv_send
]->arg
|| (argv
[idx_recv_send
]->arg
&& strncmp(argv
[idx_recv_send
]->arg
, "send", strlen(argv
[idx_recv_send
]->arg
)) == 0))
307 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
311 DEFUN (no_debug_zebra_rib
,
312 no_debug_zebra_rib_cmd
,
313 "no debug zebra rib",
316 "Zebra configuration\n"
323 DEFUN (no_debug_zebra_rib_detailed
,
324 no_debug_zebra_rib_detailed_cmd
,
325 "no debug zebra rib detailed",
328 "Zebra configuration\n"
332 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
336 DEFUN (no_debug_zebra_fpm
,
337 no_debug_zebra_fpm_cmd
,
338 "no debug zebra fpm",
341 "Zebra configuration\n"
342 "Debug zebra FPM events\n")
349 struct cmd_node debug_node
=
352 "", /* Debug node has no interface. */
357 config_write_debug (struct vty
*vty
)
361 if (IS_ZEBRA_DEBUG_EVENT
)
363 vty_out (vty
, "debug zebra events%s", VTY_NEWLINE
);
366 if (IS_ZEBRA_DEBUG_PACKET
)
368 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
370 vty_out (vty
, "debug zebra packet%s%s",
371 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
377 if (IS_ZEBRA_DEBUG_SEND
)
378 vty_out (vty
, "debug zebra packet send%s%s",
379 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
382 vty_out (vty
, "debug zebra packet recv%s%s",
383 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "",
388 if (IS_ZEBRA_DEBUG_KERNEL
)
390 vty_out (vty
, "debug zebra kernel%s", VTY_NEWLINE
);
393 /* Check here using flags as the 'macro' does an OR */
394 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
396 vty_out (vty
, "debug zebra rib%s", VTY_NEWLINE
);
399 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
401 vty_out (vty
, "debug zebra rib detailed%s", VTY_NEWLINE
);
404 if (IS_ZEBRA_DEBUG_FPM
)
406 vty_out (vty
, "debug zebra fpm%s", VTY_NEWLINE
);
413 zebra_debug_init (void)
415 zebra_debug_event
= 0;
416 zebra_debug_packet
= 0;
417 zebra_debug_kernel
= 0;
421 install_node (&debug_node
, config_write_debug
);
423 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
425 install_element (ENABLE_NODE
, &show_debugging_zebra_cmd
);
426 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
427 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
428 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
429 install_element (ENABLE_NODE
, &debug_zebra_packet_direct_cmd
);
430 install_element (ENABLE_NODE
, &debug_zebra_packet_detail_cmd
);
431 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
432 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
433 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
434 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
435 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
436 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
437 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
438 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
439 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
440 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
441 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
442 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
443 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
445 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
446 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
447 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
448 install_element (CONFIG_NODE
, &debug_zebra_packet_direct_cmd
);
449 install_element (CONFIG_NODE
, &debug_zebra_packet_detail_cmd
);
450 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
451 install_element (CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
452 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
453 install_element (CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
454 install_element (CONFIG_NODE
, &debug_zebra_fpm_cmd
);
455 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
456 install_element (CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
457 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
458 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
459 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
460 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
461 install_element (CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
462 install_element (CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);