]> git.proxmox.com Git - mirror_frr.git/blame - zebra/debug.c
zebra: do not load/store wider-than-ptr atomics
[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;
c317d3f2 45unsigned long zebra_debug_tc;
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");
36c3b296
AK
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");
23666725
DS
116 if (IS_ZEBRA_DEBUG_MLAG)
117 vty_out(vty, " Zebra mlag debugging is on\n");
d4b4b70c 118 if (IS_ZEBRA_DEBUG_NHG_DETAIL)
cb6070bd 119 vty_out(vty, " Zebra detailed nexthop debugging is on\n");
d4b4b70c 120 else if (IS_ZEBRA_DEBUG_NHG)
cb6070bd 121 vty_out(vty, " Zebra nexthop debugging is on\n");
d62a17ae 122
94eb1635
AK
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
f188e68e
AK
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
8eeca5a2
SW
135 if (IS_ZEBRA_DEBUG_PBR)
136 vty_out(vty, " Zebra PBR debugging is on\n");
137
77151b6f 138 hook_call(zebra_debug_show_debugging, vty);
cf00164b
DS
139
140 cmd_show_lib_debugs(vty);
141
d62a17ae 142 return CMD_SUCCESS;
718e3744 143}
144
145DEFUN (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{
d62a17ae 152 zebra_debug_event = ZEBRA_DEBUG_EVENT;
8527ce3a 153 return CMD_SUCCESS;
718e3744 154}
155
fb018d25
DS
156DEFUN (debug_zebra_nht,
157 debug_zebra_nht_cmd,
50872b08 158 "debug zebra nht [detailed]",
fb018d25
DS
159 DEBUG_STR
160 "Zebra configuration\n"
50872b08
DS
161 "Debug option set for zebra next hop tracking\n"
162 "Debug option set for detailed info\n")
fb018d25 163{
50872b08
DS
164 int idx = 0;
165
d62a17ae 166 zebra_debug_nht = ZEBRA_DEBUG_NHT;
50872b08
DS
167
168 if (argv_find(argv, argc, "detailed", &idx))
169 zebra_debug_nht |= ZEBRA_DEBUG_NHT_DETAILED;
170
8527ce3a 171 return CMD_SUCCESS;
fb018d25
DS
172}
173
04dda092 174DEFPY (debug_zebra_mpls,
7758e3f3 175 debug_zebra_mpls_cmd,
04dda092 176 "debug zebra mpls [detailed$detail]",
7758e3f3 177 DEBUG_STR
178 "Zebra configuration\n"
04dda092
MS
179 "Debug option set for zebra MPLS LSPs\n"
180 "Debug option for detailed info\n")
7758e3f3 181{
d62a17ae 182 zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
04dda092
MS
183
184 if (detail)
185 zebra_debug_mpls |= ZEBRA_DEBUG_MPLS_DETAILED;
186
8527ce3a 187 return CMD_SUCCESS;
7758e3f3 188}
189
077c07cc 190DEFPY (debug_zebra_vxlan,
13d60d35 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{
d62a17ae 197 zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
8527ce3a 198 return CMD_SUCCESS;
13d60d35 199}
200
6833ae01 201DEFUN (debug_zebra_pw,
202 debug_zebra_pw_cmd,
203 "[no] debug zebra pseudowires",
efd7904e 204 NO_STR
6833ae01 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);
8527ce3a 213 return CMD_SUCCESS;
6833ae01 214}
215
718e3744 216DEFUN (debug_zebra_packet,
217 debug_zebra_packet_cmd,
16cedbb0 218 "debug zebra packet [<recv|send>] [detail]",
718e3744 219 DEBUG_STR
220 "Zebra configuration\n"
221 "Debug option set for zebra packet\n"
222 "Debug option set for receive packet\n"
16cedbb0
QY
223 "Debug option set for send packet\n"
224 "Debug option set for detailed info\n")
718e3744 225{
d62a17ae 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);
ba9d46ff 231 else if (argv_find(argv, argc, "recv", &idx))
d62a17ae 232 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
ba9d46ff 233 else {
d62a17ae 234 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
235 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
236 }
ba9d46ff
DW
237
238 if (argv_find(argv, argc, "detail", &idx))
239 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
240
d62a17ae 241 return CMD_SUCCESS;
718e3744 242}
243
244DEFUN (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{
d62a17ae 251 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
ba9d46ff 252
d62a17ae 253 return CMD_SUCCESS;
556b904e
QY
254}
255
38ef05ea 256#if defined(HAVE_NETLINK)
556b904e
QY
257DEFUN (debug_zebra_kernel_msgdump,
258 debug_zebra_kernel_msgdump_cmd,
6de69f83 259 "debug zebra kernel msgdump [<recv|send>]",
556b904e
QY
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{
d62a17ae 267 int idx = 0;
ba9d46ff 268
4d0773c4 269 if (argv_find(argv, argc, "recv", &idx))
d62a17ae 270 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
4d0773c4 271 else if (argv_find(argv, argc, "send", &idx))
d62a17ae 272 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
4d0773c4 273 else {
ba9d46ff
DW
274 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
275 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
276 }
277
d62a17ae 278 return CMD_SUCCESS;
718e3744 279}
38ef05ea 280#endif
718e3744 281
b0498dc6
PJ
282DEFUN (debug_zebra_rib,
283 debug_zebra_rib_cmd,
ba9d46ff 284 "debug zebra rib [detailed]",
b0498dc6
PJ
285 DEBUG_STR
286 "Zebra configuration\n"
287 "Debug RIB events\n"
41ec9222 288 "Detailed debugs\n")
b0498dc6 289{
ba9d46ff
DW
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
d62a17ae 296 return CMD_SUCCESS;
b0498dc6
PJ
297}
298
5adc2528
AS
299DEFUN (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{
d62a17ae 306 SET_FLAG(zebra_debug_fpm, ZEBRA_DEBUG_FPM);
307 return CMD_SUCCESS;
5adc2528
AS
308}
309
6582b002
MS
310DEFUN (debug_zebra_dplane,
311 debug_zebra_dplane_cmd,
5be41a1c 312 "debug zebra dplane [detailed]",
6582b002
MS
313 DEBUG_STR
314 "Zebra configuration\n"
5be41a1c
MS
315 "Debug zebra dataplane events\n"
316 "Detailed debug information\n")
6582b002
MS
317{
318 int idx = 0;
5709131c 319
6582b002
MS
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
36c3b296
AK
328DEFPY(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)
3edb3a64 344 SET_FLAG(zebra_debug_dplane_dpdk,
36c3b296
AK
345 ZEBRA_DEBUG_DPLANE_DPDK_DETAIL);
346 }
347
348 return CMD_SUCCESS;
349}
350
8eeca5a2
SW
351DEFUN (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
4cf4fad1
AK
362DEFPY (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
c317d3f2
SY
378DEFUN (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
23666725
DS
389DEFPY (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
94eb1635
AK
404DEFPY (debug_zebra_evpn_mh,
405 debug_zebra_evpn_mh_cmd,
f188e68e 406 "[no$no] debug zebra evpn mh <es$es|mac$mac|neigh$neigh|nh$nh>",
94eb1635
AK
407 NO_STR
408 DEBUG_STR
409 "Zebra configuration\n"
410 "EVPN\n"
411 "Multihoming\n"
412 "Ethernet Segment Debugging\n"
f188e68e
AK
413 "MAC Debugging\n"
414 "Neigh Debugging\n"
94eb1635
AK
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
f188e68e
AK
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
94eb1635
AK
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
718e3744 451DEFUN (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{
d62a17ae 459 zebra_debug_event = 0;
460 return CMD_SUCCESS;
718e3744 461}
462
fb018d25
DS
463DEFUN (no_debug_zebra_nht,
464 no_debug_zebra_nht_cmd,
50872b08 465 "no debug zebra nht [detailed]",
fb018d25
DS
466 NO_STR
467 DEBUG_STR
468 "Zebra configuration\n"
50872b08
DS
469 "Debug option set for zebra next hop tracking\n"
470 "Debug option set for detailed info\n")
fb018d25 471{
d62a17ae 472 zebra_debug_nht = 0;
473 return CMD_SUCCESS;
fb018d25
DS
474}
475
7758e3f3 476DEFUN (no_debug_zebra_mpls,
477 no_debug_zebra_mpls_cmd,
04dda092 478 "no debug zebra mpls [detailed]",
7758e3f3 479 NO_STR
480 DEBUG_STR
481 "Zebra configuration\n"
04dda092
MS
482 "Debug option set for zebra MPLS LSPs\n"
483 "Debug option for zebra detailed info\n")
7758e3f3 484{
d62a17ae 485 zebra_debug_mpls = 0;
486 return CMD_SUCCESS;
7758e3f3 487}
488
13d60d35 489DEFUN (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{
d62a17ae 497 zebra_debug_vxlan = 0;
498 return CMD_SUCCESS;
13d60d35 499}
500
718e3744 501DEFUN (no_debug_zebra_packet,
502 no_debug_zebra_packet_cmd,
ba9d46ff 503 "no debug zebra packet [<recv|send>] [detail]",
718e3744 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"
ba9d46ff
DW
509 "Debug option set for send packet\n"
510 "Debug option set for detailed info\n")
718e3744 511{
ba9d46ff 512 zebra_debug_packet = 0;
d62a17ae 513 return CMD_SUCCESS;
718e3744 514}
515
516DEFUN (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{
4d0773c4
DS
524 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
525
d62a17ae 526 return CMD_SUCCESS;
556b904e
QY
527}
528
38ef05ea 529#if defined(HAVE_NETLINK)
556b904e
QY
530DEFUN (no_debug_zebra_kernel_msgdump,
531 no_debug_zebra_kernel_msgdump_cmd,
6de69f83 532 "no debug zebra kernel msgdump [<recv|send>]",
16cedbb0 533 NO_STR
556b904e
QY
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{
4d0773c4
DS
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
d62a17ae 552 return CMD_SUCCESS;
718e3744 553}
38ef05ea 554#endif
718e3744 555
b0498dc6
PJ
556DEFUN (no_debug_zebra_rib,
557 no_debug_zebra_rib_cmd,
ba9d46ff 558 "no debug zebra rib [detailed]",
b0498dc6
PJ
559 NO_STR
560 DEBUG_STR
561 "Zebra configuration\n"
562 "Debug zebra RIB\n"
41ec9222 563 "Detailed debugs\n")
b0498dc6 564{
ba9d46ff 565 zebra_debug_rib = 0;
d62a17ae 566 return CMD_SUCCESS;
b0498dc6
PJ
567}
568
5adc2528
AS
569DEFUN (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{
d62a17ae 577 zebra_debug_fpm = 0;
578 return CMD_SUCCESS;
5adc2528
AS
579}
580
6582b002
MS
581DEFUN (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
8eeca5a2
SW
593DEFUN (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
d4b4b70c
MS
605DEFPY (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
718e3744 627/* Debug node. */
612c2c15 628static int config_write_debug(struct vty *vty);
62b346ee 629struct cmd_node debug_node = {
f4b8291f 630 .name = "debug",
62b346ee
DL
631 .node = DEBUG_NODE,
632 .prompt = "",
612c2c15 633 .config_write = config_write_debug,
62b346ee 634};
718e3744 635
d62a17ae 636static int config_write_debug(struct vty *vty)
718e3744 637{
d62a17ae 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 }
ba9d46ff 659
4d0773c4
DS
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
d62a17ae 672 if (IS_ZEBRA_DEBUG_KERNEL) {
4d0773c4
DS
673 vty_out(vty, "debug zebra kernel\n");
674 write++;
d62a17ae 675 }
ba9d46ff 676
d62a17ae 677 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
678 vty_out(vty, "debug zebra rib detailed\n");
679 write++;
ba9d46ff
DW
680 } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
681 vty_out(vty, "debug zebra rib\n");
682 write++;
d62a17ae 683 }
ba9d46ff 684
d62a17ae 685 if (IS_ZEBRA_DEBUG_FPM) {
686 vty_out(vty, "debug zebra fpm\n");
687 write++;
688 }
50872b08
DS
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) {
d62a17ae 694 vty_out(vty, "debug zebra nht\n");
695 write++;
696 }
50872b08 697
04dda092
MS
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) {
d62a17ae 702 vty_out(vty, "debug zebra mpls\n");
703 write++;
718e3744 704 }
04dda092 705
d62a17ae 706 if (IS_ZEBRA_DEBUG_VXLAN) {
707 vty_out(vty, "debug zebra vxlan\n");
708 write++;
718e3744 709 }
ef011a42
AK
710 if (IS_ZEBRA_DEBUG_MLAG) {
711 vty_out(vty, "debug zebra mlag\n");
712 write++;
713 }
94eb1635
AK
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 }
f188e68e
AK
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 }
6833ae01 730 if (IS_ZEBRA_DEBUG_PW) {
69965f53 731 vty_out(vty, "debug zebra pseudowires\n");
6833ae01 732 write++;
733 }
6582b002
MS
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
3edb3a64
MS
743 if (CHECK_FLAG(zebra_debug_dplane_dpdk,
744 ZEBRA_DEBUG_DPLANE_DPDK_DETAIL)) {
36c3b296
AK
745 vty_out(vty, "debug zebra dplane dpdk detailed\n");
746 write++;
3edb3a64
MS
747 } else if (CHECK_FLAG(zebra_debug_dplane_dpdk,
748 ZEBRA_DEBUG_DPLANE_DPDK)) {
36c3b296
AK
749 vty_out(vty, "debug zebra dplane dpdk\n");
750 write++;
751 }
752
cb6070bd
MS
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
8eeca5a2
SW
761 if (IS_ZEBRA_DEBUG_PBR) {
762 vty_out(vty, "debug zebra pbr\n");
763 write++;
764 }
765
4cf4fad1
AK
766 if (IS_ZEBRA_DEBUG_NEIGH) {
767 vty_out(vty, "debug zebra neigh\n");
768 write++;
769 }
770
d62a17ae 771 return write;
718e3744 772}
773
d62a17ae 774void zebra_debug_init(void)
718e3744 775{
d62a17ae 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;
6833ae01 783 zebra_debug_pw = 0;
6582b002 784 zebra_debug_dplane = 0;
36c3b296 785 zebra_debug_dplane_dpdk = 0;
23666725 786 zebra_debug_mlag = 0;
94eb1635 787 zebra_debug_evpn_mh = 0;
50872b08 788 zebra_debug_nht = 0;
d4b4b70c 789 zebra_debug_nexthop = 0;
8eeca5a2 790 zebra_debug_pbr = 0;
4cf4fad1 791 zebra_debug_neigh = 0;
d62a17ae 792
612c2c15 793 install_node(&debug_node);
d62a17ae 794
dd73744d 795 install_element(ENABLE_NODE, &show_debugging_zebra_cmd);
d62a17ae 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);
6833ae01 801 install_element(ENABLE_NODE, &debug_zebra_pw_cmd);
d62a17ae 802 install_element(ENABLE_NODE, &debug_zebra_packet_cmd);
803 install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
38ef05ea 804#if defined(HAVE_NETLINK)
d62a17ae 805 install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
38ef05ea 806#endif
d62a17ae 807 install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
d62a17ae 808 install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
6582b002 809 install_element(ENABLE_NODE, &debug_zebra_dplane_cmd);
23666725 810 install_element(ENABLE_NODE, &debug_zebra_mlag_cmd);
d4b4b70c 811 install_element(ENABLE_NODE, &debug_zebra_nexthop_cmd);
8eeca5a2 812 install_element(ENABLE_NODE, &debug_zebra_pbr_cmd);
4cf4fad1 813 install_element(ENABLE_NODE, &debug_zebra_neigh_cmd);
c317d3f2 814 install_element(ENABLE_NODE, &debug_zebra_tc_cmd);
36c3b296 815 install_element(ENABLE_NODE, &debug_zebra_dplane_dpdk_cmd);
d62a17ae 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);
38ef05ea 822#if defined(HAVE_NETLINK)
d62a17ae 823 install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
38ef05ea 824#endif
d62a17ae 825 install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
d62a17ae 826 install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
6582b002 827 install_element(ENABLE_NODE, &no_debug_zebra_dplane_cmd);
8eeca5a2 828 install_element(ENABLE_NODE, &no_debug_zebra_pbr_cmd);
94eb1635 829 install_element(ENABLE_NODE, &debug_zebra_evpn_mh_cmd);
d62a17ae 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);
6833ae01 835 install_element(CONFIG_NODE, &debug_zebra_pw_cmd);
d62a17ae 836 install_element(CONFIG_NODE, &debug_zebra_packet_cmd);
837 install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
38ef05ea 838#if defined(HAVE_NETLINK)
d62a17ae 839 install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
38ef05ea 840#endif
d62a17ae 841 install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
d62a17ae 842 install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
6582b002 843 install_element(CONFIG_NODE, &debug_zebra_dplane_cmd);
36c3b296 844 install_element(CONFIG_NODE, &debug_zebra_dplane_dpdk_cmd);
d4b4b70c 845 install_element(CONFIG_NODE, &debug_zebra_nexthop_cmd);
8eeca5a2 846 install_element(CONFIG_NODE, &debug_zebra_pbr_cmd);
4cf4fad1 847 install_element(CONFIG_NODE, &debug_zebra_neigh_cmd);
8eeca5a2 848
d62a17ae 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);
38ef05ea 855#if defined(HAVE_NETLINK)
d62a17ae 856 install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
38ef05ea 857#endif
d62a17ae 858 install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
d62a17ae 859 install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
6582b002 860 install_element(CONFIG_NODE, &no_debug_zebra_dplane_cmd);
8eeca5a2 861 install_element(CONFIG_NODE, &no_debug_zebra_pbr_cmd);
ef011a42 862 install_element(CONFIG_NODE, &debug_zebra_mlag_cmd);
94eb1635 863 install_element(CONFIG_NODE, &debug_zebra_evpn_mh_cmd);
718e3744 864}