]> git.proxmox.com Git - mirror_frr.git/blob - zebra/debug.c
*: add missing \n in some help strings
[mirror_frr.git] / zebra / debug.c
1 /*
2 * Zebra debug related function
3 * Copyright (C) 1999 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <zebra.h>
23 #include "command.h"
24 #include "debug.h"
25
26 /* For debug statement. */
27 unsigned long zebra_debug_event;
28 unsigned long zebra_debug_packet;
29 unsigned long zebra_debug_kernel;
30 unsigned long zebra_debug_rib;
31 unsigned long zebra_debug_fpm;
32 unsigned long zebra_debug_nht;
33 unsigned long zebra_debug_mpls;
34 unsigned long zebra_debug_vxlan;
35 unsigned long zebra_debug_pw;
36
37 DEFUN_NOSH (show_debugging_zebra,
38 show_debugging_zebra_cmd,
39 "show debugging [zebra]",
40 SHOW_STR
41 "Debugging information\n"
42 "Zebra configuration\n")
43 {
44 vty_out(vty, "Zebra debugging status:\n");
45
46 if (IS_ZEBRA_DEBUG_EVENT)
47 vty_out(vty, " Zebra event debugging is on\n");
48
49 if (IS_ZEBRA_DEBUG_PACKET) {
50 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) {
51 vty_out(vty, " Zebra packet%s debugging is on\n",
52 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
53 } else {
54 if (IS_ZEBRA_DEBUG_SEND)
55 vty_out(vty,
56 " Zebra packet send%s debugging is on\n",
57 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
58 else
59 vty_out(vty,
60 " Zebra packet receive%s debugging is on\n",
61 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
62 }
63 }
64
65 if (IS_ZEBRA_DEBUG_KERNEL)
66 vty_out(vty, " Zebra kernel debugging is on\n");
67 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
68 vty_out(vty,
69 " Zebra kernel netlink message dumps (send) are on\n");
70 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
71 vty_out(vty,
72 " Zebra kernel netlink message dumps (recv) are on\n");
73
74 /* Check here using flags as the 'macro' does an OR */
75 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
76 vty_out(vty, " Zebra RIB detailed debugging is on\n");
77 else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
78 vty_out(vty, " Zebra RIB debugging is on\n");
79
80 if (IS_ZEBRA_DEBUG_FPM)
81 vty_out(vty, " Zebra FPM debugging is on\n");
82 if (IS_ZEBRA_DEBUG_NHT)
83 vty_out(vty, " Zebra next-hop tracking debugging is on\n");
84 if (IS_ZEBRA_DEBUG_MPLS)
85 vty_out(vty, " Zebra MPLS debugging is on\n");
86 if (IS_ZEBRA_DEBUG_VXLAN)
87 vty_out(vty, " Zebra VXLAN debugging is on\n");
88 if (IS_ZEBRA_DEBUG_PW)
89 vty_out(vty, " Zebra pseudowire debugging is on\n");
90
91 return CMD_SUCCESS;
92 }
93
94 DEFUN (debug_zebra_events,
95 debug_zebra_events_cmd,
96 "debug zebra events",
97 DEBUG_STR
98 "Zebra configuration\n"
99 "Debug option set for zebra events\n")
100 {
101 zebra_debug_event = ZEBRA_DEBUG_EVENT;
102 return CMD_SUCCESS;
103 }
104
105 DEFUN (debug_zebra_nht,
106 debug_zebra_nht_cmd,
107 "debug zebra nht",
108 DEBUG_STR
109 "Zebra configuration\n"
110 "Debug option set for zebra next hop tracking\n")
111 {
112 zebra_debug_nht = ZEBRA_DEBUG_NHT;
113 return CMD_SUCCESS;
114 }
115
116 DEFUN (debug_zebra_mpls,
117 debug_zebra_mpls_cmd,
118 "debug zebra mpls",
119 DEBUG_STR
120 "Zebra configuration\n"
121 "Debug option set for zebra MPLS LSPs\n")
122 {
123 zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
124 return CMD_SUCCESS;
125 }
126
127 DEFUN (debug_zebra_vxlan,
128 debug_zebra_vxlan_cmd,
129 "debug zebra vxlan",
130 DEBUG_STR
131 "Zebra configuration\n"
132 "Debug option set for zebra VxLAN (EVPN)\n")
133 {
134 zebra_debug_vxlan = ZEBRA_DEBUG_VXLAN;
135 return CMD_SUCCESS;
136 }
137
138 DEFUN (debug_zebra_pw,
139 debug_zebra_pw_cmd,
140 "[no] debug zebra pseudowires",
141 NO_STR
142 DEBUG_STR
143 "Zebra configuration\n"
144 "Debug option set for zebra pseudowires\n")
145 {
146 if (strmatch(argv[0]->text, "no"))
147 UNSET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
148 else
149 SET_FLAG(zebra_debug_pw, ZEBRA_DEBUG_PW);
150 return CMD_SUCCESS;
151 }
152
153 DEFUN (debug_zebra_packet,
154 debug_zebra_packet_cmd,
155 "debug zebra packet [<recv|send>] [detail]",
156 DEBUG_STR
157 "Zebra configuration\n"
158 "Debug option set for zebra packet\n"
159 "Debug option set for receive packet\n"
160 "Debug option set for send packet\n"
161 "Debug option set for detailed info\n")
162 {
163 int idx = 0;
164 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
165
166 if (argv_find(argv, argc, "send", &idx))
167 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
168 else if (argv_find(argv, argc, "recv", &idx))
169 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
170 else {
171 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
172 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
173 }
174
175 if (argv_find(argv, argc, "detail", &idx))
176 SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
177
178 return CMD_SUCCESS;
179 }
180
181 DEFUN (debug_zebra_kernel,
182 debug_zebra_kernel_cmd,
183 "debug zebra kernel",
184 DEBUG_STR
185 "Zebra configuration\n"
186 "Debug option set for zebra between kernel interface\n")
187 {
188 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
189
190 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
191 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
192
193 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
194 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
195
196 return CMD_SUCCESS;
197 }
198
199 DEFUN (debug_zebra_kernel_msgdump,
200 debug_zebra_kernel_msgdump_cmd,
201 "debug zebra kernel msgdump [<recv|send>]",
202 DEBUG_STR
203 "Zebra configuration\n"
204 "Debug option set for zebra between kernel interface\n"
205 "Dump raw netlink messages, sent and received\n"
206 "Dump raw netlink messages received\n"
207 "Dump raw netlink messages sent\n")
208 {
209 int idx = 0;
210
211 if (argv_find(argv, argc, "recv", &idx)) {
212 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
213
214 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
215 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
216
217 } else if (argv_find(argv, argc, "send", &idx)) {
218 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
219
220 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
221 UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
222
223 } else {
224 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
225 SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
226 }
227
228 return CMD_SUCCESS;
229 }
230
231 DEFUN (debug_zebra_rib,
232 debug_zebra_rib_cmd,
233 "debug zebra rib [detailed]",
234 DEBUG_STR
235 "Zebra configuration\n"
236 "Debug RIB events\n"
237 "Detailed debugs\n")
238 {
239 int idx = 0;
240 SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
241
242 if (argv_find(argv, argc, "detailed", &idx))
243 SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
244
245 return CMD_SUCCESS;
246 }
247
248 DEFUN (debug_zebra_fpm,
249 debug_zebra_fpm_cmd,
250 "debug zebra fpm",
251 DEBUG_STR
252 "Zebra configuration\n"
253 "Debug zebra FPM events\n")
254 {
255 SET_FLAG(zebra_debug_fpm, ZEBRA_DEBUG_FPM);
256 return CMD_SUCCESS;
257 }
258
259 DEFUN (no_debug_zebra_events,
260 no_debug_zebra_events_cmd,
261 "no debug zebra events",
262 NO_STR
263 DEBUG_STR
264 "Zebra configuration\n"
265 "Debug option set for zebra events\n")
266 {
267 zebra_debug_event = 0;
268 return CMD_SUCCESS;
269 }
270
271 DEFUN (no_debug_zebra_nht,
272 no_debug_zebra_nht_cmd,
273 "no debug zebra nht",
274 NO_STR
275 DEBUG_STR
276 "Zebra configuration\n"
277 "Debug option set for zebra next hop tracking\n")
278 {
279 zebra_debug_nht = 0;
280 return CMD_SUCCESS;
281 }
282
283 DEFUN (no_debug_zebra_mpls,
284 no_debug_zebra_mpls_cmd,
285 "no debug zebra mpls",
286 NO_STR
287 DEBUG_STR
288 "Zebra configuration\n"
289 "Debug option set for zebra MPLS LSPs\n")
290 {
291 zebra_debug_mpls = 0;
292 return CMD_SUCCESS;
293 }
294
295 DEFUN (no_debug_zebra_vxlan,
296 no_debug_zebra_vxlan_cmd,
297 "no debug zebra vxlan",
298 NO_STR
299 DEBUG_STR
300 "Zebra configuration\n"
301 "Debug option set for zebra VxLAN (EVPN)\n")
302 {
303 zebra_debug_vxlan = 0;
304 return CMD_SUCCESS;
305 }
306
307 DEFUN (no_debug_zebra_packet,
308 no_debug_zebra_packet_cmd,
309 "no debug zebra packet [<recv|send>] [detail]",
310 NO_STR
311 DEBUG_STR
312 "Zebra configuration\n"
313 "Debug option set for zebra packet\n"
314 "Debug option set for receive packet\n"
315 "Debug option set for send packet\n"
316 "Debug option set for detailed info\n")
317 {
318 zebra_debug_packet = 0;
319 return CMD_SUCCESS;
320 }
321
322 DEFUN (no_debug_zebra_kernel,
323 no_debug_zebra_kernel_cmd,
324 "no debug zebra kernel",
325 NO_STR
326 DEBUG_STR
327 "Zebra configuration\n"
328 "Debug option set for zebra between kernel interface\n")
329 {
330 zebra_debug_kernel = 0;
331 return CMD_SUCCESS;
332 }
333
334 DEFUN (no_debug_zebra_kernel_msgdump,
335 no_debug_zebra_kernel_msgdump_cmd,
336 "no debug zebra kernel msgdump [<recv|send>]",
337 NO_STR
338 DEBUG_STR
339 "Zebra configuration\n"
340 "Debug option set for zebra between kernel interface\n"
341 "Dump raw netlink messages, sent and received\n"
342 "Dump raw netlink messages received\n"
343 "Dump raw netlink messages sent\n")
344 {
345 zebra_debug_kernel = 0;
346 return CMD_SUCCESS;
347 }
348
349 DEFUN (no_debug_zebra_rib,
350 no_debug_zebra_rib_cmd,
351 "no debug zebra rib [detailed]",
352 NO_STR
353 DEBUG_STR
354 "Zebra configuration\n"
355 "Debug zebra RIB\n"
356 "Detailed debugs\n")
357 {
358 zebra_debug_rib = 0;
359 return CMD_SUCCESS;
360 }
361
362 DEFUN (no_debug_zebra_fpm,
363 no_debug_zebra_fpm_cmd,
364 "no debug zebra fpm",
365 NO_STR
366 DEBUG_STR
367 "Zebra configuration\n"
368 "Debug zebra FPM events\n")
369 {
370 zebra_debug_fpm = 0;
371 return CMD_SUCCESS;
372 }
373
374 /* Debug node. */
375 struct cmd_node debug_node = {DEBUG_NODE, "", /* Debug node has no interface. */
376 1};
377
378 static int config_write_debug(struct vty *vty)
379 {
380 int write = 0;
381
382 if (IS_ZEBRA_DEBUG_EVENT) {
383 vty_out(vty, "debug zebra events\n");
384 write++;
385 }
386 if (IS_ZEBRA_DEBUG_PACKET) {
387 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) {
388 vty_out(vty, "debug zebra packet%s\n",
389 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
390 write++;
391 } else {
392 if (IS_ZEBRA_DEBUG_SEND)
393 vty_out(vty, "debug zebra packet send%s\n",
394 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
395 else
396 vty_out(vty, "debug zebra packet recv%s\n",
397 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "");
398 write++;
399 }
400 }
401
402 if (IS_ZEBRA_DEBUG_KERNEL) {
403 if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
404 vty_out(vty, "debug zebra kernel msgdump\n");
405 write++;
406 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
407 vty_out(vty, "debug zebra kernel msgdump recv\n");
408 write++;
409 } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
410 vty_out(vty, "debug zebra kernel msgdump send\n");
411 write++;
412 } else {
413 vty_out(vty, "debug zebra kernel\n");
414 write++;
415 }
416 }
417
418 if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
419 vty_out(vty, "debug zebra rib detailed\n");
420 write++;
421 } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
422 vty_out(vty, "debug zebra rib\n");
423 write++;
424 }
425
426 if (IS_ZEBRA_DEBUG_FPM) {
427 vty_out(vty, "debug zebra fpm\n");
428 write++;
429 }
430 if (IS_ZEBRA_DEBUG_NHT) {
431 vty_out(vty, "debug zebra nht\n");
432 write++;
433 }
434 if (IS_ZEBRA_DEBUG_MPLS) {
435 vty_out(vty, "debug zebra mpls\n");
436 write++;
437 }
438 if (IS_ZEBRA_DEBUG_VXLAN) {
439 vty_out(vty, "debug zebra vxlan\n");
440 write++;
441 }
442 if (IS_ZEBRA_DEBUG_PW) {
443 vty_out(vty, "debug zebra pseudowires\n");
444 write++;
445 }
446 return write;
447 }
448
449 void zebra_debug_init(void)
450 {
451 zebra_debug_event = 0;
452 zebra_debug_packet = 0;
453 zebra_debug_kernel = 0;
454 zebra_debug_rib = 0;
455 zebra_debug_fpm = 0;
456 zebra_debug_mpls = 0;
457 zebra_debug_vxlan = 0;
458 zebra_debug_pw = 0;
459
460 install_node(&debug_node, config_write_debug);
461
462 install_element(VIEW_NODE, &show_debugging_zebra_cmd);
463
464 install_element(ENABLE_NODE, &debug_zebra_events_cmd);
465 install_element(ENABLE_NODE, &debug_zebra_nht_cmd);
466 install_element(ENABLE_NODE, &debug_zebra_mpls_cmd);
467 install_element(ENABLE_NODE, &debug_zebra_vxlan_cmd);
468 install_element(ENABLE_NODE, &debug_zebra_pw_cmd);
469 install_element(ENABLE_NODE, &debug_zebra_packet_cmd);
470 install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
471 install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
472 install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
473 install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
474 install_element(ENABLE_NODE, &no_debug_zebra_events_cmd);
475 install_element(ENABLE_NODE, &no_debug_zebra_nht_cmd);
476 install_element(ENABLE_NODE, &no_debug_zebra_mpls_cmd);
477 install_element(ENABLE_NODE, &no_debug_zebra_vxlan_cmd);
478 install_element(ENABLE_NODE, &no_debug_zebra_packet_cmd);
479 install_element(ENABLE_NODE, &no_debug_zebra_kernel_cmd);
480 install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
481 install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
482 install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
483
484 install_element(CONFIG_NODE, &debug_zebra_events_cmd);
485 install_element(CONFIG_NODE, &debug_zebra_nht_cmd);
486 install_element(CONFIG_NODE, &debug_zebra_mpls_cmd);
487 install_element(CONFIG_NODE, &debug_zebra_vxlan_cmd);
488 install_element(CONFIG_NODE, &debug_zebra_pw_cmd);
489 install_element(CONFIG_NODE, &debug_zebra_packet_cmd);
490 install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
491 install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
492 install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
493 install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
494 install_element(CONFIG_NODE, &no_debug_zebra_events_cmd);
495 install_element(CONFIG_NODE, &no_debug_zebra_nht_cmd);
496 install_element(CONFIG_NODE, &no_debug_zebra_mpls_cmd);
497 install_element(CONFIG_NODE, &no_debug_zebra_vxlan_cmd);
498 install_element(CONFIG_NODE, &no_debug_zebra_packet_cmd);
499 install_element(CONFIG_NODE, &no_debug_zebra_kernel_cmd);
500 install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
501 install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
502 install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
503 }