Coverage Report

Created: 2025-08-26 06:20

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