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
;
42 unsigned long zebra_debug_nexthop
;
44 DEFINE_HOOK(zebra_debug_show_debugging
, (struct vty
*vty
), (vty
));
46 DEFUN_NOSH (show_debugging_zebra
,
47 show_debugging_zebra_cmd
,
48 "show debugging [zebra]",
50 "Debugging information\n"
51 "Zebra configuration\n")
53 vty_out(vty
, "Zebra debugging status:\n");
55 if (IS_ZEBRA_DEBUG_EVENT
)
56 vty_out(vty
, " Zebra event debugging is on\n");
58 if (IS_ZEBRA_DEBUG_PACKET
) {
59 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
60 vty_out(vty
, " Zebra packet%s debugging is on\n",
61 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
63 if (IS_ZEBRA_DEBUG_SEND
)
65 " Zebra packet send%s debugging is on\n",
66 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
69 " Zebra packet receive%s debugging is on\n",
70 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
74 if (IS_ZEBRA_DEBUG_KERNEL
)
75 vty_out(vty
, " Zebra kernel debugging is on\n");
76 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
78 " Zebra kernel netlink message dumps (send) are on\n");
79 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
81 " Zebra kernel netlink message dumps (recv) are on\n");
83 /* Check here using flags as the 'macro' does an OR */
84 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
85 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
86 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
87 vty_out(vty
, " Zebra RIB debugging is on\n");
89 if (IS_ZEBRA_DEBUG_FPM
)
90 vty_out(vty
, " Zebra FPM debugging is on\n");
91 if (IS_ZEBRA_DEBUG_NHT_DETAILED
)
92 vty_out(vty
, " Zebra detailed next-hop tracking debugging is on\n");
93 else if (IS_ZEBRA_DEBUG_NHT
)
94 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
95 if (IS_ZEBRA_DEBUG_MPLS
)
96 vty_out(vty
, " Zebra MPLS debugging is on\n");
97 if (IS_ZEBRA_DEBUG_VXLAN
)
98 vty_out(vty
, " Zebra VXLAN debugging is on\n");
99 if (IS_ZEBRA_DEBUG_PW
)
100 vty_out(vty
, " Zebra pseudowire debugging is on\n");
101 if (IS_ZEBRA_DEBUG_DPLANE_DETAIL
)
102 vty_out(vty
, " Zebra detailed dataplane debugging is on\n");
103 else if (IS_ZEBRA_DEBUG_DPLANE
)
104 vty_out(vty
, " Zebra dataplane debugging is on\n");
105 if (IS_ZEBRA_DEBUG_MLAG
)
106 vty_out(vty
, " Zebra mlag debugging is on\n");
107 if (IS_ZEBRA_DEBUG_NHG_DETAIL
)
108 vty_out(vty
, " Zebra detailed nexthop debugging is on\n");
109 else if (IS_ZEBRA_DEBUG_NHG
)
110 vty_out(vty
, " Zebra nexthop debugging is on\n");
112 hook_call(zebra_debug_show_debugging
, vty
);
116 DEFUN (debug_zebra_events
,
117 debug_zebra_events_cmd
,
118 "debug zebra events",
120 "Zebra configuration\n"
121 "Debug option set for zebra events\n")
123 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
127 DEFUN (debug_zebra_nht
,
129 "debug zebra nht [detailed]",
131 "Zebra configuration\n"
132 "Debug option set for zebra next hop tracking\n"
133 "Debug option set for detailed info\n")
137 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
139 if (argv_find(argv
, argc
, "detailed", &idx
))
140 zebra_debug_nht
|= ZEBRA_DEBUG_NHT_DETAILED
;
145 DEFUN (debug_zebra_mpls
,
146 debug_zebra_mpls_cmd
,
149 "Zebra configuration\n"
150 "Debug option set for zebra MPLS LSPs\n")
152 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
156 DEFUN (debug_zebra_vxlan
,
157 debug_zebra_vxlan_cmd
,
160 "Zebra configuration\n"
161 "Debug option set for zebra VxLAN (EVPN)\n")
163 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
167 DEFUN (debug_zebra_pw
,
169 "[no] debug zebra pseudowires",
172 "Zebra configuration\n"
173 "Debug option set for zebra pseudowires\n")
175 if (strmatch(argv
[0]->text
, "no"))
176 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
178 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
182 DEFUN (debug_zebra_packet
,
183 debug_zebra_packet_cmd
,
184 "debug zebra packet [<recv|send>] [detail]",
186 "Zebra configuration\n"
187 "Debug option set for zebra packet\n"
188 "Debug option set for receive packet\n"
189 "Debug option set for send packet\n"
190 "Debug option set for detailed info\n")
193 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
195 if (argv_find(argv
, argc
, "send", &idx
))
196 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
197 else if (argv_find(argv
, argc
, "recv", &idx
))
198 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
200 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
201 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
204 if (argv_find(argv
, argc
, "detail", &idx
))
205 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
210 DEFUN (debug_zebra_kernel
,
211 debug_zebra_kernel_cmd
,
212 "debug zebra kernel",
214 "Zebra configuration\n"
215 "Debug option set for zebra between kernel interface\n")
217 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
219 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
220 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
222 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
223 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
228 DEFUN (debug_zebra_kernel_msgdump
,
229 debug_zebra_kernel_msgdump_cmd
,
230 "debug zebra kernel msgdump [<recv|send>]",
232 "Zebra configuration\n"
233 "Debug option set for zebra between kernel interface\n"
234 "Dump raw netlink messages, sent and received\n"
235 "Dump raw netlink messages received\n"
236 "Dump raw netlink messages sent\n")
240 if (argv_find(argv
, argc
, "recv", &idx
)) {
241 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
243 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
244 UNSET_FLAG(zebra_debug_kernel
,
245 ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
247 } else if (argv_find(argv
, argc
, "send", &idx
)) {
248 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
250 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
251 UNSET_FLAG(zebra_debug_kernel
,
252 ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
255 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
256 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
262 DEFUN (debug_zebra_rib
,
264 "debug zebra rib [detailed]",
266 "Zebra configuration\n"
271 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
273 if (argv_find(argv
, argc
, "detailed", &idx
))
274 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
279 DEFUN (debug_zebra_fpm
,
283 "Zebra configuration\n"
284 "Debug zebra FPM events\n")
286 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
290 DEFUN (debug_zebra_dplane
,
291 debug_zebra_dplane_cmd
,
292 "debug zebra dplane [detailed]",
294 "Zebra configuration\n"
295 "Debug zebra dataplane events\n"
296 "Detailed debug information\n")
300 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
);
302 if (argv_find(argv
, argc
, "detailed", &idx
))
303 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
);
308 DEFPY (debug_zebra_mlag
,
309 debug_zebra_mlag_cmd
,
310 "[no$no] debug zebra mlag",
313 "Zebra configuration\n"
314 "Debug option set for mlag events\n")
317 UNSET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
319 SET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
323 DEFUN (no_debug_zebra_events
,
324 no_debug_zebra_events_cmd
,
325 "no debug zebra events",
328 "Zebra configuration\n"
329 "Debug option set for zebra events\n")
331 zebra_debug_event
= 0;
335 DEFUN (no_debug_zebra_nht
,
336 no_debug_zebra_nht_cmd
,
337 "no debug zebra nht [detailed]",
340 "Zebra configuration\n"
341 "Debug option set for zebra next hop tracking\n"
342 "Debug option set for detailed info\n")
348 DEFUN (no_debug_zebra_mpls
,
349 no_debug_zebra_mpls_cmd
,
350 "no debug zebra mpls",
353 "Zebra configuration\n"
354 "Debug option set for zebra MPLS LSPs\n")
356 zebra_debug_mpls
= 0;
360 DEFUN (no_debug_zebra_vxlan
,
361 no_debug_zebra_vxlan_cmd
,
362 "no debug zebra vxlan",
365 "Zebra configuration\n"
366 "Debug option set for zebra VxLAN (EVPN)\n")
368 zebra_debug_vxlan
= 0;
372 DEFUN (no_debug_zebra_packet
,
373 no_debug_zebra_packet_cmd
,
374 "no debug zebra packet [<recv|send>] [detail]",
377 "Zebra configuration\n"
378 "Debug option set for zebra packet\n"
379 "Debug option set for receive packet\n"
380 "Debug option set for send packet\n"
381 "Debug option set for detailed info\n")
383 zebra_debug_packet
= 0;
387 DEFUN (no_debug_zebra_kernel
,
388 no_debug_zebra_kernel_cmd
,
389 "no debug zebra kernel",
392 "Zebra configuration\n"
393 "Debug option set for zebra between kernel interface\n")
395 zebra_debug_kernel
= 0;
399 DEFUN (no_debug_zebra_kernel_msgdump
,
400 no_debug_zebra_kernel_msgdump_cmd
,
401 "no debug zebra kernel msgdump [<recv|send>]",
404 "Zebra configuration\n"
405 "Debug option set for zebra between kernel interface\n"
406 "Dump raw netlink messages, sent and received\n"
407 "Dump raw netlink messages received\n"
408 "Dump raw netlink messages sent\n")
410 zebra_debug_kernel
= 0;
414 DEFUN (no_debug_zebra_rib
,
415 no_debug_zebra_rib_cmd
,
416 "no debug zebra rib [detailed]",
419 "Zebra configuration\n"
427 DEFUN (no_debug_zebra_fpm
,
428 no_debug_zebra_fpm_cmd
,
429 "no debug zebra fpm",
432 "Zebra configuration\n"
433 "Debug zebra FPM events\n")
439 DEFUN (no_debug_zebra_dplane
,
440 no_debug_zebra_dplane_cmd
,
441 "no debug zebra dplane",
444 "Zebra configuration\n"
445 "Debug zebra dataplane events\n")
447 zebra_debug_dplane
= 0;
451 DEFPY (debug_zebra_nexthop
,
452 debug_zebra_nexthop_cmd
,
453 "[no$no] debug zebra nexthop [detail$detail]",
456 "Zebra configuration\n"
457 "Debug zebra nexthop events\n"
458 "Detailed information\n")
461 zebra_debug_nexthop
= 0;
463 SET_FLAG(zebra_debug_nexthop
, ZEBRA_DEBUG_NHG
);
466 SET_FLAG(zebra_debug_nexthop
,
467 ZEBRA_DEBUG_NHG_DETAILED
);
474 static int config_write_debug(struct vty
*vty
);
475 struct cmd_node debug_node
= {
479 .config_write
= config_write_debug
,
482 static int config_write_debug(struct vty
*vty
)
486 if (IS_ZEBRA_DEBUG_EVENT
) {
487 vty_out(vty
, "debug zebra events\n");
490 if (IS_ZEBRA_DEBUG_PACKET
) {
491 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
492 vty_out(vty
, "debug zebra packet%s\n",
493 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
496 if (IS_ZEBRA_DEBUG_SEND
)
497 vty_out(vty
, "debug zebra packet send%s\n",
498 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
500 vty_out(vty
, "debug zebra packet recv%s\n",
501 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
506 if (IS_ZEBRA_DEBUG_KERNEL
) {
507 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
508 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
509 vty_out(vty
, "debug zebra kernel msgdump\n");
511 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
512 vty_out(vty
, "debug zebra kernel msgdump recv\n");
514 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
515 vty_out(vty
, "debug zebra kernel msgdump send\n");
518 vty_out(vty
, "debug zebra kernel\n");
523 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
524 vty_out(vty
, "debug zebra rib detailed\n");
526 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
527 vty_out(vty
, "debug zebra rib\n");
531 if (IS_ZEBRA_DEBUG_FPM
) {
532 vty_out(vty
, "debug zebra fpm\n");
536 if (IS_ZEBRA_DEBUG_NHT_DETAILED
) {
537 vty_out(vty
, "debug zebra nht detailed\n");
539 } else if (IS_ZEBRA_DEBUG_NHT
) {
540 vty_out(vty
, "debug zebra nht\n");
544 if (IS_ZEBRA_DEBUG_MPLS
) {
545 vty_out(vty
, "debug zebra mpls\n");
548 if (IS_ZEBRA_DEBUG_VXLAN
) {
549 vty_out(vty
, "debug zebra vxlan\n");
552 if (IS_ZEBRA_DEBUG_MLAG
) {
553 vty_out(vty
, "debug zebra mlag\n");
556 if (IS_ZEBRA_DEBUG_PW
) {
557 vty_out(vty
, "debug zebra pseudowires\n");
561 if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
)) {
562 vty_out(vty
, "debug zebra dplane detailed\n");
564 } else if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
)) {
565 vty_out(vty
, "debug zebra dplane\n");
569 if (CHECK_FLAG(zebra_debug_nexthop
, ZEBRA_DEBUG_NHG_DETAILED
)) {
570 vty_out(vty
, "debug zebra nexthop detail\n");
572 } else if (CHECK_FLAG(zebra_debug_nexthop
, ZEBRA_DEBUG_NHG
)) {
573 vty_out(vty
, "debug zebra nexthop\n");
580 void zebra_debug_init(void)
582 zebra_debug_event
= 0;
583 zebra_debug_packet
= 0;
584 zebra_debug_kernel
= 0;
587 zebra_debug_mpls
= 0;
588 zebra_debug_vxlan
= 0;
590 zebra_debug_dplane
= 0;
591 zebra_debug_mlag
= 0;
593 zebra_debug_nexthop
= 0;
595 install_node(&debug_node
);
597 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
599 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
600 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
601 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
602 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
603 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
604 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
605 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
606 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
607 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
608 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
609 install_element(ENABLE_NODE
, &debug_zebra_dplane_cmd
);
610 install_element(ENABLE_NODE
, &debug_zebra_mlag_cmd
);
611 install_element(ENABLE_NODE
, &debug_zebra_nexthop_cmd
);
612 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
613 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
614 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
615 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
616 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
617 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
618 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
619 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
620 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
621 install_element(ENABLE_NODE
, &no_debug_zebra_dplane_cmd
);
623 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
624 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
625 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
626 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
627 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
628 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
629 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
630 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
631 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
632 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
633 install_element(CONFIG_NODE
, &debug_zebra_dplane_cmd
);
634 install_element(CONFIG_NODE
, &debug_zebra_nexthop_cmd
);
635 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
636 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
637 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
638 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
639 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
640 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
641 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
642 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
643 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);
644 install_element(CONFIG_NODE
, &no_debug_zebra_dplane_cmd
);
645 install_element(CONFIG_NODE
, &debug_zebra_mlag_cmd
);