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