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
;
34 unsigned long zebra_debug_vxlan
;
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:\n");
45 if (IS_ZEBRA_DEBUG_EVENT
)
46 vty_out (vty
, " Zebra event debugging is on\n");
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\n",
53 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
57 if (IS_ZEBRA_DEBUG_SEND
)
58 vty_out (vty
, " Zebra packet send%s debugging is on\n",
59 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
61 vty_out (vty
, " Zebra packet receive%s debugging is on\n",
62 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
66 if (IS_ZEBRA_DEBUG_KERNEL
)
67 vty_out (vty
, " Zebra kernel debugging is on\n");
68 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
69 vty_out (vty
, " Zebra kernel netlink message dumps (send) are on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
71 vty_out (vty
, " Zebra kernel netlink message dumps (recv) are on\n");
73 /* Check here using flags as the 'macro' does an OR */
74 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
75 vty_out (vty
, " Zebra RIB debugging is on\n");
76 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
77 vty_out (vty
, " Zebra RIB detailed debugging is on\n");
79 if (IS_ZEBRA_DEBUG_FPM
)
80 vty_out (vty
, " Zebra FPM debugging is on\n");
81 if (IS_ZEBRA_DEBUG_NHT
)
82 vty_out (vty
, " Zebra next-hop tracking debugging is on\n");
83 if (IS_ZEBRA_DEBUG_MPLS
)
84 vty_out (vty
, " Zebra MPLS debugging is on\n");
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
;
97 return CMD_WARNING_CONFIG_FAILED
;
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
;
108 return CMD_WARNING_CONFIG_FAILED
;
111 DEFUN (debug_zebra_mpls
,
112 debug_zebra_mpls_cmd
,
115 "Zebra configuration\n"
116 "Debug option set for zebra MPLS LSPs\n")
118 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
119 return CMD_WARNING_CONFIG_FAILED
;
122 DEFUN (debug_zebra_vxlan
,
123 debug_zebra_vxlan_cmd
,
126 "Zebra configuration\n"
127 "Debug option set for zebra VxLAN (EVPN)\n")
129 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
133 DEFUN (debug_zebra_packet
,
134 debug_zebra_packet_cmd
,
135 "debug zebra packet [<recv|send>] [detail]",
137 "Zebra configuration\n"
138 "Debug option set for zebra packet\n"
139 "Debug option set for receive packet\n"
140 "Debug option set for send packet\n"
141 "Debug option set for detailed info\n")
144 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
146 if (argv_find (argv
, argc
, "send", &idx
))
147 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
149 if (argv_find (argv
, argc
, "recv", &idx
))
150 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
152 if (argv_find (argv
, argc
, "detail", &idx
))
153 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
155 if (!(zebra_debug_packet
& ZEBRA_DEBUG_SEND
& ZEBRA_DEBUG_RECV
))
157 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
158 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
163 DEFUN (debug_zebra_kernel
,
164 debug_zebra_kernel_cmd
,
165 "debug zebra kernel",
167 "Zebra configuration\n"
168 "Debug option set for zebra between kernel interface\n")
170 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
174 DEFUN (debug_zebra_kernel_msgdump
,
175 debug_zebra_kernel_msgdump_cmd
,
176 "debug zebra kernel msgdump [<recv|send>]",
178 "Zebra configuration\n"
179 "Debug option set for zebra between kernel interface\n"
180 "Dump raw netlink messages, sent and received\n"
181 "Dump raw netlink messages received\n"
182 "Dump raw netlink messages sent\n")
185 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
186 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
187 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
188 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_mpls
,
252 no_debug_zebra_mpls_cmd
,
253 "no debug zebra mpls",
256 "Zebra configuration\n"
257 "Debug option set for zebra MPLS LSPs\n")
259 zebra_debug_mpls
= 0;
263 DEFUN (no_debug_zebra_vxlan
,
264 no_debug_zebra_vxlan_cmd
,
265 "no debug zebra vxlan",
268 "Zebra configuration\n"
269 "Debug option set for zebra VxLAN (EVPN)\n")
271 zebra_debug_vxlan
= 0;
275 DEFUN (no_debug_zebra_packet
,
276 no_debug_zebra_packet_cmd
,
277 "no debug zebra packet [<recv|send>]",
280 "Zebra configuration\n"
281 "Debug option set for zebra packet\n"
282 "Debug option set for receive packet\n"
283 "Debug option set for send packet\n")
286 if (argc
== 4 || argv_find (argv
, argc
, "send", &idx
))
287 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
288 if (argc
== 4 || argv_find (argv
, argc
, "recv", &idx
))
289 UNSET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
293 DEFUN (no_debug_zebra_kernel
,
294 no_debug_zebra_kernel_cmd
,
295 "no debug zebra kernel",
298 "Zebra configuration\n"
299 "Debug option set for zebra between kernel interface\n")
301 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
305 DEFUN (no_debug_zebra_kernel_msgdump
,
306 no_debug_zebra_kernel_msgdump_cmd
,
307 "no debug zebra kernel msgdump [<recv|send>]",
310 "Zebra configuration\n"
311 "Debug option set for zebra between kernel interface\n"
312 "Dump raw netlink messages, sent and received\n"
313 "Dump raw netlink messages received\n"
314 "Dump raw netlink messages sent\n")
317 if (argc
== 5 || argv_find (argv
, argc
, "recv", &idx
))
318 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
319 if (argc
== 5 || argv_find (argv
, argc
, "send", &idx
))
320 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
325 DEFUN (no_debug_zebra_rib
,
326 no_debug_zebra_rib_cmd
,
327 "no debug zebra rib",
330 "Zebra configuration\n"
337 DEFUN (no_debug_zebra_rib_detailed
,
338 no_debug_zebra_rib_detailed_cmd
,
339 "no debug zebra rib detailed",
342 "Zebra configuration\n"
346 UNSET_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
350 DEFUN (no_debug_zebra_fpm
,
351 no_debug_zebra_fpm_cmd
,
352 "no debug zebra fpm",
355 "Zebra configuration\n"
356 "Debug zebra FPM events\n")
363 struct cmd_node debug_node
=
366 "", /* Debug node has no interface. */
371 config_write_debug (struct vty
*vty
)
375 if (IS_ZEBRA_DEBUG_EVENT
)
377 vty_out (vty
, "debug zebra events\n");
380 if (IS_ZEBRA_DEBUG_PACKET
)
382 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
)
384 vty_out (vty
, "debug zebra packet%s\n",
385 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
390 if (IS_ZEBRA_DEBUG_SEND
)
391 vty_out (vty
, "debug zebra packet send%s\n",
392 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
394 vty_out (vty
, "debug zebra packet recv%s\n",
395 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
399 if (IS_ZEBRA_DEBUG_KERNEL
)
401 vty_out (vty
, "debug zebra kernel\n");
404 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
406 vty_out (vty
, "debug zebra kernel msgdump recv\n");
409 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
411 vty_out (vty
, "debug zebra kernel msgdump send\n");
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\n");
420 if (CHECK_FLAG (zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
422 vty_out (vty
, "debug zebra rib detailed\n");
425 if (IS_ZEBRA_DEBUG_FPM
)
427 vty_out (vty
, "debug zebra fpm\n");
430 if (IS_ZEBRA_DEBUG_NHT
)
432 vty_out (vty
, "debug zebra nht\n");
435 if (IS_ZEBRA_DEBUG_MPLS
)
437 vty_out (vty
, "debug zebra mpls\n");
440 if (IS_ZEBRA_DEBUG_VXLAN
)
442 vty_out (vty
, "debug zebra vxlan\n");
449 zebra_debug_init (void)
451 zebra_debug_event
= 0;
452 zebra_debug_packet
= 0;
453 zebra_debug_kernel
= 0;
456 zebra_debug_mpls
= 0;
457 zebra_debug_vxlan
= 0;
459 install_node (&debug_node
, config_write_debug
);
461 install_element (VIEW_NODE
, &show_debugging_zebra_cmd
);
463 install_element (ENABLE_NODE
, &debug_zebra_events_cmd
);
464 install_element (ENABLE_NODE
, &debug_zebra_nht_cmd
);
465 install_element (ENABLE_NODE
, &debug_zebra_mpls_cmd
);
466 install_element (ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
467 install_element (ENABLE_NODE
, &debug_zebra_packet_cmd
);
468 install_element (ENABLE_NODE
, &debug_zebra_kernel_cmd
);
469 install_element (ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
470 install_element (ENABLE_NODE
, &debug_zebra_rib_cmd
);
471 install_element (ENABLE_NODE
, &debug_zebra_rib_detailed_cmd
);
472 install_element (ENABLE_NODE
, &debug_zebra_fpm_cmd
);
473 install_element (ENABLE_NODE
, &no_debug_zebra_events_cmd
);
474 install_element (ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
475 install_element (ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
476 install_element (ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
477 install_element (ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
478 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
479 install_element (ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
480 install_element (ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
481 install_element (ENABLE_NODE
, &no_debug_zebra_rib_detailed_cmd
);
482 install_element (ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
484 install_element (CONFIG_NODE
, &debug_zebra_events_cmd
);
485 install_element (CONFIG_NODE
, &debug_zebra_nht_cmd
);
486 install_element (CONFIG_NODE
, &debug_zebra_mpls_cmd
);
487 install_element (CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
488 install_element (CONFIG_NODE
, &debug_zebra_packet_cmd
);
489 install_element (CONFIG_NODE
, &debug_zebra_kernel_cmd
);
490 install_element (CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
491 install_element (CONFIG_NODE
, &debug_zebra_rib_cmd
);
492 install_element (CONFIG_NODE
, &debug_zebra_rib_detailed_cmd
);
493 install_element (CONFIG_NODE
, &debug_zebra_fpm_cmd
);
494 install_element (CONFIG_NODE
, &no_debug_zebra_events_cmd
);
495 install_element (CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
496 install_element (CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
497 install_element (CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
498 install_element (CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
499 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
500 install_element (CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
501 install_element (CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
502 install_element (CONFIG_NODE
, &no_debug_zebra_rib_detailed_cmd
);
503 install_element (CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);