]> git.proxmox.com Git - mirror_frr.git/blame - zebra/debug.c
nexthop-tracking.patch
[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 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#include <zebra.h>
24#include "command.h"
25#include "debug.h"
26
27/* For debug statement. */
28unsigned long zebra_debug_event;
29unsigned long zebra_debug_packet;
30unsigned long zebra_debug_kernel;
b0498dc6 31unsigned long zebra_debug_rib;
5adc2528 32unsigned long zebra_debug_fpm;
fb018d25 33unsigned long zebra_debug_nht;
718e3744 34
35DEFUN (show_debugging_zebra,
36 show_debugging_zebra_cmd,
37 "show debugging zebra",
38 SHOW_STR
2b00515a
CF
39 "Debugging information\n"
40 "Zebra configuration\n")
718e3744 41{
42 vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE);
43
44 if (IS_ZEBRA_DEBUG_EVENT)
45 vty_out (vty, " Zebra event debugging is on%s", VTY_NEWLINE);
46
47 if (IS_ZEBRA_DEBUG_PACKET)
48 {
49 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
50 {
51 vty_out (vty, " Zebra packet%s debugging is on%s",
52 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
53 VTY_NEWLINE);
54 }
55 else
56 {
57 if (IS_ZEBRA_DEBUG_SEND)
58 vty_out (vty, " Zebra packet send%s debugging is on%s",
59 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
60 VTY_NEWLINE);
61 else
62 vty_out (vty, " Zebra packet receive%s debugging is on%s",
63 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
64 VTY_NEWLINE);
65 }
66 }
67
68 if (IS_ZEBRA_DEBUG_KERNEL)
69 vty_out (vty, " Zebra kernel debugging is on%s", VTY_NEWLINE);
70
b0498dc6
PJ
71 if (IS_ZEBRA_DEBUG_RIB)
72 vty_out (vty, " Zebra RIB debugging is on%s", VTY_NEWLINE);
73 if (IS_ZEBRA_DEBUG_RIB_Q)
74 vty_out (vty, " Zebra RIB queue debugging is on%s", VTY_NEWLINE);
75
5adc2528
AS
76 if (IS_ZEBRA_DEBUG_FPM)
77 vty_out (vty, " Zebra FPM debugging is on%s", VTY_NEWLINE);
fb018d25
DS
78 if (IS_ZEBRA_DEBUG_NHT)
79 vty_out (vty, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE);
5adc2528 80
718e3744 81 return CMD_SUCCESS;
82}
83
84DEFUN (debug_zebra_events,
85 debug_zebra_events_cmd,
86 "debug zebra events",
87 DEBUG_STR
88 "Zebra configuration\n"
89 "Debug option set for zebra events\n")
90{
91 zebra_debug_event = ZEBRA_DEBUG_EVENT;
92 return CMD_WARNING;
93}
94
fb018d25
DS
95DEFUN (debug_zebra_nht,
96 debug_zebra_nht_cmd,
97 "debug zebra nht",
98 DEBUG_STR
99 "Zebra configuration\n"
100 "Debug option set for zebra next hop tracking\n")
101{
102 zebra_debug_nht = ZEBRA_DEBUG_NHT;
103 return CMD_WARNING;
104}
105
718e3744 106DEFUN (debug_zebra_packet,
107 debug_zebra_packet_cmd,
108 "debug zebra packet",
109 DEBUG_STR
110 "Zebra configuration\n"
111 "Debug option set for zebra packet\n")
112{
113 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
114 zebra_debug_packet |= ZEBRA_DEBUG_SEND;
115 zebra_debug_packet |= ZEBRA_DEBUG_RECV;
116 return CMD_SUCCESS;
117}
118
119DEFUN (debug_zebra_packet_direct,
120 debug_zebra_packet_direct_cmd,
121 "debug zebra packet (recv|send)",
122 DEBUG_STR
123 "Zebra configuration\n"
124 "Debug option set for zebra packet\n"
125 "Debug option set for receive packet\n"
126 "Debug option set for send packet\n")
127{
128 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
129 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
130 zebra_debug_packet |= ZEBRA_DEBUG_SEND;
131 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
132 zebra_debug_packet |= ZEBRA_DEBUG_RECV;
133 zebra_debug_packet &= ~ZEBRA_DEBUG_DETAIL;
134 return CMD_SUCCESS;
135}
136
137DEFUN (debug_zebra_packet_detail,
138 debug_zebra_packet_detail_cmd,
139 "debug zebra packet (recv|send) detail",
140 DEBUG_STR
141 "Zebra configuration\n"
142 "Debug option set for zebra packet\n"
143 "Debug option set for receive packet\n"
144 "Debug option set for send packet\n"
2b00515a 145 "Debug option set detailed information\n")
718e3744 146{
147 zebra_debug_packet = ZEBRA_DEBUG_PACKET;
148 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
149 zebra_debug_packet |= ZEBRA_DEBUG_SEND;
150 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
151 zebra_debug_packet |= ZEBRA_DEBUG_RECV;
152 zebra_debug_packet |= ZEBRA_DEBUG_DETAIL;
153 return CMD_SUCCESS;
154}
155
156DEFUN (debug_zebra_kernel,
157 debug_zebra_kernel_cmd,
158 "debug zebra kernel",
159 DEBUG_STR
160 "Zebra configuration\n"
161 "Debug option set for zebra between kernel interface\n")
162{
163 zebra_debug_kernel = ZEBRA_DEBUG_KERNEL;
164 return CMD_SUCCESS;
165}
166
b0498dc6
PJ
167DEFUN (debug_zebra_rib,
168 debug_zebra_rib_cmd,
169 "debug zebra rib",
170 DEBUG_STR
171 "Zebra configuration\n"
172 "Debug RIB events\n")
173{
174 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB);
175 return CMD_SUCCESS;
176}
177
178DEFUN (debug_zebra_rib_q,
179 debug_zebra_rib_q_cmd,
180 "debug zebra rib queue",
181 DEBUG_STR
182 "Zebra configuration\n"
183 "Debug RIB events\n"
184 "Debug RIB queueing\n")
185{
186 SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
187 return CMD_SUCCESS;
188}
189
5adc2528
AS
190DEFUN (debug_zebra_fpm,
191 debug_zebra_fpm_cmd,
192 "debug zebra fpm",
193 DEBUG_STR
194 "Zebra configuration\n"
195 "Debug zebra FPM events\n")
196{
197 SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM);
198 return CMD_SUCCESS;
199}
200
718e3744 201DEFUN (no_debug_zebra_events,
202 no_debug_zebra_events_cmd,
203 "no debug zebra events",
204 NO_STR
205 DEBUG_STR
206 "Zebra configuration\n"
207 "Debug option set for zebra events\n")
208{
209 zebra_debug_event = 0;
210 return CMD_SUCCESS;
211}
212
fb018d25
DS
213DEFUN (no_debug_zebra_nht,
214 no_debug_zebra_nht_cmd,
215 "no debug zebra nht",
216 NO_STR
217 DEBUG_STR
218 "Zebra configuration\n"
219 "Debug option set for zebra next hop tracking\n")
220{
221 zebra_debug_nht = 0;
222 return CMD_SUCCESS;
223}
224
718e3744 225DEFUN (no_debug_zebra_packet,
226 no_debug_zebra_packet_cmd,
227 "no debug zebra packet",
228 NO_STR
229 DEBUG_STR
230 "Zebra configuration\n"
231 "Debug option set for zebra packet\n")
232{
233 zebra_debug_packet = 0;
234 return CMD_SUCCESS;
235}
236
237DEFUN (no_debug_zebra_packet_direct,
238 no_debug_zebra_packet_direct_cmd,
239 "no debug zebra packet (recv|send)",
240 NO_STR
241 DEBUG_STR
242 "Zebra configuration\n"
243 "Debug option set for zebra packet\n"
244 "Debug option set for receive packet\n"
245 "Debug option set for send packet\n")
246{
247 if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
248 zebra_debug_packet &= ~ZEBRA_DEBUG_SEND;
249 if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
250 zebra_debug_packet &= ~ZEBRA_DEBUG_RECV;
251 return CMD_SUCCESS;
252}
253
254DEFUN (no_debug_zebra_kernel,
255 no_debug_zebra_kernel_cmd,
256 "no debug zebra kernel",
257 NO_STR
258 DEBUG_STR
259 "Zebra configuration\n"
260 "Debug option set for zebra between kernel interface\n")
261{
262 zebra_debug_kernel = 0;
263 return CMD_SUCCESS;
264}
265
b0498dc6
PJ
266DEFUN (no_debug_zebra_rib,
267 no_debug_zebra_rib_cmd,
268 "no debug zebra rib",
269 NO_STR
270 DEBUG_STR
271 "Zebra configuration\n"
272 "Debug zebra RIB\n")
273{
274 zebra_debug_rib = 0;
275 return CMD_SUCCESS;
276}
277
278DEFUN (no_debug_zebra_rib_q,
279 no_debug_zebra_rib_q_cmd,
e5248434 280 "no debug zebra rib queue",
b0498dc6
PJ
281 NO_STR
282 DEBUG_STR
283 "Zebra configuration\n"
284 "Debug zebra RIB\n"
285 "Debug RIB queueing\n")
286{
287 UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
288 return CMD_SUCCESS;
289}
290
5adc2528
AS
291DEFUN (no_debug_zebra_fpm,
292 no_debug_zebra_fpm_cmd,
293 "no debug zebra fpm",
294 NO_STR
295 DEBUG_STR
296 "Zebra configuration\n"
297 "Debug zebra FPM events\n")
298{
299 zebra_debug_fpm = 0;
300 return CMD_SUCCESS;
301}
302
718e3744 303/* Debug node. */
304struct cmd_node debug_node =
305{
306 DEBUG_NODE,
307 "", /* Debug node has no interface. */
308 1
309};
310
a1ac18c4 311static int
718e3744 312config_write_debug (struct vty *vty)
313{
314 int write = 0;
315
316 if (IS_ZEBRA_DEBUG_EVENT)
317 {
318 vty_out (vty, "debug zebra events%s", VTY_NEWLINE);
319 write++;
320 }
321 if (IS_ZEBRA_DEBUG_PACKET)
322 {
323 if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV)
324 {
325 vty_out (vty, "debug zebra packet%s%s",
326 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
327 VTY_NEWLINE);
328 write++;
329 }
330 else
331 {
332 if (IS_ZEBRA_DEBUG_SEND)
333 vty_out (vty, "debug zebra packet send%s%s",
334 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
335 VTY_NEWLINE);
336 else
337 vty_out (vty, "debug zebra packet recv%s%s",
338 IS_ZEBRA_DEBUG_DETAIL ? " detail" : "",
339 VTY_NEWLINE);
340 write++;
341 }
342 }
343 if (IS_ZEBRA_DEBUG_KERNEL)
344 {
345 vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
346 write++;
347 }
b0498dc6
PJ
348 if (IS_ZEBRA_DEBUG_RIB)
349 {
350 vty_out (vty, "debug zebra rib%s", VTY_NEWLINE);
351 write++;
352 }
353 if (IS_ZEBRA_DEBUG_RIB_Q)
354 {
355 vty_out (vty, "debug zebra rib queue%s", VTY_NEWLINE);
356 write++;
357 }
5adc2528
AS
358 if (IS_ZEBRA_DEBUG_FPM)
359 {
360 vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE);
361 write++;
362 }
718e3744 363 return write;
364}
365
366void
a1ac18c4 367zebra_debug_init (void)
718e3744 368{
369 zebra_debug_event = 0;
370 zebra_debug_packet = 0;
b0498dc6
PJ
371 zebra_debug_kernel = 0;
372 zebra_debug_rib = 0;
5adc2528 373 zebra_debug_fpm = 0;
718e3744 374
375 install_node (&debug_node, config_write_debug);
376
377 install_element (VIEW_NODE, &show_debugging_zebra_cmd);
378
379 install_element (ENABLE_NODE, &show_debugging_zebra_cmd);
380 install_element (ENABLE_NODE, &debug_zebra_events_cmd);
fb018d25 381 install_element (ENABLE_NODE, &debug_zebra_nht_cmd);
718e3744 382 install_element (ENABLE_NODE, &debug_zebra_packet_cmd);
383 install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd);
384 install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd);
385 install_element (ENABLE_NODE, &debug_zebra_kernel_cmd);
b0498dc6
PJ
386 install_element (ENABLE_NODE, &debug_zebra_rib_cmd);
387 install_element (ENABLE_NODE, &debug_zebra_rib_q_cmd);
5adc2528 388 install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
718e3744 389 install_element (ENABLE_NODE, &no_debug_zebra_events_cmd);
fb018d25 390 install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd);
718e3744 391 install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd);
392 install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd);
b0498dc6
PJ
393 install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd);
394 install_element (ENABLE_NODE, &no_debug_zebra_rib_q_cmd);
5adc2528 395 install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
718e3744 396
397 install_element (CONFIG_NODE, &debug_zebra_events_cmd);
fb018d25 398 install_element (CONFIG_NODE, &debug_zebra_nht_cmd);
718e3744 399 install_element (CONFIG_NODE, &debug_zebra_packet_cmd);
400 install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd);
401 install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd);
402 install_element (CONFIG_NODE, &debug_zebra_kernel_cmd);
b0498dc6
PJ
403 install_element (CONFIG_NODE, &debug_zebra_rib_cmd);
404 install_element (CONFIG_NODE, &debug_zebra_rib_q_cmd);
5adc2528 405 install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
718e3744 406 install_element (CONFIG_NODE, &no_debug_zebra_events_cmd);
fb018d25 407 install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd);
718e3744 408 install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd);
409 install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd);
b0498dc6
PJ
410 install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd);
411 install_element (CONFIG_NODE, &no_debug_zebra_rib_q_cmd);
5adc2528 412 install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);
718e3744 413}