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