]> git.proxmox.com Git - mirror_frr.git/blob - zebra/debug.c
Merge pull request #803 from opensourcerouting/redhat-doc-fixes-master
[mirror_frr.git] / zebra / debug.c
1 /*
2 * Zebra debug related function
3 * Copyright (C) 1999 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
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
20 */
21
22 #include <zebra.h>
23 #include "command.h"
24 #include "debug.h"
25
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
36 DEFUN (show_debugging_zebra,
37 show_debugging_zebra_cmd,
38 "show debugging zebra",
39 SHOW_STR
40 "Debugging information\n"
41 "Zebra configuration\n")
42 {
43 vty_out (vty, "Zebra debugging status:\n");
44
45 if (IS_ZEBRA_DEBUG_EVENT)
46 vty_out (vty, " Zebra event debugging is on\n");
47
48 if (IS_ZEBRA_DEBUG_PACKET)
49 {
50 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
51 {
52 vty_out (vty, " Zebra packet%s debugging is on\n",
53 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
54 }
55 else
56 {
57 if (IS_ZEBRA_DEBUG_SEND)
58 vty_out (vty, " Zebra packet send%s debugging is on\n",
59 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
60 else
61 vty_out (vty, " Zebra packet receive%s debugging is on\n",
62 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
63 }
64 }
65
66 if (IS_ZEBRA_DEBUG_KERNEL)
67 vty_out (vty, " Zebra kernel debugging is on\n");
68 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
69 vty_out (vty, " Zebra kernel netlink message dumps (send) are on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
71 vty_out (vty, " Zebra kernel netlink message dumps (recv) are on\n");
72
73 /* Check here using flags as the 'macro' does an OR */
74 if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
75 vty_out (vty, " Zebra RIB debugging is on\n");
76 if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
77 vty_out (vty, " Zebra RIB detailed debugging is on\n");
78
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");
85
86 return CMD_SUCCESS;
87 }
88
89 DEFUN (debug_zebra_events,
90 debug_zebra_events_cmd,
91 "debug zebra events",
92 DEBUG_STR
93 "Zebra configuration\n"
94 "Debug option set for zebra events\n")
95 {
96 zebra_debug_event = ZEBRA_DEBUG_EVENT;
97 return CMD_WARNING_CONFIG_FAILED;
98 }
99
100 DEFUN (debug_zebra_nht,
101 debug_zebra_nht_cmd,
102 "debug zebra nht",
103 DEBUG_STR
104 "Zebra configuration\n"
105 "Debug option set for zebra next hop tracking\n")
106 {
107 zebra_debug_nht = ZEBRA_DEBUG_NHT;
108 return CMD_WARNING_CONFIG_FAILED;
109 }
110
111 DEFUN (debug_zebra_mpls,
112 debug_zebra_mpls_cmd,
113 "debug zebra mpls",
114 DEBUG_STR
115 "Zebra configuration\n"
116 "Debug option set for zebra MPLS LSPs\n")
117 {
118 zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
119 return CMD_WARNING_CONFIG_FAILED;
120 }
121
122 DEFUN (debug_zebra_vxlan,
123 debug_zebra_vxlan_cmd,
124 "debug zebra vxlan",
125 DEBUG_STR
126 "Zebra configuration\n"
127 "Debug option set for zebra VxLAN (EVPN)\n")
128 {
129 zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
130 return CMD_WARNING;
131 }
132
133 DEFUN (debug_zebra_packet,
134 debug_zebra_packet_cmd,
135 "debug zebra packet [<recv|send>] [detail]",
136 DEBUG_STR
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")
142 {
143 int idx = 0;
144 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
145
146 if (argv_find (argv, argc, "send", &idx))
147 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
148 idx = 0;
149 if (argv_find (argv, argc, "recv", &idx))
150 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
151 idx = 0;
152 if (argv_find (argv, argc, "detail", &idx))
153 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
154
155 if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV))
156 {
157 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
158 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
159 }
160 return CMD_SUCCESS;
161 }
162
163 DEFUN (debug_zebra_kernel,
164 debug_zebra_kernel_cmd,
165 "debug zebra kernel",
166 DEBUG_STR
167 "Zebra configuration\n"
168 "Debug option set for zebra between kernel interface\n")
169 {
170 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
171 return CMD_SUCCESS;
172 }
173
174 DEFUN (debug_zebra_kernel_msgdump,
175 debug_zebra_kernel_msgdump_cmd,
176 "debug zebra kernel msgdump [<recv|send>]",
177 DEBUG_STR
178 "Zebra configuration\n"
179 "Debug option set for zebra between kernel interface\n"
180 "Dump raw netlink messages, sent and received\n"
181 "Dump raw netlink messages received\n"
182 "Dump raw netlink messages sent\n")
183 {
184 int idx = 0;
185 if (argc == 4 || argv_find (argv, argc, "recv", &idx))
186 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
187 if (argc == 4 || argv_find (argv, argc, "send", &idx))
188 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
189
190 return CMD_SUCCESS;
191 }
192
193 DEFUN (debug_zebra_rib,
194 debug_zebra_rib_cmd,
195 "debug zebra rib",
196 DEBUG_STR
197 "Zebra configuration\n"
198 "Debug RIB events\n")
199 {
200 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB);
201 return CMD_SUCCESS;
202 }
203
204 DEFUN (debug_zebra_rib_detailed,
205 debug_zebra_rib_detailed_cmd,
206 "debug zebra rib detailed",
207 DEBUG_STR
208 "Zebra configuration\n"
209 "Debug RIB events\n"
210 "Detailed debugs\n")
211 {
212 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
213 return CMD_SUCCESS;
214 }
215
216 DEFUN (debug_zebra_fpm,
217 debug_zebra_fpm_cmd,
218 "debug zebra fpm",
219 DEBUG_STR
220 "Zebra configuration\n"
221 "Debug zebra FPM events\n")
222 {
223 SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM);
224 return CMD_SUCCESS;
225 }
226
227 DEFUN (no_debug_zebra_events,
228 no_debug_zebra_events_cmd,
229 "no debug zebra events",
230 NO_STR
231 DEBUG_STR
232 "Zebra configuration\n"
233 "Debug option set for zebra events\n")
234 {
235 zebra_debug_event = 0;
236 return CMD_SUCCESS;
237 }
238
239 DEFUN (no_debug_zebra_nht,
240 no_debug_zebra_nht_cmd,
241 "no debug zebra nht",
242 NO_STR
243 DEBUG_STR
244 "Zebra configuration\n"
245 "Debug option set for zebra next hop tracking\n")
246 {
247 zebra_debug_nht = 0;
248 return CMD_SUCCESS;
249 }
250
251 DEFUN (no_debug_zebra_mpls,
252 no_debug_zebra_mpls_cmd,
253 "no debug zebra mpls",
254 NO_STR
255 DEBUG_STR
256 "Zebra configuration\n"
257 "Debug option set for zebra MPLS LSPs\n")
258 {
259 zebra_debug_mpls = 0;
260 return CMD_SUCCESS;
261 }
262
263 DEFUN (no_debug_zebra_vxlan,
264 no_debug_zebra_vxlan_cmd,
265 "no debug zebra vxlan",
266 NO_STR
267 DEBUG_STR
268 "Zebra configuration\n"
269 "Debug option set for zebra VxLAN (EVPN)\n")
270 {
271 zebra_debug_vxlan = 0;
272 return CMD_SUCCESS;
273 }
274
275 DEFUN (no_debug_zebra_packet,
276 no_debug_zebra_packet_cmd,
277 "no debug zebra packet [<recv|send>]",
278 NO_STR
279 DEBUG_STR
280 "Zebra configuration\n"
281 "Debug option set for zebra packet\n"
282 "Debug option set for receive packet\n"
283 "Debug option set for send packet\n")
284 {
285 int idx = 0;
286 if (argc == 4 || argv_find (argv, argc, "send", &idx))
287 UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
288 if (argc == 4 || argv_find (argv, argc, "recv", &idx))
289 UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
290 return CMD_SUCCESS;
291 }
292
293 DEFUN (no_debug_zebra_kernel,
294 no_debug_zebra_kernel_cmd,
295 "no debug zebra kernel",
296 NO_STR
297 DEBUG_STR
298 "Zebra configuration\n"
299 "Debug option set for zebra between kernel interface\n")
300 {
301 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
302 return CMD_SUCCESS;
303 }
304
305 DEFUN (no_debug_zebra_kernel_msgdump,
306 no_debug_zebra_kernel_msgdump_cmd,
307 "no debug zebra kernel msgdump [<recv|send>]",
308 NO_STR
309 DEBUG_STR
310 "Zebra configuration\n"
311 "Debug option set for zebra between kernel interface\n"
312 "Dump raw netlink messages, sent and received\n"
313 "Dump raw netlink messages received\n"
314 "Dump raw netlink messages sent\n")
315 {
316 int idx = 0;
317 if (argc == 5 || argv_find (argv, argc, "recv", &idx))
318 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
319 if (argc == 5 || argv_find (argv, argc, "send", &idx))
320 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
321
322 return CMD_SUCCESS;
323 }
324
325 DEFUN (no_debug_zebra_rib,
326 no_debug_zebra_rib_cmd,
327 "no debug zebra rib",
328 NO_STR
329 DEBUG_STR
330 "Zebra configuration\n"
331 "Debug zebra RIB\n")
332 {
333 zebra_debug_rib = 0;
334 return CMD_SUCCESS;
335 }
336
337 DEFUN (no_debug_zebra_rib_detailed,
338 no_debug_zebra_rib_detailed_cmd,
339 "no debug zebra rib detailed",
340 NO_STR
341 DEBUG_STR
342 "Zebra configuration\n"
343 "Debug zebra RIB\n"
344 "Detailed debugs\n")
345 {
346 UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
347 return CMD_SUCCESS;
348 }
349
350 DEFUN (no_debug_zebra_fpm,
351 no_debug_zebra_fpm_cmd,
352 "no debug zebra fpm",
353 NO_STR
354 DEBUG_STR
355 "Zebra configuration\n"
356 "Debug zebra FPM events\n")
357 {
358 zebra_debug_fpm = 0;
359 return CMD_SUCCESS;
360 }
361
362 /* Debug node. */
363 struct cmd_node debug_node =
364 {
365 DEBUG_NODE,
366 "", /* Debug node has no interface. */
367 1
368 };
369
370 static int
371 config_write_debug (struct vty *vty)
372 {
373 int write = 0;
374
375 if (IS_ZEBRA_DEBUG_EVENT)
376 {
377 vty_out (vty, "debug zebra events\n");
378 write++;
379 }
380 if (IS_ZEBRA_DEBUG_PACKET)
381 {
382 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
383 {
384 vty_out (vty, "debug zebra packet%s\n",
385 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
386 write++;
387 }
388 else
389 {
390 if (IS_ZEBRA_DEBUG_SEND)
391 vty_out (vty, "debug zebra packet send%s\n",
392 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
393 else
394 vty_out (vty, "debug zebra packet recv%s\n",
395 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
396 write++;
397 }
398 }
399 if (IS_ZEBRA_DEBUG_KERNEL)
400 {
401 vty_out (vty, "debug zebra kernel\n");
402 write++;
403 }
404 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
405 {
406 vty_out (vty, "debug zebra kernel msgdump recv\n");
407 write++;
408 }
409 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
410 {
411 vty_out (vty, "debug zebra kernel msgdump send\n");
412 write++;
413 }
414 /* Check here using flags as the 'macro' does an OR */
415 if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
416 {
417 vty_out (vty, "debug zebra rib\n");
418 write++;
419 }
420 if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
421 {
422 vty_out (vty, "debug zebra rib detailed\n");
423 write++;
424 }
425 if (IS_ZEBRA_DEBUG_FPM)
426 {
427 vty_out (vty, "debug zebra fpm\n");
428 write++;
429 }
430 if (IS_ZEBRA_DEBUG_NHT)
431 {
432 vty_out (vty, "debug zebra nht\n");
433 write++;
434 }
435 if (IS_ZEBRA_DEBUG_MPLS)
436 {
437 vty_out (vty, "debug zebra mpls\n");
438 write++;
439 }
440 if (IS_ZEBRA_DEBUG_VXLAN)
441 {
442 vty_out (vty, "debug zebra vxlan\n");
443 write++;
444 }
445 return write;
446 }
447
448 void
449 zebra_debug_init (void)
450 {
451 zebra_debug_event = 0;
452 zebra_debug_packet = 0;
453 zebra_debug_kernel = 0;
454 zebra_debug_rib = 0;
455 zebra_debug_fpm = 0;
456 zebra_debug_mpls = 0;
457 zebra_debug_vxlan = 0;
458
459 install_node (&debug_node, config_write_debug);
460
461 install_element (VIEW_NODE, &show_debugging_zebra_cmd);
462
463 install_element (ENABLE_NODE, &debug_zebra_events_cmd);
464 install_element (ENABLE_NODE, &debug_zebra_nht_cmd);
465 install_element (ENABLE_NODE, &debug_zebra_mpls_cmd);
466 install_element (ENABLE_NODE, &debug_zebra_vxlan_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_rib_detailed_cmd);
472 install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
473 install_element (ENABLE_NODE, &no_debug_zebra_events_cmd);
474 install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd);
475 install_element (ENABLE_NODE, &no_debug_zebra_mpls_cmd);
476 install_element (ENABLE_NODE, &no_debug_zebra_vxlan_cmd);
477 install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd);
478 install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd);
479 install_element (ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
480 install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd);
481 install_element (ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd);
482 install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
483
484 install_element (CONFIG_NODE, &debug_zebra_events_cmd);
485 install_element (CONFIG_NODE, &debug_zebra_nht_cmd);
486 install_element (CONFIG_NODE, &debug_zebra_mpls_cmd);
487 install_element (CONFIG_NODE, &debug_zebra_vxlan_cmd);
488 install_element (CONFIG_NODE, &debug_zebra_packet_cmd);
489 install_element (CONFIG_NODE, &debug_zebra_kernel_cmd);
490 install_element (CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
491 install_element (CONFIG_NODE, &debug_zebra_rib_cmd);
492 install_element (CONFIG_NODE, &debug_zebra_rib_detailed_cmd);
493 install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
494 install_element (CONFIG_NODE, &no_debug_zebra_events_cmd);
495 install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd);
496 install_element (CONFIG_NODE, &no_debug_zebra_mpls_cmd);
497 install_element (CONFIG_NODE, &no_debug_zebra_vxlan_cmd);
498 install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd);
499 install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd);
500 install_element (CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
501 install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd);
502 install_element (CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd);
503 install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);
504 }