]> git.proxmox.com Git - mirror_frr.git/blob - zebra/debug.c
build, vtysh: extract vtysh commands from .xref
[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 #include "zebra/debug_clippy.c"
27
28 /* For debug statement. */
29 unsigned long zebra_debug_event;
30 unsigned long zebra_debug_packet;
31 unsigned long zebra_debug_kernel;
32 unsigned long zebra_debug_rib;
33 unsigned long zebra_debug_fpm;
34 unsigned long zebra_debug_nht;
35 unsigned long zebra_debug_mpls;
36 unsigned long zebra_debug_vxlan;
37 unsigned long zebra_debug_pw;
38 unsigned long zebra_debug_dplane;
39 unsigned long zebra_debug_dplane_dpdk;
40 unsigned long zebra_debug_mlag;
41 unsigned long zebra_debug_nexthop;
42 unsigned long zebra_debug_evpn_mh;
43 unsigned long zebra_debug_pbr;
44 unsigned long zebra_debug_neigh;
45
46 DEFINE_HOOK(zebra_debug_show_debugging, (struct vty *vty), (vty));
47
48 DEFUN_NOSH (show_debugging_zebra,
49 show_debugging_zebra_cmd,
50 "show debugging [zebra]",
51 SHOW_STR
52 "Debugging information\n"
53 "Zebra configuration\n")
54 {
55 vty_out(vty, "Zebra debugging status:\n");
56
57 if (IS_ZEBRA_DEBUG_EVENT)
58 vty_out(vty, " Zebra event debugging is on\n");
59
60 if (IS_ZEBRA_DEBUG_PACKET) {
61 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) {
62 vty_out(vty, " Zebra packet%s debugging is on\n",
63 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
64 } else {
65 if (IS_ZEBRA_DEBUG_SEND)
66 vty_out(vty,
67 " Zebra packet send%s debugging is on\n",
68 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
69 else
70 vty_out(vty,
71 " Zebra packet receive%s debugging is on\n",
72 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
73 }
74 }
75
76 if (IS_ZEBRA_DEBUG_KERNEL)
77 vty_out(vty, " Zebra kernel debugging is on\n");
78 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
79 vty_out(vty,
80 " Zebra kernel netlink message dumps (send) are on\n");
81 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
82 vty_out(vty,
83 " Zebra kernel netlink message dumps (recv) are on\n");
84
85 /* Check here using flags as the 'macro' does an OR */
86 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
87 vty_out(vty, " Zebra RIB detailed debugging is on\n");
88 else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
89 vty_out(vty, " Zebra RIB debugging is on\n");
90
91 if (IS_ZEBRA_DEBUG_FPM)
92 vty_out(vty, " Zebra FPM debugging is on\n");
93 if (IS_ZEBRA_DEBUG_NHT_DETAILED)
94 vty_out(vty, " Zebra detailed next-hop tracking debugging is on\n");
95 else if (IS_ZEBRA_DEBUG_NHT)
96 vty_out(vty, " Zebra next-hop tracking debugging is on\n");
97 if (IS_ZEBRA_DEBUG_MPLS_DETAIL)
98 vty_out(vty, " Zebra detailed MPLS debugging is on\n");
99 else if (IS_ZEBRA_DEBUG_MPLS)
100 vty_out(vty, " Zebra MPLS debugging is on\n");
101
102 if (IS_ZEBRA_DEBUG_VXLAN)
103 vty_out(vty, " Zebra VXLAN debugging is on\n");
104 if (IS_ZEBRA_DEBUG_PW)
105 vty_out(vty, " Zebra pseudowire debugging is on\n");
106 if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
107 vty_out(vty, " Zebra detailed dataplane debugging is on\n");
108 else if (IS_ZEBRA_DEBUG_DPLANE)
109 vty_out(vty, " Zebra dataplane debugging is on\n");
110 if (IS_ZEBRA_DEBUG_DPLANE_DPDK_DETAIL)
111 vty_out(vty,
112 " Zebra detailed dpdk dataplane debugging is on\n");
113 else if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
114 vty_out(vty, " Zebra dataplane dpdk debugging is on\n");
115 if (IS_ZEBRA_DEBUG_MLAG)
116 vty_out(vty, " Zebra mlag debugging is on\n");
117 if (IS_ZEBRA_DEBUG_NHG_DETAIL)
118 vty_out(vty, " Zebra detailed nexthop debugging is on\n");
119 else if (IS_ZEBRA_DEBUG_NHG)
120 vty_out(vty, " Zebra nexthop debugging is on\n");
121
122 if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
123 vty_out(vty, " Zebra EVPN-MH ethernet segment debugging is on\n");
124
125 if (IS_ZEBRA_DEBUG_EVPN_MH_NH)
126 vty_out(vty, " Zebra EVPN-MH nexthop debugging is on\n");
127
128 if (IS_ZEBRA_DEBUG_EVPN_MH_MAC)
129 vty_out(vty, " Zebra EVPN-MH MAC debugging is on\n");
130
131 if (IS_ZEBRA_DEBUG_EVPN_MH_NEIGH)
132 vty_out(vty, " Zebra EVPN-MH Neigh debugging is on\n");
133
134 if (IS_ZEBRA_DEBUG_PBR)
135 vty_out(vty, " Zebra PBR debugging is on\n");
136
137 hook_call(zebra_debug_show_debugging, vty);
138
139 cmd_show_lib_debugs(vty);
140
141 return CMD_SUCCESS;
142 }
143
144 DEFUN (debug_zebra_events,
145 debug_zebra_events_cmd,
146 "debug zebra events",
147 DEBUG_STR
148 "Zebra configuration\n"
149 "Debug option set for zebra events\n")
150 {
151 zebra_debug_event = ZEBRA_DEBUG_EVENT;
152 return CMD_SUCCESS;
153 }
154
155 DEFUN (debug_zebra_nht,
156 debug_zebra_nht_cmd,
157 "debug zebra nht [detailed]",
158 DEBUG_STR
159 "Zebra configuration\n"
160 "Debug option set for zebra next hop tracking\n"
161 "Debug option set for detailed info\n")
162 {
163 int idx = 0;
164
165 zebra_debug_nht = ZEBRA_DEBUG_NHT;
166
167 if (argv_find(argv, argc, "detailed", &idx))
168 zebra_debug_nht |= ZEBRA_DEBUG_NHT_DETAILED;
169
170 return CMD_SUCCESS;
171 }
172
173 DEFPY (debug_zebra_mpls,
174 debug_zebra_mpls_cmd,
175 "debug zebra mpls [detailed$detail]",
176 DEBUG_STR
177 "Zebra configuration\n"
178 "Debug option set for zebra MPLS LSPs\n"
179 "Debug option for detailed info\n")
180 {
181 zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
182
183 if (detail)
184 zebra_debug_mpls |= ZEBRA_DEBUG_MPLS_DETAILED;
185
186 return CMD_SUCCESS;
187 }
188
189 DEFPY (debug_zebra_vxlan,
190 debug_zebra_vxlan_cmd,
191 "debug zebra vxlan",
192 DEBUG_STR
193 "Zebra configuration\n"
194 "Debug option set for zebra VxLAN (EVPN)\n")
195 {
196 zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
197 return CMD_SUCCESS;
198 }
199
200 DEFUN (debug_zebra_pw,
201 debug_zebra_pw_cmd,
202 "[no] debug zebra pseudowires",
203 NO_STR
204 DEBUG_STR
205 "Zebra configuration\n"
206 "Debug option set for zebra pseudowires\n")
207 {
208 if (strmatch(argv[0]->text, "no"))
209 UNSET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
210 else
211 SET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
212 return CMD_SUCCESS;
213 }
214
215 DEFUN (debug_zebra_packet,
216 debug_zebra_packet_cmd,
217 "debug zebra packet [<recv|send>] [detail]",
218 DEBUG_STR
219 "Zebra configuration\n"
220 "Debug option set for zebra packet\n"
221 "Debug option set for receive packet\n"
222 "Debug option set for send packet\n"
223 "Debug option set for detailed info\n")
224 {
225 int idx = 0;
226 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
227
228 if (argv_find(argv, argc, "send", &idx))
229 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
230 else if (argv_find(argv, argc, "recv", &idx))
231 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
232 else {
233 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
234 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
235 }
236
237 if (argv_find(argv, argc, "detail", &idx))
238 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
239
240 return CMD_SUCCESS;
241 }
242
243 DEFUN (debug_zebra_kernel,
244 debug_zebra_kernel_cmd,
245 "debug zebra kernel",
246 DEBUG_STR
247 "Zebra configuration\n"
248 "Debug option set for zebra between kernel interface\n")
249 {
250 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
251
252 return CMD_SUCCESS;
253 }
254
255 #if defined(HAVE_NETLINK)
256 DEFUN (debug_zebra_kernel_msgdump,
257 debug_zebra_kernel_msgdump_cmd,
258 "debug zebra kernel msgdump [<recv|send>]",
259 DEBUG_STR
260 "Zebra configuration\n"
261 "Debug option set for zebra between kernel interface\n"
262 "Dump raw netlink messages, sent and received\n"
263 "Dump raw netlink messages received\n"
264 "Dump raw netlink messages sent\n")
265 {
266 int idx = 0;
267
268 if (argv_find(argv, argc, "recv", &idx))
269 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
270 else if (argv_find(argv, argc, "send", &idx))
271 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
272 else {
273 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
274 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
275 }
276
277 return CMD_SUCCESS;
278 }
279 #endif
280
281 DEFUN (debug_zebra_rib,
282 debug_zebra_rib_cmd,
283 "debug zebra rib [detailed]",
284 DEBUG_STR
285 "Zebra configuration\n"
286 "Debug RIB events\n"
287 "Detailed debugs\n")
288 {
289 int idx = 0;
290 SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
291
292 if (argv_find(argv, argc, "detailed", &idx))
293 SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
294
295 return CMD_SUCCESS;
296 }
297
298 DEFUN (debug_zebra_fpm,
299 debug_zebra_fpm_cmd,
300 "debug zebra fpm",
301 DEBUG_STR
302 "Zebra configuration\n"
303 "Debug zebra FPM events\n")
304 {
305 SET_FLAG(zebra_debug_fpm, ZEBRA_DEBUG_FPM);
306 return CMD_SUCCESS;
307 }
308
309 DEFUN (debug_zebra_dplane,
310 debug_zebra_dplane_cmd,
311 "debug zebra dplane [detailed]",
312 DEBUG_STR
313 "Zebra configuration\n"
314 "Debug zebra dataplane events\n"
315 "Detailed debug information\n")
316 {
317 int idx = 0;
318
319 SET_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE);
320
321 if (argv_find(argv, argc, "detailed", &idx))
322 SET_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE_DETAILED);
323
324 return CMD_SUCCESS;
325 }
326
327 DEFPY(debug_zebra_dplane_dpdk, debug_zebra_dplane_dpdk_cmd,
328 "[no$no] debug zebra dplane dpdk [detailed$detail]",
329 NO_STR DEBUG_STR
330 "Zebra configuration\n"
331 "Debug zebra dataplane events\n"
332 "Debug zebra DPDK offload events\n"
333 "Detailed debug information\n")
334 {
335 if (no) {
336 UNSET_FLAG(zebra_debug_dplane_dpdk, ZEBRA_DEBUG_DPLANE_DPDK);
337 UNSET_FLAG(zebra_debug_dplane_dpdk,
338 ZEBRA_DEBUG_DPLANE_DPDK_DETAIL);
339 } else {
340 SET_FLAG(zebra_debug_dplane_dpdk, ZEBRA_DEBUG_DPLANE_DPDK);
341
342 if (detail)
343 SET_FLAG(zebra_debug_dplane,
344 ZEBRA_DEBUG_DPLANE_DPDK_DETAIL);
345 }
346
347 return CMD_SUCCESS;
348 }
349
350 DEFUN (debug_zebra_pbr,
351 debug_zebra_pbr_cmd,
352 "debug zebra pbr",
353 DEBUG_STR
354 "Zebra configuration\n"
355 "Debug zebra pbr events\n")
356 {
357 SET_FLAG(zebra_debug_pbr, ZEBRA_DEBUG_PBR);
358 return CMD_SUCCESS;
359 }
360
361 DEFPY (debug_zebra_neigh,
362 debug_zebra_neigh_cmd,
363 "[no$no] debug zebra neigh",
364 NO_STR
365 DEBUG_STR
366 "Zebra configuration\n"
367 "Debug zebra neigh events\n")
368 {
369 if (no)
370 UNSET_FLAG(zebra_debug_neigh, ZEBRA_DEBUG_NEIGH);
371 else
372 SET_FLAG(zebra_debug_neigh, ZEBRA_DEBUG_NEIGH);
373
374 return CMD_SUCCESS;
375 }
376
377 DEFPY (debug_zebra_mlag,
378 debug_zebra_mlag_cmd,
379 "[no$no] debug zebra mlag",
380 NO_STR
381 DEBUG_STR
382 "Zebra configuration\n"
383 "Debug option set for mlag events\n")
384 {
385 if (no)
386 UNSET_FLAG(zebra_debug_mlag, ZEBRA_DEBUG_MLAG);
387 else
388 SET_FLAG(zebra_debug_mlag, ZEBRA_DEBUG_MLAG);
389 return CMD_SUCCESS;
390 }
391
392 DEFPY (debug_zebra_evpn_mh,
393 debug_zebra_evpn_mh_cmd,
394 "[no$no] debug zebra evpn mh <es$es|mac$mac|neigh$neigh|nh$nh>",
395 NO_STR
396 DEBUG_STR
397 "Zebra configuration\n"
398 "EVPN\n"
399 "Multihoming\n"
400 "Ethernet Segment Debugging\n"
401 "MAC Debugging\n"
402 "Neigh Debugging\n"
403 "Nexthop Debugging\n")
404 {
405 if (es) {
406 if (no)
407 UNSET_FLAG(zebra_debug_evpn_mh, ZEBRA_DEBUG_EVPN_MH_ES);
408 else
409 SET_FLAG(zebra_debug_evpn_mh, ZEBRA_DEBUG_EVPN_MH_ES);
410 }
411
412 if (mac) {
413 if (no)
414 UNSET_FLAG(zebra_debug_evpn_mh,
415 ZEBRA_DEBUG_EVPN_MH_MAC);
416 else
417 SET_FLAG(zebra_debug_evpn_mh, ZEBRA_DEBUG_EVPN_MH_MAC);
418 }
419
420 if (neigh) {
421 if (no)
422 UNSET_FLAG(zebra_debug_evpn_mh,
423 ZEBRA_DEBUG_EVPN_MH_NEIGH);
424 else
425 SET_FLAG(zebra_debug_evpn_mh,
426 ZEBRA_DEBUG_EVPN_MH_NEIGH);
427 }
428
429 if (nh) {
430 if (no)
431 UNSET_FLAG(zebra_debug_evpn_mh, ZEBRA_DEBUG_EVPN_MH_NH);
432 else
433 SET_FLAG(zebra_debug_evpn_mh, ZEBRA_DEBUG_EVPN_MH_NH);
434 }
435
436 return CMD_SUCCESS;
437 }
438
439 DEFUN (no_debug_zebra_events,
440 no_debug_zebra_events_cmd,
441 "no debug zebra events",
442 NO_STR
443 DEBUG_STR
444 "Zebra configuration\n"
445 "Debug option set for zebra events\n")
446 {
447 zebra_debug_event = 0;
448 return CMD_SUCCESS;
449 }
450
451 DEFUN (no_debug_zebra_nht,
452 no_debug_zebra_nht_cmd,
453 "no debug zebra nht [detailed]",
454 NO_STR
455 DEBUG_STR
456 "Zebra configuration\n"
457 "Debug option set for zebra next hop tracking\n"
458 "Debug option set for detailed info\n")
459 {
460 zebra_debug_nht = 0;
461 return CMD_SUCCESS;
462 }
463
464 DEFUN (no_debug_zebra_mpls,
465 no_debug_zebra_mpls_cmd,
466 "no debug zebra mpls [detailed]",
467 NO_STR
468 DEBUG_STR
469 "Zebra configuration\n"
470 "Debug option set for zebra MPLS LSPs\n"
471 "Debug option for zebra detailed info\n")
472 {
473 zebra_debug_mpls = 0;
474 return CMD_SUCCESS;
475 }
476
477 DEFUN (no_debug_zebra_vxlan,
478 no_debug_zebra_vxlan_cmd,
479 "no debug zebra vxlan",
480 NO_STR
481 DEBUG_STR
482 "Zebra configuration\n"
483 "Debug option set for zebra VxLAN (EVPN)\n")
484 {
485 zebra_debug_vxlan = 0;
486 return CMD_SUCCESS;
487 }
488
489 DEFUN (no_debug_zebra_packet,
490 no_debug_zebra_packet_cmd,
491 "no debug zebra packet [<recv|send>] [detail]",
492 NO_STR
493 DEBUG_STR
494 "Zebra configuration\n"
495 "Debug option set for zebra packet\n"
496 "Debug option set for receive packet\n"
497 "Debug option set for send packet\n"
498 "Debug option set for detailed info\n")
499 {
500 zebra_debug_packet = 0;
501 return CMD_SUCCESS;
502 }
503
504 DEFUN (no_debug_zebra_kernel,
505 no_debug_zebra_kernel_cmd,
506 "no debug zebra kernel",
507 NO_STR
508 DEBUG_STR
509 "Zebra configuration\n"
510 "Debug option set for zebra between kernel interface\n")
511 {
512 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
513
514 return CMD_SUCCESS;
515 }
516
517 #if defined(HAVE_NETLINK)
518 DEFUN (no_debug_zebra_kernel_msgdump,
519 no_debug_zebra_kernel_msgdump_cmd,
520 "no debug zebra kernel msgdump [<recv|send>]",
521 NO_STR
522 DEBUG_STR
523 "Zebra configuration\n"
524 "Debug option set for zebra between kernel interface\n"
525 "Dump raw netlink messages, sent and received\n"
526 "Dump raw netlink messages received\n"
527 "Dump raw netlink messages sent\n")
528 {
529 int idx = 0;
530
531 if (argv_find(argv, argc, "recv", &idx))
532 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
533 else if (argv_find(argv, argc, "send", &idx))
534 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
535 else {
536 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
537 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
538 }
539
540 return CMD_SUCCESS;
541 }
542 #endif
543
544 DEFUN (no_debug_zebra_rib,
545 no_debug_zebra_rib_cmd,
546 "no debug zebra rib [detailed]",
547 NO_STR
548 DEBUG_STR
549 "Zebra configuration\n"
550 "Debug zebra RIB\n"
551 "Detailed debugs\n")
552 {
553 zebra_debug_rib = 0;
554 return CMD_SUCCESS;
555 }
556
557 DEFUN (no_debug_zebra_fpm,
558 no_debug_zebra_fpm_cmd,
559 "no debug zebra fpm",
560 NO_STR
561 DEBUG_STR
562 "Zebra configuration\n"
563 "Debug zebra FPM events\n")
564 {
565 zebra_debug_fpm = 0;
566 return CMD_SUCCESS;
567 }
568
569 DEFUN (no_debug_zebra_dplane,
570 no_debug_zebra_dplane_cmd,
571 "no debug zebra dplane",
572 NO_STR
573 DEBUG_STR
574 "Zebra configuration\n"
575 "Debug zebra dataplane events\n")
576 {
577 zebra_debug_dplane = 0;
578 return CMD_SUCCESS;
579 }
580
581 DEFUN (no_debug_zebra_pbr,
582 no_debug_zebra_pbr_cmd,
583 "no debug zebra pbr",
584 NO_STR
585 DEBUG_STR
586 "Zebra configuration\n"
587 "Debug zebra pbr events\n")
588 {
589 zebra_debug_pbr = 0;
590 return CMD_SUCCESS;
591 }
592
593 DEFPY (debug_zebra_nexthop,
594 debug_zebra_nexthop_cmd,
595 "[no$no] debug zebra nexthop [detail$detail]",
596 NO_STR
597 DEBUG_STR
598 "Zebra configuration\n"
599 "Debug zebra nexthop events\n"
600 "Detailed information\n")
601 {
602 if (no)
603 zebra_debug_nexthop = 0;
604 else {
605 SET_FLAG(zebra_debug_nexthop, ZEBRA_DEBUG_NHG);
606
607 if (detail)
608 SET_FLAG(zebra_debug_nexthop,
609 ZEBRA_DEBUG_NHG_DETAILED);
610 }
611
612 return CMD_SUCCESS;
613 }
614
615 /* Debug node. */
616 static int config_write_debug(struct vty *vty);
617 struct cmd_node debug_node = {
618 .name = "debug",
619 .node = DEBUG_NODE,
620 .prompt = "",
621 .config_write = config_write_debug,
622 };
623
624 static int config_write_debug(struct vty *vty)
625 {
626 int write = 0;
627
628 if (IS_ZEBRA_DEBUG_EVENT) {
629 vty_out(vty, "debug zebra events\n");
630 write++;
631 }
632 if (IS_ZEBRA_DEBUG_PACKET) {
633 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) {
634 vty_out(vty, "debug zebra packet%s\n",
635 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
636 write++;
637 } else {
638 if (IS_ZEBRA_DEBUG_SEND)
639 vty_out(vty, "debug zebra packet send%s\n",
640 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
641 else
642 vty_out(vty, "debug zebra packet recv%s\n",
643 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
644 write++;
645 }
646 }
647
648 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND
649 && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
650 vty_out(vty, "debug zebra kernel msgdump\n");
651 write++;
652 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
653 vty_out(vty, "debug zebra kernel msgdump recv\n");
654 write++;
655 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
656 vty_out(vty, "debug zebra kernel msgdump send\n");
657 write++;
658 }
659
660 if (IS_ZEBRA_DEBUG_KERNEL) {
661 vty_out(vty, "debug zebra kernel\n");
662 write++;
663 }
664
665 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
666 vty_out(vty, "debug zebra rib detailed\n");
667 write++;
668 } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
669 vty_out(vty, "debug zebra rib\n");
670 write++;
671 }
672
673 if (IS_ZEBRA_DEBUG_FPM) {
674 vty_out(vty, "debug zebra fpm\n");
675 write++;
676 }
677
678 if (IS_ZEBRA_DEBUG_NHT_DETAILED) {
679 vty_out(vty, "debug zebra nht detailed\n");
680 write++;
681 } else if (IS_ZEBRA_DEBUG_NHT) {
682 vty_out(vty, "debug zebra nht\n");
683 write++;
684 }
685
686 if (IS_ZEBRA_DEBUG_MPLS_DETAIL) {
687 vty_out(vty, "debug zebra mpls detailed\n");
688 write++;
689 } else if (IS_ZEBRA_DEBUG_MPLS) {
690 vty_out(vty, "debug zebra mpls\n");
691 write++;
692 }
693
694 if (IS_ZEBRA_DEBUG_VXLAN) {
695 vty_out(vty, "debug zebra vxlan\n");
696 write++;
697 }
698 if (IS_ZEBRA_DEBUG_MLAG) {
699 vty_out(vty, "debug zebra mlag\n");
700 write++;
701 }
702 if (IS_ZEBRA_DEBUG_EVPN_MH_ES) {
703 vty_out(vty, "debug zebra evpn mh es\n");
704 write++;
705 }
706 if (IS_ZEBRA_DEBUG_EVPN_MH_NH) {
707 vty_out(vty, "debug zebra evpn mh nh\n");
708 write++;
709 }
710 if (IS_ZEBRA_DEBUG_EVPN_MH_MAC) {
711 vty_out(vty, "debug zebra evpn mh mac\n");
712 write++;
713 }
714 if (IS_ZEBRA_DEBUG_EVPN_MH_NEIGH) {
715 vty_out(vty, "debug zebra evpn mh neigh\n");
716 write++;
717 }
718 if (IS_ZEBRA_DEBUG_PW) {
719 vty_out(vty, "debug zebra pseudowires\n");
720 write++;
721 }
722
723 if (CHECK_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE_DETAILED)) {
724 vty_out(vty, "debug zebra dplane detailed\n");
725 write++;
726 } else if (CHECK_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE)) {
727 vty_out(vty, "debug zebra dplane\n");
728 write++;
729 }
730
731 if (CHECK_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE_DPDK_DETAIL)) {
732 vty_out(vty, "debug zebra dplane dpdk detailed\n");
733 write++;
734 } else if (CHECK_FLAG(zebra_debug_dplane, ZEBRA_DEBUG_DPLANE_DPDK)) {
735 vty_out(vty, "debug zebra dplane dpdk\n");
736 write++;
737 }
738
739 if (CHECK_FLAG(zebra_debug_nexthop, ZEBRA_DEBUG_NHG_DETAILED)) {
740 vty_out(vty, "debug zebra nexthop detail\n");
741 write++;
742 } else if (CHECK_FLAG(zebra_debug_nexthop, ZEBRA_DEBUG_NHG)) {
743 vty_out(vty, "debug zebra nexthop\n");
744 write++;
745 }
746
747 if (IS_ZEBRA_DEBUG_PBR) {
748 vty_out(vty, "debug zebra pbr\n");
749 write++;
750 }
751
752 if (IS_ZEBRA_DEBUG_NEIGH) {
753 vty_out(vty, "debug zebra neigh\n");
754 write++;
755 }
756
757 return write;
758 }
759
760 void zebra_debug_init(void)
761 {
762 zebra_debug_event = 0;
763 zebra_debug_packet = 0;
764 zebra_debug_kernel = 0;
765 zebra_debug_rib = 0;
766 zebra_debug_fpm = 0;
767 zebra_debug_mpls = 0;
768 zebra_debug_vxlan = 0;
769 zebra_debug_pw = 0;
770 zebra_debug_dplane = 0;
771 zebra_debug_dplane_dpdk = 0;
772 zebra_debug_mlag = 0;
773 zebra_debug_evpn_mh = 0;
774 zebra_debug_nht = 0;
775 zebra_debug_nexthop = 0;
776 zebra_debug_pbr = 0;
777 zebra_debug_neigh = 0;
778
779 install_node(&debug_node);
780
781 install_element(ENABLE_NODE, &show_debugging_zebra_cmd);
782
783 install_element(ENABLE_NODE, &debug_zebra_events_cmd);
784 install_element(ENABLE_NODE, &debug_zebra_nht_cmd);
785 install_element(ENABLE_NODE, &debug_zebra_mpls_cmd);
786 install_element(ENABLE_NODE, &debug_zebra_vxlan_cmd);
787 install_element(ENABLE_NODE, &debug_zebra_pw_cmd);
788 install_element(ENABLE_NODE, &debug_zebra_packet_cmd);
789 install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
790 #if defined(HAVE_NETLINK)
791 install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
792 #endif
793 install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
794 install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
795 install_element(ENABLE_NODE, &debug_zebra_dplane_cmd);
796 install_element(ENABLE_NODE, &debug_zebra_mlag_cmd);
797 install_element(ENABLE_NODE, &debug_zebra_nexthop_cmd);
798 install_element(ENABLE_NODE, &debug_zebra_pbr_cmd);
799 install_element(ENABLE_NODE, &debug_zebra_neigh_cmd);
800 install_element(ENABLE_NODE, &debug_zebra_dplane_dpdk_cmd);
801 install_element(ENABLE_NODE, &no_debug_zebra_events_cmd);
802 install_element(ENABLE_NODE, &no_debug_zebra_nht_cmd);
803 install_element(ENABLE_NODE, &no_debug_zebra_mpls_cmd);
804 install_element(ENABLE_NODE, &no_debug_zebra_vxlan_cmd);
805 install_element(ENABLE_NODE, &no_debug_zebra_packet_cmd);
806 install_element(ENABLE_NODE, &no_debug_zebra_kernel_cmd);
807 #if defined(HAVE_NETLINK)
808 install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
809 #endif
810 install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
811 install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
812 install_element(ENABLE_NODE, &no_debug_zebra_dplane_cmd);
813 install_element(ENABLE_NODE, &no_debug_zebra_pbr_cmd);
814 install_element(ENABLE_NODE, &debug_zebra_evpn_mh_cmd);
815
816 install_element(CONFIG_NODE, &debug_zebra_events_cmd);
817 install_element(CONFIG_NODE, &debug_zebra_nht_cmd);
818 install_element(CONFIG_NODE, &debug_zebra_mpls_cmd);
819 install_element(CONFIG_NODE, &debug_zebra_vxlan_cmd);
820 install_element(CONFIG_NODE, &debug_zebra_pw_cmd);
821 install_element(CONFIG_NODE, &debug_zebra_packet_cmd);
822 install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
823 #if defined(HAVE_NETLINK)
824 install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
825 #endif
826 install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
827 install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
828 install_element(CONFIG_NODE, &debug_zebra_dplane_cmd);
829 install_element(CONFIG_NODE, &debug_zebra_dplane_dpdk_cmd);
830 install_element(CONFIG_NODE, &debug_zebra_nexthop_cmd);
831 install_element(CONFIG_NODE, &debug_zebra_pbr_cmd);
832 install_element(CONFIG_NODE, &debug_zebra_neigh_cmd);
833
834 install_element(CONFIG_NODE, &no_debug_zebra_events_cmd);
835 install_element(CONFIG_NODE, &no_debug_zebra_nht_cmd);
836 install_element(CONFIG_NODE, &no_debug_zebra_mpls_cmd);
837 install_element(CONFIG_NODE, &no_debug_zebra_vxlan_cmd);
838 install_element(CONFIG_NODE, &no_debug_zebra_packet_cmd);
839 install_element(CONFIG_NODE, &no_debug_zebra_kernel_cmd);
840 #if defined(HAVE_NETLINK)
841 install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
842 #endif
843 install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
844 install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
845 install_element(CONFIG_NODE, &no_debug_zebra_dplane_cmd);
846 install_element(CONFIG_NODE, &no_debug_zebra_pbr_cmd);
847 install_element(CONFIG_NODE, &debug_zebra_mlag_cmd);
848 install_element(CONFIG_NODE, &debug_zebra_evpn_mh_cmd);
849 }