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