]> git.proxmox.com Git - mirror_frr.git/blame - zebra/debug.c
build, vtysh: extract vtysh commands from .xref
[mirror_frr.git] / zebra / debug.c
CommitLineData
718e3744 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 *
896014f4
DL
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
718e3744 20 */
21
22#include <zebra.h>
23#include "command.h"
24#include "debug.h"
25
23666725 26#include "zebra/debug_clippy.c"
23666725 27
718e3744 28/* For debug statement. */
29unsigned long zebra_debug_event;
30unsigned long zebra_debug_packet;
31unsigned long zebra_debug_kernel;
b0498dc6 32unsigned long zebra_debug_rib;
5adc2528 33unsigned long zebra_debug_fpm;
fb018d25 34unsigned long zebra_debug_nht;
7758e3f3 35unsigned long zebra_debug_mpls;
13d60d35 36unsigned long zebra_debug_vxlan;
6833ae01 37unsigned long zebra_debug_pw;
6582b002 38unsigned long zebra_debug_dplane;
36c3b296 39unsigned long zebra_debug_dplane_dpdk;
23666725 40unsigned long zebra_debug_mlag;
d4b4b70c 41unsigned long zebra_debug_nexthop;
94eb1635 42unsigned long zebra_debug_evpn_mh;
8eeca5a2 43unsigned long zebra_debug_pbr;
4cf4fad1 44unsigned long zebra_debug_neigh;
718e3744 45
77151b6f
PG
46DEFINE_HOOK(zebra_debug_show_debugging, (struct vty *vty), (vty));
47
87f6dc50
DS
48DEFUN_NOSH (show_debugging_zebra,
49 show_debugging_zebra_cmd,
50 "show debugging [zebra]",
51 SHOW_STR
52 "Debugging information\n"
53 "Zebra configuration\n")
718e3744 54{
d62a17ae 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 }
718e3744 74 }
d62a17ae 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 */
d62a17ae 86 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
87 vty_out(vty, " Zebra RIB detailed debugging is on\n");
ba9d46ff
DW
88 else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
89 vty_out(vty, " Zebra RIB debugging is on\n");
d62a17ae 90
91 if (IS_ZEBRA_DEBUG_FPM)
92 vty_out(vty, " Zebra FPM debugging is on\n");
50872b08
DS
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)
d62a17ae 96 vty_out(vty, " Zebra next-hop tracking debugging is on\n");
04dda092
MS
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)
d62a17ae 100 vty_out(vty, " Zebra MPLS debugging is on\n");
04dda092 101
95744ad8
DS
102 if (IS_ZEBRA_DEBUG_VXLAN)
103 vty_out(vty, " Zebra VXLAN debugging is on\n");
6833ae01 104 if (IS_ZEBRA_DEBUG_PW)
105 vty_out(vty, " Zebra pseudowire debugging is on\n");
6582b002
MS
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");
36c3b296
AK
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");
23666725
DS
115 if (IS_ZEBRA_DEBUG_MLAG)
116 vty_out(vty, " Zebra mlag debugging is on\n");
d4b4b70c 117 if (IS_ZEBRA_DEBUG_NHG_DETAIL)
cb6070bd 118 vty_out(vty, " Zebra detailed nexthop debugging is on\n");
d4b4b70c 119 else if (IS_ZEBRA_DEBUG_NHG)
cb6070bd 120 vty_out(vty, " Zebra nexthop debugging is on\n");
d62a17ae 121
94eb1635
AK
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
f188e68e
AK
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
8eeca5a2
SW
134 if (IS_ZEBRA_DEBUG_PBR)
135 vty_out(vty, " Zebra PBR debugging is on\n");
136
77151b6f 137 hook_call(zebra_debug_show_debugging, vty);
cf00164b
DS
138
139 cmd_show_lib_debugs(vty);
140
d62a17ae 141 return CMD_SUCCESS;
718e3744 142}
143
144DEFUN (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{
d62a17ae 151 zebra_debug_event = ZEBRA_DEBUG_EVENT;
8527ce3a 152 return CMD_SUCCESS;
718e3744 153}
154
fb018d25
DS
155DEFUN (debug_zebra_nht,
156 debug_zebra_nht_cmd,
50872b08 157 "debug zebra nht [detailed]",
fb018d25
DS
158 DEBUG_STR
159 "Zebra configuration\n"
50872b08
DS
160 "Debug option set for zebra next hop tracking\n"
161 "Debug option set for detailed info\n")
fb018d25 162{
50872b08
DS
163 int idx = 0;
164
d62a17ae 165 zebra_debug_nht = ZEBRA_DEBUG_NHT;
50872b08
DS
166
167 if (argv_find(argv, argc, "detailed", &idx))
168 zebra_debug_nht |= ZEBRA_DEBUG_NHT_DETAILED;
169
8527ce3a 170 return CMD_SUCCESS;
fb018d25
DS
171}
172
04dda092 173DEFPY (debug_zebra_mpls,
7758e3f3 174 debug_zebra_mpls_cmd,
04dda092 175 "debug zebra mpls [detailed$detail]",
7758e3f3 176 DEBUG_STR
177 "Zebra configuration\n"
04dda092
MS
178 "Debug option set for zebra MPLS LSPs\n"
179 "Debug option for detailed info\n")
7758e3f3 180{
d62a17ae 181 zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
04dda092
MS
182
183 if (detail)
184 zebra_debug_mpls |= ZEBRA_DEBUG_MPLS_DETAILED;
185
8527ce3a 186 return CMD_SUCCESS;
7758e3f3 187}
188
077c07cc 189DEFPY (debug_zebra_vxlan,
13d60d35 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{
d62a17ae 196 zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
8527ce3a 197 return CMD_SUCCESS;
13d60d35 198}
199
6833ae01 200DEFUN (debug_zebra_pw,
201 debug_zebra_pw_cmd,
202 "[no] debug zebra pseudowires",
efd7904e 203 NO_STR
6833ae01 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);
8527ce3a 212 return CMD_SUCCESS;
6833ae01 213}
214
718e3744 215DEFUN (debug_zebra_packet,
216 debug_zebra_packet_cmd,
16cedbb0 217 "debug zebra packet [<recv|send>] [detail]",
718e3744 218 DEBUG_STR
219 "Zebra configuration\n"
220 "Debug option set for zebra packet\n"
221 "Debug option set for receive packet\n"
16cedbb0
QY
222 "Debug option set for send packet\n"
223 "Debug option set for detailed info\n")
718e3744 224{
d62a17ae 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);
ba9d46ff 230 else if (argv_find(argv, argc, "recv", &idx))
d62a17ae 231 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
ba9d46ff 232 else {
d62a17ae 233 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
234 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
235 }
ba9d46ff
DW
236
237 if (argv_find(argv, argc, "detail", &idx))
238 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
239
d62a17ae 240 return CMD_SUCCESS;
718e3744 241}
242
243DEFUN (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{
d62a17ae 250 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
ba9d46ff 251
d62a17ae 252 return CMD_SUCCESS;
556b904e
QY
253}
254
38ef05ea 255#if defined(HAVE_NETLINK)
556b904e
QY
256DEFUN (debug_zebra_kernel_msgdump,
257 debug_zebra_kernel_msgdump_cmd,
6de69f83 258 "debug zebra kernel msgdump [<recv|send>]",
556b904e
QY
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{
d62a17ae 266 int idx = 0;
ba9d46ff 267
4d0773c4 268 if (argv_find(argv, argc, "recv", &idx))
d62a17ae 269 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
4d0773c4 270 else if (argv_find(argv, argc, "send", &idx))
d62a17ae 271 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
4d0773c4 272 else {
ba9d46ff
DW
273 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
274 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
275 }
276
d62a17ae 277 return CMD_SUCCESS;
718e3744 278}
38ef05ea 279#endif
718e3744 280
b0498dc6
PJ
281DEFUN (debug_zebra_rib,
282 debug_zebra_rib_cmd,
ba9d46ff 283 "debug zebra rib [detailed]",
b0498dc6
PJ
284 DEBUG_STR
285 "Zebra configuration\n"
286 "Debug RIB events\n"
41ec9222 287 "Detailed debugs\n")
b0498dc6 288{
ba9d46ff
DW
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
d62a17ae 295 return CMD_SUCCESS;
b0498dc6
PJ
296}
297
5adc2528
AS
298DEFUN (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{
d62a17ae 305 SET_FLAG(zebra_debug_fpm, ZEBRA_DEBUG_FPM);
306 return CMD_SUCCESS;
5adc2528
AS
307}
308
6582b002
MS
309DEFUN (debug_zebra_dplane,
310 debug_zebra_dplane_cmd,
5be41a1c 311 "debug zebra dplane [detailed]",
6582b002
MS
312 DEBUG_STR
313 "Zebra configuration\n"
5be41a1c
MS
314 "Debug zebra dataplane events\n"
315 "Detailed debug information\n")
6582b002
MS
316{
317 int idx = 0;
5709131c 318
6582b002
MS
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
36c3b296
AK
327DEFPY(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
8eeca5a2
SW
350DEFUN (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
4cf4fad1
AK
361DEFPY (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
23666725
DS
377DEFPY (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
94eb1635
AK
392DEFPY (debug_zebra_evpn_mh,
393 debug_zebra_evpn_mh_cmd,
f188e68e 394 "[no$no] debug zebra evpn mh <es$es|mac$mac|neigh$neigh|nh$nh>",
94eb1635
AK
395 NO_STR
396 DEBUG_STR
397 "Zebra configuration\n"
398 "EVPN\n"
399 "Multihoming\n"
400 "Ethernet Segment Debugging\n"
f188e68e
AK
401 "MAC Debugging\n"
402 "Neigh Debugging\n"
94eb1635
AK
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
f188e68e
AK
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
94eb1635
AK
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
718e3744 439DEFUN (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{
d62a17ae 447 zebra_debug_event = 0;
448 return CMD_SUCCESS;
718e3744 449}
450
fb018d25
DS
451DEFUN (no_debug_zebra_nht,
452 no_debug_zebra_nht_cmd,
50872b08 453 "no debug zebra nht [detailed]",
fb018d25
DS
454 NO_STR
455 DEBUG_STR
456 "Zebra configuration\n"
50872b08
DS
457 "Debug option set for zebra next hop tracking\n"
458 "Debug option set for detailed info\n")
fb018d25 459{
d62a17ae 460 zebra_debug_nht = 0;
461 return CMD_SUCCESS;
fb018d25
DS
462}
463
7758e3f3 464DEFUN (no_debug_zebra_mpls,
465 no_debug_zebra_mpls_cmd,
04dda092 466 "no debug zebra mpls [detailed]",
7758e3f3 467 NO_STR
468 DEBUG_STR
469 "Zebra configuration\n"
04dda092
MS
470 "Debug option set for zebra MPLS LSPs\n"
471 "Debug option for zebra detailed info\n")
7758e3f3 472{
d62a17ae 473 zebra_debug_mpls = 0;
474 return CMD_SUCCESS;
7758e3f3 475}
476
13d60d35 477DEFUN (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{
d62a17ae 485 zebra_debug_vxlan = 0;
486 return CMD_SUCCESS;
13d60d35 487}
488
718e3744 489DEFUN (no_debug_zebra_packet,
490 no_debug_zebra_packet_cmd,
ba9d46ff 491 "no debug zebra packet [<recv|send>] [detail]",
718e3744 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"
ba9d46ff
DW
497 "Debug option set for send packet\n"
498 "Debug option set for detailed info\n")
718e3744 499{
ba9d46ff 500 zebra_debug_packet = 0;
d62a17ae 501 return CMD_SUCCESS;
718e3744 502}
503
504DEFUN (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{
4d0773c4
DS
512 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
513
d62a17ae 514 return CMD_SUCCESS;
556b904e
QY
515}
516
38ef05ea 517#if defined(HAVE_NETLINK)
556b904e
QY
518DEFUN (no_debug_zebra_kernel_msgdump,
519 no_debug_zebra_kernel_msgdump_cmd,
6de69f83 520 "no debug zebra kernel msgdump [<recv|send>]",
16cedbb0 521 NO_STR
556b904e
QY
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{
4d0773c4
DS
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
d62a17ae 540 return CMD_SUCCESS;
718e3744 541}
38ef05ea 542#endif
718e3744 543
b0498dc6
PJ
544DEFUN (no_debug_zebra_rib,
545 no_debug_zebra_rib_cmd,
ba9d46ff 546 "no debug zebra rib [detailed]",
b0498dc6
PJ
547 NO_STR
548 DEBUG_STR
549 "Zebra configuration\n"
550 "Debug zebra RIB\n"
41ec9222 551 "Detailed debugs\n")
b0498dc6 552{
ba9d46ff 553 zebra_debug_rib = 0;
d62a17ae 554 return CMD_SUCCESS;
b0498dc6
PJ
555}
556
5adc2528
AS
557DEFUN (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{
d62a17ae 565 zebra_debug_fpm = 0;
566 return CMD_SUCCESS;
5adc2528
AS
567}
568
6582b002
MS
569DEFUN (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
8eeca5a2
SW
581DEFUN (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
d4b4b70c
MS
593DEFPY (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
718e3744 615/* Debug node. */
612c2c15 616static int config_write_debug(struct vty *vty);
62b346ee 617struct cmd_node debug_node = {
f4b8291f 618 .name = "debug",
62b346ee
DL
619 .node = DEBUG_NODE,
620 .prompt = "",
612c2c15 621 .config_write = config_write_debug,
62b346ee 622};
718e3744 623
d62a17ae 624static int config_write_debug(struct vty *vty)
718e3744 625{
d62a17ae 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 }
ba9d46ff 647
4d0773c4
DS
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
d62a17ae 660 if (IS_ZEBRA_DEBUG_KERNEL) {
4d0773c4
DS
661 vty_out(vty, "debug zebra kernel\n");
662 write++;
d62a17ae 663 }
ba9d46ff 664
d62a17ae 665 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
666 vty_out(vty, "debug zebra rib detailed\n");
667 write++;
ba9d46ff
DW
668 } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
669 vty_out(vty, "debug zebra rib\n");
670 write++;
d62a17ae 671 }
ba9d46ff 672
d62a17ae 673 if (IS_ZEBRA_DEBUG_FPM) {
674 vty_out(vty, "debug zebra fpm\n");
675 write++;
676 }
50872b08
DS
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) {
d62a17ae 682 vty_out(vty, "debug zebra nht\n");
683 write++;
684 }
50872b08 685
04dda092
MS
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) {
d62a17ae 690 vty_out(vty, "debug zebra mpls\n");
691 write++;
718e3744 692 }
04dda092 693
d62a17ae 694 if (IS_ZEBRA_DEBUG_VXLAN) {
695 vty_out(vty, "debug zebra vxlan\n");
696 write++;
718e3744 697 }
ef011a42
AK
698 if (IS_ZEBRA_DEBUG_MLAG) {
699 vty_out(vty, "debug zebra mlag\n");
700 write++;
701 }
94eb1635
AK
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 }
f188e68e
AK
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 }
6833ae01 718 if (IS_ZEBRA_DEBUG_PW) {
69965f53 719 vty_out(vty, "debug zebra pseudowires\n");
6833ae01 720 write++;
721 }
6582b002
MS
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
36c3b296
AK
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
cb6070bd
MS
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
8eeca5a2
SW
747 if (IS_ZEBRA_DEBUG_PBR) {
748 vty_out(vty, "debug zebra pbr\n");
749 write++;
750 }
751
4cf4fad1
AK
752 if (IS_ZEBRA_DEBUG_NEIGH) {
753 vty_out(vty, "debug zebra neigh\n");
754 write++;
755 }
756
d62a17ae 757 return write;
718e3744 758}
759
d62a17ae 760void zebra_debug_init(void)
718e3744 761{
d62a17ae 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;
6833ae01 769 zebra_debug_pw = 0;
6582b002 770 zebra_debug_dplane = 0;
36c3b296 771 zebra_debug_dplane_dpdk = 0;
23666725 772 zebra_debug_mlag = 0;
94eb1635 773 zebra_debug_evpn_mh = 0;
50872b08 774 zebra_debug_nht = 0;
d4b4b70c 775 zebra_debug_nexthop = 0;
8eeca5a2 776 zebra_debug_pbr = 0;
4cf4fad1 777 zebra_debug_neigh = 0;
d62a17ae 778
612c2c15 779 install_node(&debug_node);
d62a17ae 780
dd73744d 781 install_element(ENABLE_NODE, &show_debugging_zebra_cmd);
d62a17ae 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);
6833ae01 787 install_element(ENABLE_NODE, &debug_zebra_pw_cmd);
d62a17ae 788 install_element(ENABLE_NODE, &debug_zebra_packet_cmd);
789 install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
38ef05ea 790#if defined(HAVE_NETLINK)
d62a17ae 791 install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
38ef05ea 792#endif
d62a17ae 793 install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
d62a17ae 794 install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
6582b002 795 install_element(ENABLE_NODE, &debug_zebra_dplane_cmd);
23666725 796 install_element(ENABLE_NODE, &debug_zebra_mlag_cmd);
d4b4b70c 797 install_element(ENABLE_NODE, &debug_zebra_nexthop_cmd);
8eeca5a2 798 install_element(ENABLE_NODE, &debug_zebra_pbr_cmd);
4cf4fad1 799 install_element(ENABLE_NODE, &debug_zebra_neigh_cmd);
36c3b296 800 install_element(ENABLE_NODE, &debug_zebra_dplane_dpdk_cmd);
d62a17ae 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);
38ef05ea 807#if defined(HAVE_NETLINK)
d62a17ae 808 install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
38ef05ea 809#endif
d62a17ae 810 install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
d62a17ae 811 install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
6582b002 812 install_element(ENABLE_NODE, &no_debug_zebra_dplane_cmd);
8eeca5a2 813 install_element(ENABLE_NODE, &no_debug_zebra_pbr_cmd);
94eb1635 814 install_element(ENABLE_NODE, &debug_zebra_evpn_mh_cmd);
d62a17ae 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);
6833ae01 820 install_element(CONFIG_NODE, &debug_zebra_pw_cmd);
d62a17ae 821 install_element(CONFIG_NODE, &debug_zebra_packet_cmd);
822 install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
38ef05ea 823#if defined(HAVE_NETLINK)
d62a17ae 824 install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
38ef05ea 825#endif
d62a17ae 826 install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
d62a17ae 827 install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
6582b002 828 install_element(CONFIG_NODE, &debug_zebra_dplane_cmd);
36c3b296 829 install_element(CONFIG_NODE, &debug_zebra_dplane_dpdk_cmd);
d4b4b70c 830 install_element(CONFIG_NODE, &debug_zebra_nexthop_cmd);
8eeca5a2 831 install_element(CONFIG_NODE, &debug_zebra_pbr_cmd);
4cf4fad1 832 install_element(CONFIG_NODE, &debug_zebra_neigh_cmd);
8eeca5a2 833
d62a17ae 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);
38ef05ea 840#if defined(HAVE_NETLINK)
d62a17ae 841 install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
38ef05ea 842#endif
d62a17ae 843 install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
d62a17ae 844 install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
6582b002 845 install_element(CONFIG_NODE, &no_debug_zebra_dplane_cmd);
8eeca5a2 846 install_element(CONFIG_NODE, &no_debug_zebra_pbr_cmd);
ef011a42 847 install_element(CONFIG_NODE, &debug_zebra_mlag_cmd);
94eb1635 848 install_element(CONFIG_NODE, &debug_zebra_evpn_mh_cmd);
718e3744 849}