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 #ifndef VTYSH_EXTRACT_PL
27 #include "zebra/debug_clippy.c"
30 /* For debug statement. */
31 unsigned long zebra_debug_event
;
32 unsigned long zebra_debug_packet
;
33 unsigned long zebra_debug_kernel
;
34 unsigned long zebra_debug_rib
;
35 unsigned long zebra_debug_fpm
;
36 unsigned long zebra_debug_nht
;
37 unsigned long zebra_debug_mpls
;
38 unsigned long zebra_debug_vxlan
;
39 unsigned long zebra_debug_pw
;
40 unsigned long zebra_debug_dplane
;
41 unsigned long zebra_debug_mlag
;
43 DEFINE_HOOK(zebra_debug_show_debugging
, (struct vty
*vty
), (vty
));
45 DEFUN_NOSH (show_debugging_zebra
,
46 show_debugging_zebra_cmd
,
47 "show debugging [zebra]",
49 "Debugging information\n"
50 "Zebra configuration\n")
52 vty_out(vty
, "Zebra debugging status:\n");
54 if (IS_ZEBRA_DEBUG_EVENT
)
55 vty_out(vty
, " Zebra event debugging is on\n");
57 if (IS_ZEBRA_DEBUG_PACKET
) {
58 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
59 vty_out(vty
, " Zebra packet%s debugging is on\n",
60 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
62 if (IS_ZEBRA_DEBUG_SEND
)
64 " Zebra packet send%s debugging is on\n",
65 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
68 " Zebra packet receive%s debugging is on\n",
69 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
73 if (IS_ZEBRA_DEBUG_KERNEL
)
74 vty_out(vty
, " Zebra kernel debugging is on\n");
75 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
77 " Zebra kernel netlink message dumps (send) are on\n");
78 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
80 " Zebra kernel netlink message dumps (recv) are on\n");
82 /* Check here using flags as the 'macro' does an OR */
83 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
84 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
85 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
86 vty_out(vty
, " Zebra RIB debugging is on\n");
88 if (IS_ZEBRA_DEBUG_FPM
)
89 vty_out(vty
, " Zebra FPM debugging is on\n");
90 if (IS_ZEBRA_DEBUG_NHT
)
91 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
92 if (IS_ZEBRA_DEBUG_MPLS
)
93 vty_out(vty
, " Zebra MPLS debugging is on\n");
94 if (IS_ZEBRA_DEBUG_VXLAN
)
95 vty_out(vty
, " Zebra VXLAN debugging is on\n");
96 if (IS_ZEBRA_DEBUG_PW
)
97 vty_out(vty
, " Zebra pseudowire debugging is on\n");
98 if (IS_ZEBRA_DEBUG_DPLANE_DETAIL
)
99 vty_out(vty
, " Zebra detailed dataplane debugging is on\n");
100 else if (IS_ZEBRA_DEBUG_DPLANE
)
101 vty_out(vty
, " Zebra dataplane debugging is on\n");
102 if (IS_ZEBRA_DEBUG_MLAG
)
103 vty_out(vty
, " Zebra mlag debugging is on\n");
105 hook_call(zebra_debug_show_debugging
, vty
);
109 DEFUN (debug_zebra_events
,
110 debug_zebra_events_cmd
,
111 "debug zebra events",
113 "Zebra configuration\n"
114 "Debug option set for zebra events\n")
116 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
120 DEFUN (debug_zebra_nht
,
124 "Zebra configuration\n"
125 "Debug option set for zebra next hop tracking\n")
127 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
131 DEFUN (debug_zebra_mpls
,
132 debug_zebra_mpls_cmd
,
135 "Zebra configuration\n"
136 "Debug option set for zebra MPLS LSPs\n")
138 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
142 DEFUN (debug_zebra_vxlan
,
143 debug_zebra_vxlan_cmd
,
146 "Zebra configuration\n"
147 "Debug option set for zebra VxLAN (EVPN)\n")
149 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
153 DEFUN (debug_zebra_pw
,
155 "[no] debug zebra pseudowires",
158 "Zebra configuration\n"
159 "Debug option set for zebra pseudowires\n")
161 if (strmatch(argv
[0]->text
, "no"))
162 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
164 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
168 DEFUN (debug_zebra_packet
,
169 debug_zebra_packet_cmd
,
170 "debug zebra packet [<recv|send>] [detail]",
172 "Zebra configuration\n"
173 "Debug option set for zebra packet\n"
174 "Debug option set for receive packet\n"
175 "Debug option set for send packet\n"
176 "Debug option set for detailed info\n")
179 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
181 if (argv_find(argv
, argc
, "send", &idx
))
182 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
183 else if (argv_find(argv
, argc
, "recv", &idx
))
184 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
186 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
187 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
190 if (argv_find(argv
, argc
, "detail", &idx
))
191 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
196 DEFUN (debug_zebra_kernel
,
197 debug_zebra_kernel_cmd
,
198 "debug zebra kernel",
200 "Zebra configuration\n"
201 "Debug option set for zebra between kernel interface\n")
203 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
205 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
206 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
208 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
209 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
214 DEFUN (debug_zebra_kernel_msgdump
,
215 debug_zebra_kernel_msgdump_cmd
,
216 "debug zebra kernel msgdump [<recv|send>]",
218 "Zebra configuration\n"
219 "Debug option set for zebra between kernel interface\n"
220 "Dump raw netlink messages, sent and received\n"
221 "Dump raw netlink messages received\n"
222 "Dump raw netlink messages sent\n")
226 if (argv_find(argv
, argc
, "recv", &idx
)) {
227 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
229 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
230 UNSET_FLAG(zebra_debug_kernel
,
231 ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
233 } else if (argv_find(argv
, argc
, "send", &idx
)) {
234 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
236 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
237 UNSET_FLAG(zebra_debug_kernel
,
238 ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
241 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
242 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
248 DEFUN (debug_zebra_rib
,
250 "debug zebra rib [detailed]",
252 "Zebra configuration\n"
257 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
259 if (argv_find(argv
, argc
, "detailed", &idx
))
260 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
265 DEFUN (debug_zebra_fpm
,
269 "Zebra configuration\n"
270 "Debug zebra FPM events\n")
272 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
276 DEFUN (debug_zebra_dplane
,
277 debug_zebra_dplane_cmd
,
278 "debug zebra dplane [detailed]",
280 "Zebra configuration\n"
281 "Debug zebra dataplane events\n"
282 "Detailed debug information\n")
286 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
);
288 if (argv_find(argv
, argc
, "detailed", &idx
))
289 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
);
294 DEFPY (debug_zebra_mlag
,
295 debug_zebra_mlag_cmd
,
296 "[no$no] debug zebra mlag",
299 "Zebra configuration\n"
300 "Debug option set for mlag events\n")
303 UNSET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
305 SET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
309 DEFUN (no_debug_zebra_events
,
310 no_debug_zebra_events_cmd
,
311 "no debug zebra events",
314 "Zebra configuration\n"
315 "Debug option set for zebra events\n")
317 zebra_debug_event
= 0;
321 DEFUN (no_debug_zebra_nht
,
322 no_debug_zebra_nht_cmd
,
323 "no debug zebra nht",
326 "Zebra configuration\n"
327 "Debug option set for zebra next hop tracking\n")
333 DEFUN (no_debug_zebra_mpls
,
334 no_debug_zebra_mpls_cmd
,
335 "no debug zebra mpls",
338 "Zebra configuration\n"
339 "Debug option set for zebra MPLS LSPs\n")
341 zebra_debug_mpls
= 0;
345 DEFUN (no_debug_zebra_vxlan
,
346 no_debug_zebra_vxlan_cmd
,
347 "no debug zebra vxlan",
350 "Zebra configuration\n"
351 "Debug option set for zebra VxLAN (EVPN)\n")
353 zebra_debug_vxlan
= 0;
357 DEFUN (no_debug_zebra_packet
,
358 no_debug_zebra_packet_cmd
,
359 "no debug zebra packet [<recv|send>] [detail]",
362 "Zebra configuration\n"
363 "Debug option set for zebra packet\n"
364 "Debug option set for receive packet\n"
365 "Debug option set for send packet\n"
366 "Debug option set for detailed info\n")
368 zebra_debug_packet
= 0;
372 DEFUN (no_debug_zebra_kernel
,
373 no_debug_zebra_kernel_cmd
,
374 "no debug zebra kernel",
377 "Zebra configuration\n"
378 "Debug option set for zebra between kernel interface\n")
380 zebra_debug_kernel
= 0;
384 DEFUN (no_debug_zebra_kernel_msgdump
,
385 no_debug_zebra_kernel_msgdump_cmd
,
386 "no debug zebra kernel msgdump [<recv|send>]",
389 "Zebra configuration\n"
390 "Debug option set for zebra between kernel interface\n"
391 "Dump raw netlink messages, sent and received\n"
392 "Dump raw netlink messages received\n"
393 "Dump raw netlink messages sent\n")
395 zebra_debug_kernel
= 0;
399 DEFUN (no_debug_zebra_rib
,
400 no_debug_zebra_rib_cmd
,
401 "no debug zebra rib [detailed]",
404 "Zebra configuration\n"
412 DEFUN (no_debug_zebra_fpm
,
413 no_debug_zebra_fpm_cmd
,
414 "no debug zebra fpm",
417 "Zebra configuration\n"
418 "Debug zebra FPM events\n")
424 DEFUN (no_debug_zebra_dplane
,
425 no_debug_zebra_dplane_cmd
,
426 "no debug zebra dplane",
429 "Zebra configuration\n"
430 "Debug zebra dataplane events\n")
432 zebra_debug_dplane
= 0;
437 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
440 static int config_write_debug(struct vty
*vty
)
444 if (IS_ZEBRA_DEBUG_EVENT
) {
445 vty_out(vty
, "debug zebra events\n");
448 if (IS_ZEBRA_DEBUG_PACKET
) {
449 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
450 vty_out(vty
, "debug zebra packet%s\n",
451 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
454 if (IS_ZEBRA_DEBUG_SEND
)
455 vty_out(vty
, "debug zebra packet send%s\n",
456 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
458 vty_out(vty
, "debug zebra packet recv%s\n",
459 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
464 if (IS_ZEBRA_DEBUG_KERNEL
) {
465 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
466 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
467 vty_out(vty
, "debug zebra kernel msgdump\n");
469 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
470 vty_out(vty
, "debug zebra kernel msgdump recv\n");
472 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
473 vty_out(vty
, "debug zebra kernel msgdump send\n");
476 vty_out(vty
, "debug zebra kernel\n");
481 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
482 vty_out(vty
, "debug zebra rib detailed\n");
484 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
485 vty_out(vty
, "debug zebra rib\n");
489 if (IS_ZEBRA_DEBUG_FPM
) {
490 vty_out(vty
, "debug zebra fpm\n");
493 if (IS_ZEBRA_DEBUG_NHT
) {
494 vty_out(vty
, "debug zebra nht\n");
497 if (IS_ZEBRA_DEBUG_MPLS
) {
498 vty_out(vty
, "debug zebra mpls\n");
501 if (IS_ZEBRA_DEBUG_VXLAN
) {
502 vty_out(vty
, "debug zebra vxlan\n");
505 if (IS_ZEBRA_DEBUG_PW
) {
506 vty_out(vty
, "debug zebra pseudowires\n");
510 if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
)) {
511 vty_out(vty
, "debug zebra dplane detailed\n");
513 } else if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
)) {
514 vty_out(vty
, "debug zebra dplane\n");
521 void zebra_debug_init(void)
523 zebra_debug_event
= 0;
524 zebra_debug_packet
= 0;
525 zebra_debug_kernel
= 0;
528 zebra_debug_mpls
= 0;
529 zebra_debug_vxlan
= 0;
531 zebra_debug_dplane
= 0;
532 zebra_debug_mlag
= 0;
534 install_node(&debug_node
, config_write_debug
);
536 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
538 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
539 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
540 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
541 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
542 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
543 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
544 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
545 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
546 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
547 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
548 install_element(ENABLE_NODE
, &debug_zebra_dplane_cmd
);
549 install_element(ENABLE_NODE
, &debug_zebra_mlag_cmd
);
550 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
551 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
552 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
553 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
554 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
555 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
556 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
557 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
558 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
559 install_element(ENABLE_NODE
, &no_debug_zebra_dplane_cmd
);
561 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
562 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
563 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
564 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
565 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
566 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
567 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
568 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
569 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
570 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
571 install_element(CONFIG_NODE
, &debug_zebra_dplane_cmd
);
572 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
573 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
574 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
575 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
576 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
577 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
578 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
579 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
580 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);
581 install_element(CONFIG_NODE
, &no_debug_zebra_dplane_cmd
);