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_DETAILED
)
91 vty_out(vty
, " Zebra detailed next-hop tracking debugging is on\n");
92 else if (IS_ZEBRA_DEBUG_NHT
)
93 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
94 if (IS_ZEBRA_DEBUG_MPLS
)
95 vty_out(vty
, " Zebra MPLS debugging is on\n");
96 if (IS_ZEBRA_DEBUG_VXLAN
)
97 vty_out(vty
, " Zebra VXLAN debugging is on\n");
98 if (IS_ZEBRA_DEBUG_PW
)
99 vty_out(vty
, " Zebra pseudowire debugging is on\n");
100 if (IS_ZEBRA_DEBUG_DPLANE_DETAIL
)
101 vty_out(vty
, " Zebra detailed dataplane debugging is on\n");
102 else if (IS_ZEBRA_DEBUG_DPLANE
)
103 vty_out(vty
, " Zebra dataplane debugging is on\n");
104 if (IS_ZEBRA_DEBUG_MLAG
)
105 vty_out(vty
, " Zebra mlag debugging is on\n");
107 hook_call(zebra_debug_show_debugging
, vty
);
111 DEFUN (debug_zebra_events
,
112 debug_zebra_events_cmd
,
113 "debug zebra events",
115 "Zebra configuration\n"
116 "Debug option set for zebra events\n")
118 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
122 DEFUN (debug_zebra_nht
,
124 "debug zebra nht [detailed]",
126 "Zebra configuration\n"
127 "Debug option set for zebra next hop tracking\n"
128 "Debug option set for detailed info\n")
132 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
134 if (argv_find(argv
, argc
, "detailed", &idx
))
135 zebra_debug_nht
|= ZEBRA_DEBUG_NHT_DETAILED
;
140 DEFUN (debug_zebra_mpls
,
141 debug_zebra_mpls_cmd
,
144 "Zebra configuration\n"
145 "Debug option set for zebra MPLS LSPs\n")
147 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
151 DEFUN (debug_zebra_vxlan
,
152 debug_zebra_vxlan_cmd
,
155 "Zebra configuration\n"
156 "Debug option set for zebra VxLAN (EVPN)\n")
158 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
162 DEFUN (debug_zebra_pw
,
164 "[no] debug zebra pseudowires",
167 "Zebra configuration\n"
168 "Debug option set for zebra pseudowires\n")
170 if (strmatch(argv
[0]->text
, "no"))
171 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
173 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
177 DEFUN (debug_zebra_packet
,
178 debug_zebra_packet_cmd
,
179 "debug zebra packet [<recv|send>] [detail]",
181 "Zebra configuration\n"
182 "Debug option set for zebra packet\n"
183 "Debug option set for receive packet\n"
184 "Debug option set for send packet\n"
185 "Debug option set for detailed info\n")
188 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
190 if (argv_find(argv
, argc
, "send", &idx
))
191 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
192 else if (argv_find(argv
, argc
, "recv", &idx
))
193 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
195 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
196 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
199 if (argv_find(argv
, argc
, "detail", &idx
))
200 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
205 DEFUN (debug_zebra_kernel
,
206 debug_zebra_kernel_cmd
,
207 "debug zebra kernel",
209 "Zebra configuration\n"
210 "Debug option set for zebra between kernel interface\n")
212 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
214 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
215 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
217 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
218 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
223 DEFUN (debug_zebra_kernel_msgdump
,
224 debug_zebra_kernel_msgdump_cmd
,
225 "debug zebra kernel msgdump [<recv|send>]",
227 "Zebra configuration\n"
228 "Debug option set for zebra between kernel interface\n"
229 "Dump raw netlink messages, sent and received\n"
230 "Dump raw netlink messages received\n"
231 "Dump raw netlink messages sent\n")
235 if (argv_find(argv
, argc
, "recv", &idx
)) {
236 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
238 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
239 UNSET_FLAG(zebra_debug_kernel
,
240 ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
242 } else if (argv_find(argv
, argc
, "send", &idx
)) {
243 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
245 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
246 UNSET_FLAG(zebra_debug_kernel
,
247 ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
250 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
251 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
257 DEFUN (debug_zebra_rib
,
259 "debug zebra rib [detailed]",
261 "Zebra configuration\n"
266 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
268 if (argv_find(argv
, argc
, "detailed", &idx
))
269 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
274 DEFUN (debug_zebra_fpm
,
278 "Zebra configuration\n"
279 "Debug zebra FPM events\n")
281 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
285 DEFUN (debug_zebra_dplane
,
286 debug_zebra_dplane_cmd
,
287 "debug zebra dplane [detailed]",
289 "Zebra configuration\n"
290 "Debug zebra dataplane events\n"
291 "Detailed debug information\n")
295 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
);
297 if (argv_find(argv
, argc
, "detailed", &idx
))
298 SET_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
);
303 DEFPY (debug_zebra_mlag
,
304 debug_zebra_mlag_cmd
,
305 "[no$no] debug zebra mlag",
308 "Zebra configuration\n"
309 "Debug option set for mlag events\n")
312 UNSET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
314 SET_FLAG(zebra_debug_mlag
, ZEBRA_DEBUG_MLAG
);
318 DEFUN (no_debug_zebra_events
,
319 no_debug_zebra_events_cmd
,
320 "no debug zebra events",
323 "Zebra configuration\n"
324 "Debug option set for zebra events\n")
326 zebra_debug_event
= 0;
330 DEFUN (no_debug_zebra_nht
,
331 no_debug_zebra_nht_cmd
,
332 "no debug zebra nht [detailed]",
335 "Zebra configuration\n"
336 "Debug option set for zebra next hop tracking\n"
337 "Debug option set for detailed info\n")
343 DEFUN (no_debug_zebra_mpls
,
344 no_debug_zebra_mpls_cmd
,
345 "no debug zebra mpls",
348 "Zebra configuration\n"
349 "Debug option set for zebra MPLS LSPs\n")
351 zebra_debug_mpls
= 0;
355 DEFUN (no_debug_zebra_vxlan
,
356 no_debug_zebra_vxlan_cmd
,
357 "no debug zebra vxlan",
360 "Zebra configuration\n"
361 "Debug option set for zebra VxLAN (EVPN)\n")
363 zebra_debug_vxlan
= 0;
367 DEFUN (no_debug_zebra_packet
,
368 no_debug_zebra_packet_cmd
,
369 "no debug zebra packet [<recv|send>] [detail]",
372 "Zebra configuration\n"
373 "Debug option set for zebra packet\n"
374 "Debug option set for receive packet\n"
375 "Debug option set for send packet\n"
376 "Debug option set for detailed info\n")
378 zebra_debug_packet
= 0;
382 DEFUN (no_debug_zebra_kernel
,
383 no_debug_zebra_kernel_cmd
,
384 "no debug zebra kernel",
387 "Zebra configuration\n"
388 "Debug option set for zebra between kernel interface\n")
390 zebra_debug_kernel
= 0;
394 DEFUN (no_debug_zebra_kernel_msgdump
,
395 no_debug_zebra_kernel_msgdump_cmd
,
396 "no debug zebra kernel msgdump [<recv|send>]",
399 "Zebra configuration\n"
400 "Debug option set for zebra between kernel interface\n"
401 "Dump raw netlink messages, sent and received\n"
402 "Dump raw netlink messages received\n"
403 "Dump raw netlink messages sent\n")
405 zebra_debug_kernel
= 0;
409 DEFUN (no_debug_zebra_rib
,
410 no_debug_zebra_rib_cmd
,
411 "no debug zebra rib [detailed]",
414 "Zebra configuration\n"
422 DEFUN (no_debug_zebra_fpm
,
423 no_debug_zebra_fpm_cmd
,
424 "no debug zebra fpm",
427 "Zebra configuration\n"
428 "Debug zebra FPM events\n")
434 DEFUN (no_debug_zebra_dplane
,
435 no_debug_zebra_dplane_cmd
,
436 "no debug zebra dplane",
439 "Zebra configuration\n"
440 "Debug zebra dataplane events\n")
442 zebra_debug_dplane
= 0;
447 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
450 static int config_write_debug(struct vty
*vty
)
454 if (IS_ZEBRA_DEBUG_EVENT
) {
455 vty_out(vty
, "debug zebra events\n");
458 if (IS_ZEBRA_DEBUG_PACKET
) {
459 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
460 vty_out(vty
, "debug zebra packet%s\n",
461 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
464 if (IS_ZEBRA_DEBUG_SEND
)
465 vty_out(vty
, "debug zebra packet send%s\n",
466 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
468 vty_out(vty
, "debug zebra packet recv%s\n",
469 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
474 if (IS_ZEBRA_DEBUG_KERNEL
) {
475 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
476 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
477 vty_out(vty
, "debug zebra kernel msgdump\n");
479 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
480 vty_out(vty
, "debug zebra kernel msgdump recv\n");
482 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
483 vty_out(vty
, "debug zebra kernel msgdump send\n");
486 vty_out(vty
, "debug zebra kernel\n");
491 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
492 vty_out(vty
, "debug zebra rib detailed\n");
494 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
495 vty_out(vty
, "debug zebra rib\n");
499 if (IS_ZEBRA_DEBUG_FPM
) {
500 vty_out(vty
, "debug zebra fpm\n");
504 if (IS_ZEBRA_DEBUG_NHT_DETAILED
) {
505 vty_out(vty
, "debug zebra nht detailed\n");
507 } else if (IS_ZEBRA_DEBUG_NHT
) {
508 vty_out(vty
, "debug zebra nht\n");
512 if (IS_ZEBRA_DEBUG_MPLS
) {
513 vty_out(vty
, "debug zebra mpls\n");
516 if (IS_ZEBRA_DEBUG_VXLAN
) {
517 vty_out(vty
, "debug zebra vxlan\n");
520 if (IS_ZEBRA_DEBUG_PW
) {
521 vty_out(vty
, "debug zebra pseudowires\n");
525 if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE_DETAILED
)) {
526 vty_out(vty
, "debug zebra dplane detailed\n");
528 } else if (CHECK_FLAG(zebra_debug_dplane
, ZEBRA_DEBUG_DPLANE
)) {
529 vty_out(vty
, "debug zebra dplane\n");
536 void zebra_debug_init(void)
538 zebra_debug_event
= 0;
539 zebra_debug_packet
= 0;
540 zebra_debug_kernel
= 0;
543 zebra_debug_mpls
= 0;
544 zebra_debug_vxlan
= 0;
546 zebra_debug_dplane
= 0;
547 zebra_debug_mlag
= 0;
550 install_node(&debug_node
, config_write_debug
);
552 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
554 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
555 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
556 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
557 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
558 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
559 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
560 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
561 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
562 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
563 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
564 install_element(ENABLE_NODE
, &debug_zebra_dplane_cmd
);
565 install_element(ENABLE_NODE
, &debug_zebra_mlag_cmd
);
566 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
567 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
568 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
569 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
570 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
571 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
572 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
573 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
574 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
575 install_element(ENABLE_NODE
, &no_debug_zebra_dplane_cmd
);
577 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
578 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
579 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
580 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
581 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
582 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
583 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
584 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
585 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
586 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
587 install_element(CONFIG_NODE
, &debug_zebra_dplane_cmd
);
588 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
589 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
590 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
591 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
592 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
593 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
594 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
595 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
596 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);
597 install_element(CONFIG_NODE
, &no_debug_zebra_dplane_cmd
);