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