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 DEFINE_HOOK(zebra_debug_show_debugging
, (struct vty
*vty
), (vty
));
39 DEFUN_NOSH (show_debugging_zebra
,
40 show_debugging_zebra_cmd
,
41 "show debugging [zebra]",
43 "Debugging information\n"
44 "Zebra configuration\n")
46 vty_out(vty
, "Zebra debugging status:\n");
48 if (IS_ZEBRA_DEBUG_EVENT
)
49 vty_out(vty
, " Zebra event debugging is on\n");
51 if (IS_ZEBRA_DEBUG_PACKET
) {
52 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
53 vty_out(vty
, " Zebra packet%s debugging is on\n",
54 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
56 if (IS_ZEBRA_DEBUG_SEND
)
58 " Zebra packet send%s debugging is on\n",
59 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
62 " Zebra packet receive%s debugging is on\n",
63 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
67 if (IS_ZEBRA_DEBUG_KERNEL
)
68 vty_out(vty
, " Zebra kernel debugging is on\n");
69 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
71 " Zebra kernel netlink message dumps (send) are on\n");
72 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
74 " Zebra kernel netlink message dumps (recv) are on\n");
76 /* Check here using flags as the 'macro' does an OR */
77 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
78 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
79 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
80 vty_out(vty
, " Zebra RIB debugging is on\n");
82 if (IS_ZEBRA_DEBUG_FPM
)
83 vty_out(vty
, " Zebra FPM debugging is on\n");
84 if (IS_ZEBRA_DEBUG_NHT
)
85 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
86 if (IS_ZEBRA_DEBUG_MPLS
)
87 vty_out(vty
, " Zebra MPLS debugging is on\n");
88 if (IS_ZEBRA_DEBUG_VXLAN
)
89 vty_out(vty
, " Zebra VXLAN debugging is on\n");
90 if (IS_ZEBRA_DEBUG_PW
)
91 vty_out(vty
, " Zebra pseudowire debugging is on\n");
93 hook_call(zebra_debug_show_debugging
, vty
);
97 DEFUN (debug_zebra_events
,
98 debug_zebra_events_cmd
,
101 "Zebra configuration\n"
102 "Debug option set for zebra events\n")
104 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
108 DEFUN (debug_zebra_nht
,
112 "Zebra configuration\n"
113 "Debug option set for zebra next hop tracking\n")
115 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
119 DEFUN (debug_zebra_mpls
,
120 debug_zebra_mpls_cmd
,
123 "Zebra configuration\n"
124 "Debug option set for zebra MPLS LSPs\n")
126 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
130 DEFUN (debug_zebra_vxlan
,
131 debug_zebra_vxlan_cmd
,
134 "Zebra configuration\n"
135 "Debug option set for zebra VxLAN (EVPN)\n")
137 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
141 DEFUN (debug_zebra_pw
,
143 "[no] debug zebra pseudowires",
146 "Zebra configuration\n"
147 "Debug option set for zebra pseudowires\n")
149 if (strmatch(argv
[0]->text
, "no"))
150 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
152 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
156 DEFUN (debug_zebra_packet
,
157 debug_zebra_packet_cmd
,
158 "debug zebra packet [<recv|send>] [detail]",
160 "Zebra configuration\n"
161 "Debug option set for zebra packet\n"
162 "Debug option set for receive packet\n"
163 "Debug option set for send packet\n"
164 "Debug option set for detailed info\n")
167 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
169 if (argv_find(argv
, argc
, "send", &idx
))
170 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
171 else if (argv_find(argv
, argc
, "recv", &idx
))
172 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
174 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
175 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
178 if (argv_find(argv
, argc
, "detail", &idx
))
179 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
184 DEFUN (debug_zebra_kernel
,
185 debug_zebra_kernel_cmd
,
186 "debug zebra kernel",
188 "Zebra configuration\n"
189 "Debug option set for zebra between kernel interface\n")
191 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
193 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
194 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
196 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
197 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
202 DEFUN (debug_zebra_kernel_msgdump
,
203 debug_zebra_kernel_msgdump_cmd
,
204 "debug zebra kernel msgdump [<recv|send>]",
206 "Zebra configuration\n"
207 "Debug option set for zebra between kernel interface\n"
208 "Dump raw netlink messages, sent and received\n"
209 "Dump raw netlink messages received\n"
210 "Dump raw netlink messages sent\n")
214 if (argv_find(argv
, argc
, "recv", &idx
)) {
215 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
217 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
218 UNSET_FLAG(zebra_debug_kernel
,
219 ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
221 } else if (argv_find(argv
, argc
, "send", &idx
)) {
222 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
224 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
225 UNSET_FLAG(zebra_debug_kernel
,
226 ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
229 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
230 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
236 DEFUN (debug_zebra_rib
,
238 "debug zebra rib [detailed]",
240 "Zebra configuration\n"
245 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
247 if (argv_find(argv
, argc
, "detailed", &idx
))
248 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
253 DEFUN (debug_zebra_fpm
,
257 "Zebra configuration\n"
258 "Debug zebra FPM events\n")
260 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
264 DEFUN (no_debug_zebra_events
,
265 no_debug_zebra_events_cmd
,
266 "no debug zebra events",
269 "Zebra configuration\n"
270 "Debug option set for zebra events\n")
272 zebra_debug_event
= 0;
276 DEFUN (no_debug_zebra_nht
,
277 no_debug_zebra_nht_cmd
,
278 "no debug zebra nht",
281 "Zebra configuration\n"
282 "Debug option set for zebra next hop tracking\n")
288 DEFUN (no_debug_zebra_mpls
,
289 no_debug_zebra_mpls_cmd
,
290 "no debug zebra mpls",
293 "Zebra configuration\n"
294 "Debug option set for zebra MPLS LSPs\n")
296 zebra_debug_mpls
= 0;
300 DEFUN (no_debug_zebra_vxlan
,
301 no_debug_zebra_vxlan_cmd
,
302 "no debug zebra vxlan",
305 "Zebra configuration\n"
306 "Debug option set for zebra VxLAN (EVPN)\n")
308 zebra_debug_vxlan
= 0;
312 DEFUN (no_debug_zebra_packet
,
313 no_debug_zebra_packet_cmd
,
314 "no debug zebra packet [<recv|send>] [detail]",
317 "Zebra configuration\n"
318 "Debug option set for zebra packet\n"
319 "Debug option set for receive packet\n"
320 "Debug option set for send packet\n"
321 "Debug option set for detailed info\n")
323 zebra_debug_packet
= 0;
327 DEFUN (no_debug_zebra_kernel
,
328 no_debug_zebra_kernel_cmd
,
329 "no debug zebra kernel",
332 "Zebra configuration\n"
333 "Debug option set for zebra between kernel interface\n")
335 zebra_debug_kernel
= 0;
339 DEFUN (no_debug_zebra_kernel_msgdump
,
340 no_debug_zebra_kernel_msgdump_cmd
,
341 "no debug zebra kernel msgdump [<recv|send>]",
344 "Zebra configuration\n"
345 "Debug option set for zebra between kernel interface\n"
346 "Dump raw netlink messages, sent and received\n"
347 "Dump raw netlink messages received\n"
348 "Dump raw netlink messages sent\n")
350 zebra_debug_kernel
= 0;
354 DEFUN (no_debug_zebra_rib
,
355 no_debug_zebra_rib_cmd
,
356 "no debug zebra rib [detailed]",
359 "Zebra configuration\n"
367 DEFUN (no_debug_zebra_fpm
,
368 no_debug_zebra_fpm_cmd
,
369 "no debug zebra fpm",
372 "Zebra configuration\n"
373 "Debug zebra FPM events\n")
380 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
383 static int config_write_debug(struct vty
*vty
)
387 if (IS_ZEBRA_DEBUG_EVENT
) {
388 vty_out(vty
, "debug zebra events\n");
391 if (IS_ZEBRA_DEBUG_PACKET
) {
392 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
393 vty_out(vty
, "debug zebra packet%s\n",
394 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
397 if (IS_ZEBRA_DEBUG_SEND
)
398 vty_out(vty
, "debug zebra packet send%s\n",
399 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
401 vty_out(vty
, "debug zebra packet recv%s\n",
402 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
407 if (IS_ZEBRA_DEBUG_KERNEL
) {
408 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
409 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
410 vty_out(vty
, "debug zebra kernel msgdump\n");
412 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
413 vty_out(vty
, "debug zebra kernel msgdump recv\n");
415 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
416 vty_out(vty
, "debug zebra kernel msgdump send\n");
419 vty_out(vty
, "debug zebra kernel\n");
424 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
425 vty_out(vty
, "debug zebra rib detailed\n");
427 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
428 vty_out(vty
, "debug zebra rib\n");
432 if (IS_ZEBRA_DEBUG_FPM
) {
433 vty_out(vty
, "debug zebra fpm\n");
436 if (IS_ZEBRA_DEBUG_NHT
) {
437 vty_out(vty
, "debug zebra nht\n");
440 if (IS_ZEBRA_DEBUG_MPLS
) {
441 vty_out(vty
, "debug zebra mpls\n");
444 if (IS_ZEBRA_DEBUG_VXLAN
) {
445 vty_out(vty
, "debug zebra vxlan\n");
448 if (IS_ZEBRA_DEBUG_PW
) {
449 vty_out(vty
, "debug zebra pseudowires\n");
455 void zebra_debug_init(void)
457 zebra_debug_event
= 0;
458 zebra_debug_packet
= 0;
459 zebra_debug_kernel
= 0;
462 zebra_debug_mpls
= 0;
463 zebra_debug_vxlan
= 0;
466 install_node(&debug_node
, config_write_debug
);
468 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
470 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
471 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
472 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
473 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
474 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
475 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
476 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
477 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
478 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
479 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
480 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
481 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
482 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
483 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
484 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
485 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
486 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
487 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
488 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
490 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
491 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
492 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
493 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
494 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
495 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
496 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
497 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
498 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
499 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
500 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
501 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
502 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
503 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
504 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
505 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
506 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
507 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
508 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);