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
;
36 unsigned long zebra_debug_dplane
;
38 DEFINE_HOOK(zebra_debug_show_debugging
, (struct vty
*vty
), (vty
));
40 DEFUN_NOSH (show_debugging_zebra
,
41 show_debugging_zebra_cmd
,
42 "show debugging [zebra]",
44 "Debugging information\n"
45 "Zebra configuration\n")
47 vty_out(vty
, "Zebra debugging status:\n");
49 if (IS_ZEBRA_DEBUG_EVENT
)
50 vty_out(vty
, " Zebra event debugging is on\n");
52 if (IS_ZEBRA_DEBUG_PACKET
) {
53 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
54 vty_out(vty
, " Zebra packet%s debugging is on\n",
55 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
57 if (IS_ZEBRA_DEBUG_SEND
)
59 " Zebra packet send%s debugging is on\n",
60 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
63 " Zebra packet receive%s debugging is on\n",
64 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
68 if (IS_ZEBRA_DEBUG_KERNEL
)
69 vty_out(vty
, " Zebra kernel debugging is on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
72 " Zebra kernel netlink message dumps (send) are on\n");
73 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
75 " Zebra kernel netlink message dumps (recv) are on\n");
77 /* Check here using flags as the 'macro' does an OR */
78 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
79 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
80 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
81 vty_out(vty
, " Zebra RIB debugging is on\n");
83 if (IS_ZEBRA_DEBUG_FPM
)
84 vty_out(vty
, " Zebra FPM debugging is on\n");
85 if (IS_ZEBRA_DEBUG_NHT
)
86 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
87 if (IS_ZEBRA_DEBUG_MPLS
)
88 vty_out(vty
, " Zebra MPLS debugging is on\n");
89 if (IS_ZEBRA_DEBUG_VXLAN
)
90 vty_out(vty
, " Zebra VXLAN debugging is on\n");
91 if (IS_ZEBRA_DEBUG_PW
)
92 vty_out(vty
, " Zebra pseudowire debugging is on\n");
93 if (IS_ZEBRA_DEBUG_DPLANE_DETAIL
)
94 vty_out(vty
, " Zebra detailed dataplane debugging is on\n");
95 else if (IS_ZEBRA_DEBUG_DPLANE
)
96 vty_out(vty
, " Zebra dataplane debugging is on\n");
98 hook_call(zebra_debug_show_debugging
, vty
);
102 DEFUN (debug_zebra_events
,
103 debug_zebra_events_cmd
,
104 "debug zebra events",
106 "Zebra configuration\n"
107 "Debug option set for zebra events\n")
109 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
113 DEFUN (debug_zebra_nht
,
117 "Zebra configuration\n"
118 "Debug option set for zebra next hop tracking\n")
120 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
124 DEFUN (debug_zebra_mpls
,
125 debug_zebra_mpls_cmd
,
128 "Zebra configuration\n"
129 "Debug option set for zebra MPLS LSPs\n")
131 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
135 DEFUN (debug_zebra_vxlan
,
136 debug_zebra_vxlan_cmd
,
139 "Zebra configuration\n"
140 "Debug option set for zebra VxLAN (EVPN)\n")
142 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
146 DEFUN (debug_zebra_pw
,
148 "[no] debug zebra pseudowires",
151 "Zebra configuration\n"
152 "Debug option set for zebra pseudowires\n")
154 if (strmatch(argv
[0]->text
, "no"))
155 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
157 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
161 DEFUN (debug_zebra_packet
,
162 debug_zebra_packet_cmd
,
163 "debug zebra packet [<recv|send>] [detail]",
165 "Zebra configuration\n"
166 "Debug option set for zebra packet\n"
167 "Debug option set for receive packet\n"
168 "Debug option set for send packet\n"
169 "Debug option set for detailed info\n")
172 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
174 if (argv_find(argv
, argc
, "send", &idx
))
175 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
176 else if (argv_find(argv
, argc
, "recv", &idx
))
177 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
179 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
180 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
183 if (argv_find(argv
, argc
, "detail", &idx
))
184 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
189 DEFUN (debug_zebra_kernel
,
190 debug_zebra_kernel_cmd
,
191 "debug zebra kernel",
193 "Zebra configuration\n"
194 "Debug option set for zebra between kernel interface\n")
196 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
198 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
199 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
201 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
202 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
207 DEFUN (debug_zebra_kernel_msgdump
,
208 debug_zebra_kernel_msgdump_cmd
,
209 "debug zebra kernel msgdump [<recv|send>]",
211 "Zebra configuration\n"
212 "Debug option set for zebra between kernel interface\n"
213 "Dump raw netlink messages, sent and received\n"
214 "Dump raw netlink messages received\n"
215 "Dump raw netlink messages sent\n")
219 if (argv_find(argv
, argc
, "recv", &idx
)) {
220 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
222 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
223 UNSET_FLAG(zebra_debug_kernel
,
224 ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
226 } else if (argv_find(argv
, argc
, "send", &idx
)) {
227 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
229 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
230 UNSET_FLAG(zebra_debug_kernel
,
231 ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
234 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
235 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
241 DEFUN (debug_zebra_rib
,
243 "debug zebra rib [detailed]",
245 "Zebra configuration\n"
250 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
252 if (argv_find(argv
, argc
, "detailed", &idx
))
253 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
258 DEFUN (debug_zebra_fpm
,
262 "Zebra configuration\n"
263 "Debug zebra FPM events\n")
265 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
269 DEFUN (debug_zebra_dplane
,
270 debug_zebra_dplane_cmd
,
271 "debug zebra dplane [detailed]",
273 "Zebra configuration\n"
274 "Debug zebra dataplane events\n"
275 "Detailed debug information\n")
279 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
);
281 if (argv_find(argv
, argc
, "detailed", &idx
))
282 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
);
287 DEFUN (no_debug_zebra_events
,
288 no_debug_zebra_events_cmd
,
289 "no debug zebra events",
292 "Zebra configuration\n"
293 "Debug option set for zebra events\n")
295 zebra_debug_event
= 0;
299 DEFUN (no_debug_zebra_nht
,
300 no_debug_zebra_nht_cmd
,
301 "no debug zebra nht",
304 "Zebra configuration\n"
305 "Debug option set for zebra next hop tracking\n")
311 DEFUN (no_debug_zebra_mpls
,
312 no_debug_zebra_mpls_cmd
,
313 "no debug zebra mpls",
316 "Zebra configuration\n"
317 "Debug option set for zebra MPLS LSPs\n")
319 zebra_debug_mpls
= 0;
323 DEFUN (no_debug_zebra_vxlan
,
324 no_debug_zebra_vxlan_cmd
,
325 "no debug zebra vxlan",
328 "Zebra configuration\n"
329 "Debug option set for zebra VxLAN (EVPN)\n")
331 zebra_debug_vxlan
= 0;
335 DEFUN (no_debug_zebra_packet
,
336 no_debug_zebra_packet_cmd
,
337 "no debug zebra packet [<recv|send>] [detail]",
340 "Zebra configuration\n"
341 "Debug option set for zebra packet\n"
342 "Debug option set for receive packet\n"
343 "Debug option set for send packet\n"
344 "Debug option set for detailed info\n")
346 zebra_debug_packet
= 0;
350 DEFUN (no_debug_zebra_kernel
,
351 no_debug_zebra_kernel_cmd
,
352 "no debug zebra kernel",
355 "Zebra configuration\n"
356 "Debug option set for zebra between kernel interface\n")
358 zebra_debug_kernel
= 0;
362 DEFUN (no_debug_zebra_kernel_msgdump
,
363 no_debug_zebra_kernel_msgdump_cmd
,
364 "no debug zebra kernel msgdump [<recv|send>]",
367 "Zebra configuration\n"
368 "Debug option set for zebra between kernel interface\n"
369 "Dump raw netlink messages, sent and received\n"
370 "Dump raw netlink messages received\n"
371 "Dump raw netlink messages sent\n")
373 zebra_debug_kernel
= 0;
377 DEFUN (no_debug_zebra_rib
,
378 no_debug_zebra_rib_cmd
,
379 "no debug zebra rib [detailed]",
382 "Zebra configuration\n"
390 DEFUN (no_debug_zebra_fpm
,
391 no_debug_zebra_fpm_cmd
,
392 "no debug zebra fpm",
395 "Zebra configuration\n"
396 "Debug zebra FPM events\n")
402 DEFUN (no_debug_zebra_dplane
,
403 no_debug_zebra_dplane_cmd
,
404 "no debug zebra dplane",
407 "Zebra configuration\n"
408 "Debug zebra dataplane events\n")
410 zebra_debug_dplane
= 0;
415 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
418 static int config_write_debug(struct vty
*vty
)
422 if (IS_ZEBRA_DEBUG_EVENT
) {
423 vty_out(vty
, "debug zebra events\n");
426 if (IS_ZEBRA_DEBUG_PACKET
) {
427 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
428 vty_out(vty
, "debug zebra packet%s\n",
429 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
432 if (IS_ZEBRA_DEBUG_SEND
)
433 vty_out(vty
, "debug zebra packet send%s\n",
434 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
436 vty_out(vty
, "debug zebra packet recv%s\n",
437 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
442 if (IS_ZEBRA_DEBUG_KERNEL
) {
443 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
444 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
445 vty_out(vty
, "debug zebra kernel msgdump\n");
447 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
448 vty_out(vty
, "debug zebra kernel msgdump recv\n");
450 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
451 vty_out(vty
, "debug zebra kernel msgdump send\n");
454 vty_out(vty
, "debug zebra kernel\n");
459 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
460 vty_out(vty
, "debug zebra rib detailed\n");
462 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
463 vty_out(vty
, "debug zebra rib\n");
467 if (IS_ZEBRA_DEBUG_FPM
) {
468 vty_out(vty
, "debug zebra fpm\n");
471 if (IS_ZEBRA_DEBUG_NHT
) {
472 vty_out(vty
, "debug zebra nht\n");
475 if (IS_ZEBRA_DEBUG_MPLS
) {
476 vty_out(vty
, "debug zebra mpls\n");
479 if (IS_ZEBRA_DEBUG_VXLAN
) {
480 vty_out(vty
, "debug zebra vxlan\n");
483 if (IS_ZEBRA_DEBUG_PW
) {
484 vty_out(vty
, "debug zebra pseudowires\n");
488 if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
)) {
489 vty_out(vty
, "debug zebra dplane detailed\n");
491 } else if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
)) {
492 vty_out(vty
, "debug zebra dplane\n");
499 void zebra_debug_init(void)
501 zebra_debug_event
= 0;
502 zebra_debug_packet
= 0;
503 zebra_debug_kernel
= 0;
506 zebra_debug_mpls
= 0;
507 zebra_debug_vxlan
= 0;
509 zebra_debug_dplane
= 0;
511 install_node(&debug_node
, config_write_debug
);
513 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
515 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
516 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
517 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
518 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
519 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
520 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
521 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
522 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
523 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
524 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
525 install_element(ENABLE_NODE
, &debug_zebra_dplane_cmd
);
526 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
527 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
528 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
529 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
530 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
531 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
532 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
533 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
534 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
535 install_element(ENABLE_NODE
, &no_debug_zebra_dplane_cmd
);
537 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
538 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
539 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
540 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
541 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
542 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
543 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
544 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
545 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
546 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
547 install_element(CONFIG_NODE
, &debug_zebra_dplane_cmd
);
548 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
549 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
550 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
551 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
552 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
553 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
554 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
555 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
556 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);
557 install_element(CONFIG_NODE
, &no_debug_zebra_dplane_cmd
);