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