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
;
36 DEFUN (show_debugging_zebra
,
37 show_debugging_zebra_cmd
,
38 "show debugging zebra",
40 "Debugging information\n"
41 "Zebra configuration\n")
43 vty_out(vty
, "Zebra debugging status:\n");
45 if (IS_ZEBRA_DEBUG_EVENT
)
46 vty_out(vty
, " Zebra event debugging is on\n");
48 if (IS_ZEBRA_DEBUG_PACKET
) {
49 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
50 vty_out(vty
, " Zebra packet%s debugging is on\n",
51 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
53 if (IS_ZEBRA_DEBUG_SEND
)
55 " Zebra packet send%s debugging is on\n",
56 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
59 " Zebra packet receive%s debugging is on\n",
60 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
64 if (IS_ZEBRA_DEBUG_KERNEL
)
65 vty_out(vty
, " Zebra kernel debugging is on\n");
66 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
68 " Zebra kernel netlink message dumps (send) are on\n");
69 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
71 " Zebra kernel netlink message dumps (recv) are on\n");
73 /* Check here using flags as the 'macro' does an OR */
74 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
75 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
76 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
77 vty_out(vty
, " Zebra RIB debugging is on\n");
79 if (IS_ZEBRA_DEBUG_FPM
)
80 vty_out(vty
, " Zebra FPM debugging is on\n");
81 if (IS_ZEBRA_DEBUG_NHT
)
82 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
83 if (IS_ZEBRA_DEBUG_MPLS
)
84 vty_out(vty
, " Zebra MPLS debugging is on\n");
89 DEFUN (debug_zebra_events
,
90 debug_zebra_events_cmd
,
93 "Zebra configuration\n"
94 "Debug option set for zebra events\n")
96 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
97 return CMD_WARNING_CONFIG_FAILED
;
100 DEFUN (debug_zebra_nht
,
104 "Zebra configuration\n"
105 "Debug option set for zebra next hop tracking\n")
107 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
108 return CMD_WARNING_CONFIG_FAILED
;
111 DEFUN (debug_zebra_mpls
,
112 debug_zebra_mpls_cmd
,
115 "Zebra configuration\n"
116 "Debug option set for zebra MPLS LSPs\n")
118 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
119 return CMD_WARNING_CONFIG_FAILED
;
122 DEFUN (debug_zebra_vxlan
,
123 debug_zebra_vxlan_cmd
,
126 "Zebra configuration\n"
127 "Debug option set for zebra VxLAN (EVPN)\n")
129 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
133 DEFUN (debug_zebra_packet
,
134 debug_zebra_packet_cmd
,
135 "debug zebra packet [<recv|send>] [detail]",
137 "Zebra configuration\n"
138 "Debug option set for zebra packet\n"
139 "Debug option set for receive packet\n"
140 "Debug option set for send packet\n"
141 "Debug option set for detailed info\n")
144 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
146 if (argv_find(argv
, argc
, "send", &idx
))
147 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
148 else if (argv_find(argv
, argc
, "recv", &idx
))
149 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
151 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
152 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
155 if (argv_find(argv
, argc
, "detail", &idx
))
156 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
161 DEFUN (debug_zebra_kernel
,
162 debug_zebra_kernel_cmd
,
163 "debug zebra kernel",
165 "Zebra configuration\n"
166 "Debug option set for zebra between kernel interface\n")
168 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
170 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
171 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
173 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
174 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
179 DEFUN (debug_zebra_kernel_msgdump
,
180 debug_zebra_kernel_msgdump_cmd
,
181 "debug zebra kernel msgdump [<recv|send>]",
183 "Zebra configuration\n"
184 "Debug option set for zebra between kernel interface\n"
185 "Dump raw netlink messages, sent and received\n"
186 "Dump raw netlink messages received\n"
187 "Dump raw netlink messages sent\n")
191 if (argv_find(argv
, argc
, "recv", &idx
)) {
192 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
194 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
195 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
197 } else if (argv_find(argv
, argc
, "send", &idx
)) {
198 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
200 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
201 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
204 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
205 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
211 DEFUN (debug_zebra_rib
,
213 "debug zebra rib [detailed]",
215 "Zebra configuration\n"
220 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
222 if (argv_find(argv
, argc
, "detailed", &idx
))
223 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
228 DEFUN (debug_zebra_fpm
,
232 "Zebra configuration\n"
233 "Debug zebra FPM events\n")
235 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
239 DEFUN (no_debug_zebra_events
,
240 no_debug_zebra_events_cmd
,
241 "no debug zebra events",
244 "Zebra configuration\n"
245 "Debug option set for zebra events\n")
247 zebra_debug_event
= 0;
251 DEFUN (no_debug_zebra_nht
,
252 no_debug_zebra_nht_cmd
,
253 "no debug zebra nht",
256 "Zebra configuration\n"
257 "Debug option set for zebra next hop tracking\n")
263 DEFUN (no_debug_zebra_mpls
,
264 no_debug_zebra_mpls_cmd
,
265 "no debug zebra mpls",
268 "Zebra configuration\n"
269 "Debug option set for zebra MPLS LSPs\n")
271 zebra_debug_mpls
= 0;
275 DEFUN (no_debug_zebra_vxlan
,
276 no_debug_zebra_vxlan_cmd
,
277 "no debug zebra vxlan",
280 "Zebra configuration\n"
281 "Debug option set for zebra VxLAN (EVPN)\n")
283 zebra_debug_vxlan
= 0;
287 DEFUN (no_debug_zebra_packet
,
288 no_debug_zebra_packet_cmd
,
289 "no debug zebra packet [<recv|send>] [detail]",
292 "Zebra configuration\n"
293 "Debug option set for zebra packet\n"
294 "Debug option set for receive packet\n"
295 "Debug option set for send packet\n"
296 "Debug option set for detailed info\n")
298 zebra_debug_packet
= 0;
302 DEFUN (no_debug_zebra_kernel
,
303 no_debug_zebra_kernel_cmd
,
304 "no debug zebra kernel",
307 "Zebra configuration\n"
308 "Debug option set for zebra between kernel interface\n")
310 zebra_debug_kernel
= 0;
314 DEFUN (no_debug_zebra_kernel_msgdump
,
315 no_debug_zebra_kernel_msgdump_cmd
,
316 "no debug zebra kernel msgdump [<recv|send>]",
319 "Zebra configuration\n"
320 "Debug option set for zebra between kernel interface\n"
321 "Dump raw netlink messages, sent and received\n"
322 "Dump raw netlink messages received\n"
323 "Dump raw netlink messages sent\n")
325 zebra_debug_kernel
= 0;
329 DEFUN (no_debug_zebra_rib
,
330 no_debug_zebra_rib_cmd
,
331 "no debug zebra rib [detailed]",
334 "Zebra configuration\n"
342 DEFUN (no_debug_zebra_fpm
,
343 no_debug_zebra_fpm_cmd
,
344 "no debug zebra fpm",
347 "Zebra configuration\n"
348 "Debug zebra FPM events\n")
355 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
358 static int config_write_debug(struct vty
*vty
)
362 if (IS_ZEBRA_DEBUG_EVENT
) {
363 vty_out(vty
, "debug zebra events\n");
366 if (IS_ZEBRA_DEBUG_PACKET
) {
367 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
368 vty_out(vty
, "debug zebra packet%s\n",
369 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
372 if (IS_ZEBRA_DEBUG_SEND
)
373 vty_out(vty
, "debug zebra packet send%s\n",
374 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
376 vty_out(vty
, "debug zebra packet recv%s\n",
377 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
382 if (IS_ZEBRA_DEBUG_KERNEL
) {
383 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
&& IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
384 vty_out(vty
, "debug zebra kernel msgdump\n");
386 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
387 vty_out(vty
, "debug zebra kernel msgdump recv\n");
389 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
390 vty_out(vty
, "debug zebra kernel msgdump send\n");
393 vty_out(vty
, "debug zebra kernel\n");
398 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
399 vty_out(vty
, "debug zebra rib detailed\n");
401 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
402 vty_out(vty
, "debug zebra rib\n");
406 if (IS_ZEBRA_DEBUG_FPM
) {
407 vty_out(vty
, "debug zebra fpm\n");
410 if (IS_ZEBRA_DEBUG_NHT
) {
411 vty_out(vty
, "debug zebra nht\n");
414 if (IS_ZEBRA_DEBUG_MPLS
) {
415 vty_out(vty
, "debug zebra mpls\n");
418 if (IS_ZEBRA_DEBUG_VXLAN
) {
419 vty_out(vty
, "debug zebra vxlan\n");
425 void zebra_debug_init(void)
427 zebra_debug_event
= 0;
428 zebra_debug_packet
= 0;
429 zebra_debug_kernel
= 0;
432 zebra_debug_mpls
= 0;
433 zebra_debug_vxlan
= 0;
435 install_node(&debug_node
, config_write_debug
);
437 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
439 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
440 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
441 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
442 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
443 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
444 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
445 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
446 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
447 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
448 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
449 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
450 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
451 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
452 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
453 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
454 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
455 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
456 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
458 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
459 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
460 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
461 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
462 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
463 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
464 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
465 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
466 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
467 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
468 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
469 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
470 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
471 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
472 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
473 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
474 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
475 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);