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 DEFUN (show_debugging_zebra
,
38 show_debugging_zebra_cmd
,
39 "show debugging zebra",
41 "Debugging information\n"
42 "Zebra configuration\n")
44 vty_out(vty
, "Zebra debugging status:\n");
46 if (IS_ZEBRA_DEBUG_EVENT
)
47 vty_out(vty
, " Zebra event debugging is on\n");
49 if (IS_ZEBRA_DEBUG_PACKET
) {
50 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
51 vty_out(vty
, " Zebra packet%s debugging is on\n",
52 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
54 if (IS_ZEBRA_DEBUG_SEND
)
56 " Zebra packet send%s debugging is on\n",
57 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
60 " Zebra packet receive%s debugging is on\n",
61 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
65 if (IS_ZEBRA_DEBUG_KERNEL
)
66 vty_out(vty
, " Zebra kernel debugging is on\n");
67 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
69 " Zebra kernel netlink message dumps (send) are on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
72 " Zebra kernel netlink message dumps (recv) are on\n");
74 /* Check here using flags as the 'macro' does an OR */
75 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
))
76 vty_out(vty
, " Zebra RIB detailed debugging is on\n");
77 else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
))
78 vty_out(vty
, " Zebra RIB debugging is on\n");
80 if (IS_ZEBRA_DEBUG_FPM
)
81 vty_out(vty
, " Zebra FPM debugging is on\n");
82 if (IS_ZEBRA_DEBUG_NHT
)
83 vty_out(vty
, " Zebra next-hop tracking debugging is on\n");
84 if (IS_ZEBRA_DEBUG_MPLS
)
85 vty_out(vty
, " Zebra MPLS debugging is on\n");
86 if (IS_ZEBRA_DEBUG_PW
)
87 vty_out(vty
, " Zebra pseudowire debugging is on\n");
92 DEFUN (debug_zebra_events
,
93 debug_zebra_events_cmd
,
96 "Zebra configuration\n"
97 "Debug option set for zebra events\n")
99 zebra_debug_event
= ZEBRA_DEBUG_EVENT
;
100 return CMD_WARNING_CONFIG_FAILED
;
103 DEFUN (debug_zebra_nht
,
107 "Zebra configuration\n"
108 "Debug option set for zebra next hop tracking\n")
110 zebra_debug_nht
= ZEBRA_DEBUG_NHT
;
111 return CMD_WARNING_CONFIG_FAILED
;
114 DEFUN (debug_zebra_mpls
,
115 debug_zebra_mpls_cmd
,
118 "Zebra configuration\n"
119 "Debug option set for zebra MPLS LSPs\n")
121 zebra_debug_mpls
= ZEBRA_DEBUG_MPLS
;
122 return CMD_WARNING_CONFIG_FAILED
;
125 DEFUN (debug_zebra_vxlan
,
126 debug_zebra_vxlan_cmd
,
129 "Zebra configuration\n"
130 "Debug option set for zebra VxLAN (EVPN)\n")
132 zebra_debug_vxlan
= ZEBRA_DEBUG_VXLAN
;
136 DEFUN (debug_zebra_pw
,
138 "[no] debug zebra pseudowires",
139 "Negate a command or set its defaults\n"
141 "Zebra configuration\n"
142 "Debug option set for zebra pseudowires\n")
144 if (strmatch(argv
[0]->text
, "no"))
145 UNSET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
147 SET_FLAG(zebra_debug_pw
, ZEBRA_DEBUG_PW
);
151 DEFUN (debug_zebra_packet
,
152 debug_zebra_packet_cmd
,
153 "debug zebra packet [<recv|send>] [detail]",
155 "Zebra configuration\n"
156 "Debug option set for zebra packet\n"
157 "Debug option set for receive packet\n"
158 "Debug option set for send packet\n"
159 "Debug option set for detailed info\n")
162 zebra_debug_packet
= ZEBRA_DEBUG_PACKET
;
164 if (argv_find(argv
, argc
, "send", &idx
))
165 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
166 else if (argv_find(argv
, argc
, "recv", &idx
))
167 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
169 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_SEND
);
170 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_RECV
);
173 if (argv_find(argv
, argc
, "detail", &idx
))
174 SET_FLAG(zebra_debug_packet
, ZEBRA_DEBUG_DETAIL
);
179 DEFUN (debug_zebra_kernel
,
180 debug_zebra_kernel_cmd
,
181 "debug zebra kernel",
183 "Zebra configuration\n"
184 "Debug option set for zebra between kernel interface\n")
186 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL
);
188 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
189 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
191 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
192 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
197 DEFUN (debug_zebra_kernel_msgdump
,
198 debug_zebra_kernel_msgdump_cmd
,
199 "debug zebra kernel msgdump [<recv|send>]",
201 "Zebra configuration\n"
202 "Debug option set for zebra between kernel interface\n"
203 "Dump raw netlink messages, sent and received\n"
204 "Dump raw netlink messages received\n"
205 "Dump raw netlink messages sent\n")
209 if (argv_find(argv
, argc
, "recv", &idx
)) {
210 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
212 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
)
213 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
215 } else if (argv_find(argv
, argc
, "send", &idx
)) {
216 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
218 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
)
219 UNSET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
222 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
);
223 SET_FLAG(zebra_debug_kernel
, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
);
229 DEFUN (debug_zebra_rib
,
231 "debug zebra rib [detailed]",
233 "Zebra configuration\n"
238 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
);
240 if (argv_find(argv
, argc
, "detailed", &idx
))
241 SET_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
);
246 DEFUN (debug_zebra_fpm
,
250 "Zebra configuration\n"
251 "Debug zebra FPM events\n")
253 SET_FLAG(zebra_debug_fpm
, ZEBRA_DEBUG_FPM
);
257 DEFUN (no_debug_zebra_events
,
258 no_debug_zebra_events_cmd
,
259 "no debug zebra events",
262 "Zebra configuration\n"
263 "Debug option set for zebra events\n")
265 zebra_debug_event
= 0;
269 DEFUN (no_debug_zebra_nht
,
270 no_debug_zebra_nht_cmd
,
271 "no debug zebra nht",
274 "Zebra configuration\n"
275 "Debug option set for zebra next hop tracking\n")
281 DEFUN (no_debug_zebra_mpls
,
282 no_debug_zebra_mpls_cmd
,
283 "no debug zebra mpls",
286 "Zebra configuration\n"
287 "Debug option set for zebra MPLS LSPs\n")
289 zebra_debug_mpls
= 0;
293 DEFUN (no_debug_zebra_vxlan
,
294 no_debug_zebra_vxlan_cmd
,
295 "no debug zebra vxlan",
298 "Zebra configuration\n"
299 "Debug option set for zebra VxLAN (EVPN)\n")
301 zebra_debug_vxlan
= 0;
305 DEFUN (no_debug_zebra_packet
,
306 no_debug_zebra_packet_cmd
,
307 "no debug zebra packet [<recv|send>] [detail]",
310 "Zebra configuration\n"
311 "Debug option set for zebra packet\n"
312 "Debug option set for receive packet\n"
313 "Debug option set for send packet\n"
314 "Debug option set for detailed info\n")
316 zebra_debug_packet
= 0;
320 DEFUN (no_debug_zebra_kernel
,
321 no_debug_zebra_kernel_cmd
,
322 "no debug zebra kernel",
325 "Zebra configuration\n"
326 "Debug option set for zebra between kernel interface\n")
328 zebra_debug_kernel
= 0;
332 DEFUN (no_debug_zebra_kernel_msgdump
,
333 no_debug_zebra_kernel_msgdump_cmd
,
334 "no debug zebra kernel msgdump [<recv|send>]",
337 "Zebra configuration\n"
338 "Debug option set for zebra between kernel interface\n"
339 "Dump raw netlink messages, sent and received\n"
340 "Dump raw netlink messages received\n"
341 "Dump raw netlink messages sent\n")
343 zebra_debug_kernel
= 0;
347 DEFUN (no_debug_zebra_rib
,
348 no_debug_zebra_rib_cmd
,
349 "no debug zebra rib [detailed]",
352 "Zebra configuration\n"
360 DEFUN (no_debug_zebra_fpm
,
361 no_debug_zebra_fpm_cmd
,
362 "no debug zebra fpm",
365 "Zebra configuration\n"
366 "Debug zebra FPM events\n")
373 struct cmd_node debug_node
= {DEBUG_NODE
, "", /* Debug node has no interface. */
376 static int config_write_debug(struct vty
*vty
)
380 if (IS_ZEBRA_DEBUG_EVENT
) {
381 vty_out(vty
, "debug zebra events\n");
384 if (IS_ZEBRA_DEBUG_PACKET
) {
385 if (IS_ZEBRA_DEBUG_SEND
&& IS_ZEBRA_DEBUG_RECV
) {
386 vty_out(vty
, "debug zebra packet%s\n",
387 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
390 if (IS_ZEBRA_DEBUG_SEND
)
391 vty_out(vty
, "debug zebra packet send%s\n",
392 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
394 vty_out(vty
, "debug zebra packet recv%s\n",
395 IS_ZEBRA_DEBUG_DETAIL
? " detail" : "");
400 if (IS_ZEBRA_DEBUG_KERNEL
) {
401 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
&& IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
402 vty_out(vty
, "debug zebra kernel msgdump\n");
404 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV
) {
405 vty_out(vty
, "debug zebra kernel msgdump recv\n");
407 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
) {
408 vty_out(vty
, "debug zebra kernel msgdump send\n");
411 vty_out(vty
, "debug zebra kernel\n");
416 if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB_DETAILED
)) {
417 vty_out(vty
, "debug zebra rib detailed\n");
419 } else if (CHECK_FLAG(zebra_debug_rib
, ZEBRA_DEBUG_RIB
)) {
420 vty_out(vty
, "debug zebra rib\n");
424 if (IS_ZEBRA_DEBUG_FPM
) {
425 vty_out(vty
, "debug zebra fpm\n");
428 if (IS_ZEBRA_DEBUG_NHT
) {
429 vty_out(vty
, "debug zebra nht\n");
432 if (IS_ZEBRA_DEBUG_MPLS
) {
433 vty_out(vty
, "debug zebra mpls\n");
436 if (IS_ZEBRA_DEBUG_VXLAN
) {
437 vty_out(vty
, "debug zebra vxlan\n");
440 if (IS_ZEBRA_DEBUG_PW
) {
441 vty_out(vty
, "debug zebra pseudowires\n");
447 void zebra_debug_init(void)
449 zebra_debug_event
= 0;
450 zebra_debug_packet
= 0;
451 zebra_debug_kernel
= 0;
454 zebra_debug_mpls
= 0;
455 zebra_debug_vxlan
= 0;
458 install_node(&debug_node
, config_write_debug
);
460 install_element(VIEW_NODE
, &show_debugging_zebra_cmd
);
462 install_element(ENABLE_NODE
, &debug_zebra_events_cmd
);
463 install_element(ENABLE_NODE
, &debug_zebra_nht_cmd
);
464 install_element(ENABLE_NODE
, &debug_zebra_mpls_cmd
);
465 install_element(ENABLE_NODE
, &debug_zebra_vxlan_cmd
);
466 install_element(ENABLE_NODE
, &debug_zebra_pw_cmd
);
467 install_element(ENABLE_NODE
, &debug_zebra_packet_cmd
);
468 install_element(ENABLE_NODE
, &debug_zebra_kernel_cmd
);
469 install_element(ENABLE_NODE
, &debug_zebra_kernel_msgdump_cmd
);
470 install_element(ENABLE_NODE
, &debug_zebra_rib_cmd
);
471 install_element(ENABLE_NODE
, &debug_zebra_fpm_cmd
);
472 install_element(ENABLE_NODE
, &no_debug_zebra_events_cmd
);
473 install_element(ENABLE_NODE
, &no_debug_zebra_nht_cmd
);
474 install_element(ENABLE_NODE
, &no_debug_zebra_mpls_cmd
);
475 install_element(ENABLE_NODE
, &no_debug_zebra_vxlan_cmd
);
476 install_element(ENABLE_NODE
, &no_debug_zebra_packet_cmd
);
477 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_cmd
);
478 install_element(ENABLE_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
479 install_element(ENABLE_NODE
, &no_debug_zebra_rib_cmd
);
480 install_element(ENABLE_NODE
, &no_debug_zebra_fpm_cmd
);
482 install_element(CONFIG_NODE
, &debug_zebra_events_cmd
);
483 install_element(CONFIG_NODE
, &debug_zebra_nht_cmd
);
484 install_element(CONFIG_NODE
, &debug_zebra_mpls_cmd
);
485 install_element(CONFIG_NODE
, &debug_zebra_vxlan_cmd
);
486 install_element(CONFIG_NODE
, &debug_zebra_pw_cmd
);
487 install_element(CONFIG_NODE
, &debug_zebra_packet_cmd
);
488 install_element(CONFIG_NODE
, &debug_zebra_kernel_cmd
);
489 install_element(CONFIG_NODE
, &debug_zebra_kernel_msgdump_cmd
);
490 install_element(CONFIG_NODE
, &debug_zebra_rib_cmd
);
491 install_element(CONFIG_NODE
, &debug_zebra_fpm_cmd
);
492 install_element(CONFIG_NODE
, &no_debug_zebra_events_cmd
);
493 install_element(CONFIG_NODE
, &no_debug_zebra_nht_cmd
);
494 install_element(CONFIG_NODE
, &no_debug_zebra_mpls_cmd
);
495 install_element(CONFIG_NODE
, &no_debug_zebra_vxlan_cmd
);
496 install_element(CONFIG_NODE
, &no_debug_zebra_packet_cmd
);
497 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_cmd
);
498 install_element(CONFIG_NODE
, &no_debug_zebra_kernel_msgdump_cmd
);
499 install_element(CONFIG_NODE
, &no_debug_zebra_rib_cmd
);
500 install_element(CONFIG_NODE
, &no_debug_zebra_fpm_cmd
);