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
;
35 unsigned long zebra_debug_pw
;
37 DEFUN_NOSH (show_debugging_zebra
,
38 show_debugging_zebra_cmd
,
39 "show debugging [zebra]",
41 "Debugging information\n"
42 "Zebra configuration\n")
44 vty_out(vty
, "Zebra debugging status:\n");
46 if (IS_ZEBRA_DEBUG_EVENT
)
47 vty_out(vty
, " Zebra event debugging is on\n");
49 if (IS_ZEBRA_DEBUG_PACKET
) {
50 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
51 vty_out(vty
, " Zebra packet%s debugging is on\n",
52 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
54 if (IS_ZEBRA_DEBUG_SEND
)
56 " Zebra packet send%s debugging is on\n",
57 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
60 " Zebra packet receive%s debugging is on\n",
61 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
65 if (IS_ZEBRA_DEBUG_KERNEL
)
66 vty_out(vty
, " Zebra kernel debugging is on\n");
67 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
69 " Zebra kernel netlink message dumps (send) are on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
72 " Zebra kernel netlink message dumps (recv) are on\n");
74 /* Check here using flags as the 'macro' does an OR */
75 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
76 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
77 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
78 vty_out(vty
, " Zebra RIB debugging is on\n");
80 if (IS_ZEBRA_DEBUG_FPM
)
81 vty_out(vty
, " Zebra FPM debugging is on\n");
82 if (IS_ZEBRA_DEBUG_NHT
)
83 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
84 if (IS_ZEBRA_DEBUG_MPLS
)
85 vty_out(vty
, " Zebra MPLS debugging is on\n");
86 if (IS_ZEBRA_DEBUG_VXLAN
)
87 vty_out(vty
, " Zebra VXLAN debugging is on\n");
88 if (IS_ZEBRA_DEBUG_PW
)
89 vty_out(vty
, " Zebra pseudowire debugging is on\n");
94 DEFUN (debug_zebra_events
,
95 debug_zebra_events_cmd
,
98 "Zebra configuration\n"
99 "Debug option set for zebra events\n")
101 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
105 DEFUN (debug_zebra_nht
,
109 "Zebra configuration\n"
110 "Debug option set for zebra next hop tracking\n")
112 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
116 DEFUN (debug_zebra_mpls
,
117 debug_zebra_mpls_cmd
,
120 "Zebra configuration\n"
121 "Debug option set for zebra MPLS LSPs\n")
123 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
127 DEFUN (debug_zebra_vxlan
,
128 debug_zebra_vxlan_cmd
,
131 "Zebra configuration\n"
132 "Debug option set for zebra VxLAN (EVPN)\n")
134 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
138 DEFUN (debug_zebra_pw
,
140 "[no] debug zebra pseudowires",
143 "Zebra configuration\n"
144 "Debug option set for zebra pseudowires\n")
146 if (strmatch(argv
[0]->text
, "no"))
147 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
149 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
153 DEFUN (debug_zebra_packet
,
154 debug_zebra_packet_cmd
,
155 "debug zebra packet [<recv|send>] [detail]",
157 "Zebra configuration\n"
158 "Debug option set for zebra packet\n"
159 "Debug option set for receive packet\n"
160 "Debug option set for send packet\n"
161 "Debug option set for detailed info\n")
164 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
166 if (argv_find(argv
, argc
, "send", &idx
))
167 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
168 else if (argv_find(argv
, argc
, "recv", &idx
))
169 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
171 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
172 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
175 if (argv_find(argv
, argc
, "detail", &idx
))
176 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
181 DEFUN (debug_zebra_kernel
,
182 debug_zebra_kernel_cmd
,
183 "debug zebra kernel",
185 "Zebra configuration\n"
186 "Debug option set for zebra between kernel interface\n")
188 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
190 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
191 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
193 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
194 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
199 DEFUN (debug_zebra_kernel_msgdump
,
200 debug_zebra_kernel_msgdump_cmd
,
201 "debug zebra kernel msgdump [<recv|send>]",
203 "Zebra configuration\n"
204 "Debug option set for zebra between kernel interface\n"
205 "Dump raw netlink messages, sent and received\n"
206 "Dump raw netlink messages received\n"
207 "Dump raw netlink messages sent\n")
211 if (argv_find(argv
, argc
, "recv", &idx
)) {
212 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
214 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
215 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
217 } else if (argv_find(argv
, argc
, "send", &idx
)) {
218 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
220 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
221 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
224 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
225 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
231 DEFUN (debug_zebra_rib
,
233 "debug zebra rib [detailed]",
235 "Zebra configuration\n"
240 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
242 if (argv_find(argv
, argc
, "detailed", &idx
))
243 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
248 DEFUN (debug_zebra_fpm
,
252 "Zebra configuration\n"
253 "Debug zebra FPM events\n")
255 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
259 DEFUN (no_debug_zebra_events
,
260 no_debug_zebra_events_cmd
,
261 "no debug zebra events",
264 "Zebra configuration\n"
265 "Debug option set for zebra events\n")
267 zebra_debug_event
= 0;
271 DEFUN (no_debug_zebra_nht
,
272 no_debug_zebra_nht_cmd
,
273 "no debug zebra nht",
276 "Zebra configuration\n"
277 "Debug option set for zebra next hop tracking\n")
283 DEFUN (no_debug_zebra_mpls
,
284 no_debug_zebra_mpls_cmd
,
285 "no debug zebra mpls",
288 "Zebra configuration\n"
289 "Debug option set for zebra MPLS LSPs\n")
291 zebra_debug_mpls
= 0;
295 DEFUN (no_debug_zebra_vxlan
,
296 no_debug_zebra_vxlan_cmd
,
297 "no debug zebra vxlan",
300 "Zebra configuration\n"
301 "Debug option set for zebra VxLAN (EVPN)\n")
303 zebra_debug_vxlan
= 0;
307 DEFUN (no_debug_zebra_packet
,
308 no_debug_zebra_packet_cmd
,
309 "no debug zebra packet [<recv|send>] [detail]",
312 "Zebra configuration\n"
313 "Debug option set for zebra packet\n"
314 "Debug option set for receive packet\n"
315 "Debug option set for send packet\n"
316 "Debug option set for detailed info\n")
318 zebra_debug_packet
= 0;
322 DEFUN (no_debug_zebra_kernel
,
323 no_debug_zebra_kernel_cmd
,
324 "no debug zebra kernel",
327 "Zebra configuration\n"
328 "Debug option set for zebra between kernel interface\n")
330 zebra_debug_kernel
= 0;
334 DEFUN (no_debug_zebra_kernel_msgdump
,
335 no_debug_zebra_kernel_msgdump_cmd
,
336 "no debug zebra kernel msgdump [<recv|send>]",
339 "Zebra configuration\n"
340 "Debug option set for zebra between kernel interface\n"
341 "Dump raw netlink messages, sent and received\n"
342 "Dump raw netlink messages received\n"
343 "Dump raw netlink messages sent\n")
345 zebra_debug_kernel
= 0;
349 DEFUN (no_debug_zebra_rib
,
350 no_debug_zebra_rib_cmd
,
351 "no debug zebra rib [detailed]",
354 "Zebra configuration\n"
362 DEFUN (no_debug_zebra_fpm
,
363 no_debug_zebra_fpm_cmd
,
364 "no debug zebra fpm",
367 "Zebra configuration\n"
368 "Debug zebra FPM events\n")
375 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
378 static int config_write_debug(struct vty
*vty
)
382 if (IS_ZEBRA_DEBUG_EVENT
) {
383 vty_out(vty
, "debug zebra events\n");
386 if (IS_ZEBRA_DEBUG_PACKET
) {
387 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
388 vty_out(vty
, "debug zebra packet%s\n",
389 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
392 if (IS_ZEBRA_DEBUG_SEND
)
393 vty_out(vty
, "debug zebra packet send%s\n",
394 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
396 vty_out(vty
, "debug zebra packet recv%s\n",
397 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
402 if (IS_ZEBRA_DEBUG_KERNEL
) {
403 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
&& IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
404 vty_out(vty
, "debug zebra kernel msgdump\n");
406 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
407 vty_out(vty
, "debug zebra kernel msgdump recv\n");
409 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
410 vty_out(vty
, "debug zebra kernel msgdump send\n");
413 vty_out(vty
, "debug zebra kernel\n");
418 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
419 vty_out(vty
, "debug zebra rib detailed\n");
421 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
422 vty_out(vty
, "debug zebra rib\n");
426 if (IS_ZEBRA_DEBUG_FPM
) {
427 vty_out(vty
, "debug zebra fpm\n");
430 if (IS_ZEBRA_DEBUG_NHT
) {
431 vty_out(vty
, "debug zebra nht\n");
434 if (IS_ZEBRA_DEBUG_MPLS
) {
435 vty_out(vty
, "debug zebra mpls\n");
438 if (IS_ZEBRA_DEBUG_VXLAN
) {
439 vty_out(vty
, "debug zebra vxlan\n");
442 if (IS_ZEBRA_DEBUG_PW
) {
443 vty_out(vty
, "debug zebra pseudowires\n");
449 void 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;
460 install_node(&debug_node
, config_write_debug
);
462 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
464 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
465 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
466 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
467 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
468 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
469 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
470 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
471 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
472 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
473 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
474 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
475 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
476 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
477 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
478 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
479 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
480 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
481 install_element(ENABLE_NODE
, &no_debug_zebra_rib_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_pw_cmd
);
489 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
490 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
491 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
492 install_element(CONFIG_NODE
, &debug_zebra_rib_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_fpm_cmd
);