]>
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; |
fb018d25 | 33 | unsigned long zebra_debug_nht; |
718e3744 | 34 | |
35 | DEFUN (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 | ||
41ec9222 | 71 | /* Check here using flags as the 'macro' does an OR */ |
72 | if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB)) | |
b0498dc6 | 73 | vty_out (vty, " Zebra RIB debugging is on%s", VTY_NEWLINE); |
41ec9222 | 74 | if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) |
75 | vty_out (vty, " Zebra RIB detailed debugging is on%s", VTY_NEWLINE); | |
b0498dc6 | 76 | |
5adc2528 AS |
77 | if (IS_ZEBRA_DEBUG_FPM) |
78 | vty_out (vty, " Zebra FPM debugging is on%s", VTY_NEWLINE); | |
fb018d25 DS |
79 | if (IS_ZEBRA_DEBUG_NHT) |
80 | vty_out (vty, " Zebra next-hop tracking debugging is on%s", VTY_NEWLINE); | |
5adc2528 | 81 | |
718e3744 | 82 | return CMD_SUCCESS; |
83 | } | |
84 | ||
85 | DEFUN (debug_zebra_events, | |
86 | debug_zebra_events_cmd, | |
87 | "debug zebra events", | |
88 | DEBUG_STR | |
89 | "Zebra configuration\n" | |
90 | "Debug option set for zebra events\n") | |
91 | { | |
92 | zebra_debug_event = ZEBRA_DEBUG_EVENT; | |
93 | return CMD_WARNING; | |
94 | } | |
95 | ||
fb018d25 DS |
96 | DEFUN (debug_zebra_nht, |
97 | debug_zebra_nht_cmd, | |
98 | "debug zebra nht", | |
99 | DEBUG_STR | |
100 | "Zebra configuration\n" | |
101 | "Debug option set for zebra next hop tracking\n") | |
102 | { | |
103 | zebra_debug_nht = ZEBRA_DEBUG_NHT; | |
104 | return CMD_WARNING; | |
105 | } | |
106 | ||
718e3744 | 107 | DEFUN (debug_zebra_packet, |
108 | debug_zebra_packet_cmd, | |
109 | "debug zebra packet", | |
110 | DEBUG_STR | |
111 | "Zebra configuration\n" | |
112 | "Debug option set for zebra packet\n") | |
113 | { | |
114 | zebra_debug_packet = ZEBRA_DEBUG_PACKET; | |
115 | zebra_debug_packet |= ZEBRA_DEBUG_SEND; | |
116 | zebra_debug_packet |= ZEBRA_DEBUG_RECV; | |
117 | return CMD_SUCCESS; | |
118 | } | |
119 | ||
120 | DEFUN (debug_zebra_packet_direct, | |
121 | debug_zebra_packet_direct_cmd, | |
122 | "debug zebra packet (recv|send)", | |
123 | DEBUG_STR | |
124 | "Zebra configuration\n" | |
125 | "Debug option set for zebra packet\n" | |
126 | "Debug option set for receive packet\n" | |
127 | "Debug option set for send packet\n") | |
128 | { | |
129 | zebra_debug_packet = ZEBRA_DEBUG_PACKET; | |
130 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
131 | zebra_debug_packet |= ZEBRA_DEBUG_SEND; | |
132 | if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
133 | zebra_debug_packet |= ZEBRA_DEBUG_RECV; | |
134 | zebra_debug_packet &= ~ZEBRA_DEBUG_DETAIL; | |
135 | return CMD_SUCCESS; | |
136 | } | |
137 | ||
138 | DEFUN (debug_zebra_packet_detail, | |
139 | debug_zebra_packet_detail_cmd, | |
140 | "debug zebra packet (recv|send) detail", | |
141 | DEBUG_STR | |
142 | "Zebra configuration\n" | |
143 | "Debug option set for zebra packet\n" | |
144 | "Debug option set for receive packet\n" | |
145 | "Debug option set for send packet\n" | |
2b00515a | 146 | "Debug option set detailed information\n") |
718e3744 | 147 | { |
148 | zebra_debug_packet = ZEBRA_DEBUG_PACKET; | |
149 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
150 | zebra_debug_packet |= ZEBRA_DEBUG_SEND; | |
151 | if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
152 | zebra_debug_packet |= ZEBRA_DEBUG_RECV; | |
153 | zebra_debug_packet |= ZEBRA_DEBUG_DETAIL; | |
154 | return CMD_SUCCESS; | |
155 | } | |
156 | ||
157 | DEFUN (debug_zebra_kernel, | |
158 | debug_zebra_kernel_cmd, | |
159 | "debug zebra kernel", | |
160 | DEBUG_STR | |
161 | "Zebra configuration\n" | |
162 | "Debug option set for zebra between kernel interface\n") | |
163 | { | |
164 | zebra_debug_kernel = ZEBRA_DEBUG_KERNEL; | |
165 | return CMD_SUCCESS; | |
166 | } | |
167 | ||
b0498dc6 PJ |
168 | DEFUN (debug_zebra_rib, |
169 | debug_zebra_rib_cmd, | |
170 | "debug zebra rib", | |
171 | DEBUG_STR | |
172 | "Zebra configuration\n" | |
173 | "Debug RIB events\n") | |
174 | { | |
175 | SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB); | |
176 | return CMD_SUCCESS; | |
177 | } | |
178 | ||
41ec9222 | 179 | DEFUN (debug_zebra_rib_detailed, |
180 | debug_zebra_rib_detailed_cmd, | |
181 | "debug zebra rib detailed", | |
b0498dc6 PJ |
182 | DEBUG_STR |
183 | "Zebra configuration\n" | |
184 | "Debug RIB events\n" | |
41ec9222 | 185 | "Detailed debugs\n") |
b0498dc6 | 186 | { |
41ec9222 | 187 | SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED); |
b0498dc6 PJ |
188 | return CMD_SUCCESS; |
189 | } | |
190 | ||
5adc2528 AS |
191 | DEFUN (debug_zebra_fpm, |
192 | debug_zebra_fpm_cmd, | |
193 | "debug zebra fpm", | |
194 | DEBUG_STR | |
195 | "Zebra configuration\n" | |
196 | "Debug zebra FPM events\n") | |
197 | { | |
198 | SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM); | |
199 | return CMD_SUCCESS; | |
200 | } | |
201 | ||
718e3744 | 202 | DEFUN (no_debug_zebra_events, |
203 | no_debug_zebra_events_cmd, | |
204 | "no debug zebra events", | |
205 | NO_STR | |
206 | DEBUG_STR | |
207 | "Zebra configuration\n" | |
208 | "Debug option set for zebra events\n") | |
209 | { | |
210 | zebra_debug_event = 0; | |
211 | return CMD_SUCCESS; | |
212 | } | |
213 | ||
fb018d25 DS |
214 | DEFUN (no_debug_zebra_nht, |
215 | no_debug_zebra_nht_cmd, | |
216 | "no debug zebra nht", | |
217 | NO_STR | |
218 | DEBUG_STR | |
219 | "Zebra configuration\n" | |
220 | "Debug option set for zebra next hop tracking\n") | |
221 | { | |
222 | zebra_debug_nht = 0; | |
223 | return CMD_SUCCESS; | |
224 | } | |
225 | ||
718e3744 | 226 | DEFUN (no_debug_zebra_packet, |
227 | no_debug_zebra_packet_cmd, | |
228 | "no debug zebra packet", | |
229 | NO_STR | |
230 | DEBUG_STR | |
231 | "Zebra configuration\n" | |
232 | "Debug option set for zebra packet\n") | |
233 | { | |
234 | zebra_debug_packet = 0; | |
235 | return CMD_SUCCESS; | |
236 | } | |
237 | ||
238 | DEFUN (no_debug_zebra_packet_direct, | |
239 | no_debug_zebra_packet_direct_cmd, | |
240 | "no debug zebra packet (recv|send)", | |
241 | NO_STR | |
242 | DEBUG_STR | |
243 | "Zebra configuration\n" | |
244 | "Debug option set for zebra packet\n" | |
245 | "Debug option set for receive packet\n" | |
246 | "Debug option set for send packet\n") | |
247 | { | |
248 | if (strncmp ("send", argv[0], strlen (argv[0])) == 0) | |
249 | zebra_debug_packet &= ~ZEBRA_DEBUG_SEND; | |
250 | if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) | |
251 | zebra_debug_packet &= ~ZEBRA_DEBUG_RECV; | |
252 | return CMD_SUCCESS; | |
253 | } | |
254 | ||
255 | DEFUN (no_debug_zebra_kernel, | |
256 | no_debug_zebra_kernel_cmd, | |
257 | "no debug zebra kernel", | |
258 | NO_STR | |
259 | DEBUG_STR | |
260 | "Zebra configuration\n" | |
261 | "Debug option set for zebra between kernel interface\n") | |
262 | { | |
263 | zebra_debug_kernel = 0; | |
264 | return CMD_SUCCESS; | |
265 | } | |
266 | ||
b0498dc6 PJ |
267 | DEFUN (no_debug_zebra_rib, |
268 | no_debug_zebra_rib_cmd, | |
269 | "no debug zebra rib", | |
270 | NO_STR | |
271 | DEBUG_STR | |
272 | "Zebra configuration\n" | |
273 | "Debug zebra RIB\n") | |
274 | { | |
275 | zebra_debug_rib = 0; | |
276 | return CMD_SUCCESS; | |
277 | } | |
278 | ||
41ec9222 | 279 | DEFUN (no_debug_zebra_rib_detailed, |
280 | no_debug_zebra_rib_detailed_cmd, | |
281 | "no debug zebra rib detailed", | |
b0498dc6 PJ |
282 | NO_STR |
283 | DEBUG_STR | |
284 | "Zebra configuration\n" | |
285 | "Debug zebra RIB\n" | |
41ec9222 | 286 | "Detailed debugs\n") |
b0498dc6 | 287 | { |
41ec9222 | 288 | UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED); |
b0498dc6 PJ |
289 | return CMD_SUCCESS; |
290 | } | |
291 | ||
5adc2528 AS |
292 | DEFUN (no_debug_zebra_fpm, |
293 | no_debug_zebra_fpm_cmd, | |
294 | "no debug zebra fpm", | |
295 | NO_STR | |
296 | DEBUG_STR | |
297 | "Zebra configuration\n" | |
298 | "Debug zebra FPM events\n") | |
299 | { | |
300 | zebra_debug_fpm = 0; | |
301 | return CMD_SUCCESS; | |
302 | } | |
303 | ||
718e3744 | 304 | /* Debug node. */ |
305 | struct cmd_node debug_node = | |
306 | { | |
307 | DEBUG_NODE, | |
308 | "", /* Debug node has no interface. */ | |
309 | 1 | |
310 | }; | |
311 | ||
a1ac18c4 | 312 | static int |
718e3744 | 313 | config_write_debug (struct vty *vty) |
314 | { | |
315 | int write = 0; | |
316 | ||
317 | if (IS_ZEBRA_DEBUG_EVENT) | |
318 | { | |
319 | vty_out (vty, "debug zebra events%s", VTY_NEWLINE); | |
320 | write++; | |
321 | } | |
322 | if (IS_ZEBRA_DEBUG_PACKET) | |
323 | { | |
324 | if (IS_ZEBRA_DEBUG_SEND && IS_ZEBRA_DEBUG_RECV) | |
325 | { | |
326 | vty_out (vty, "debug zebra packet%s%s", | |
327 | IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", | |
328 | VTY_NEWLINE); | |
329 | write++; | |
330 | } | |
331 | else | |
332 | { | |
333 | if (IS_ZEBRA_DEBUG_SEND) | |
334 | vty_out (vty, "debug zebra packet send%s%s", | |
335 | IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", | |
336 | VTY_NEWLINE); | |
337 | else | |
338 | vty_out (vty, "debug zebra packet recv%s%s", | |
339 | IS_ZEBRA_DEBUG_DETAIL ? " detail" : "", | |
340 | VTY_NEWLINE); | |
341 | write++; | |
342 | } | |
343 | } | |
344 | if (IS_ZEBRA_DEBUG_KERNEL) | |
345 | { | |
346 | vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE); | |
347 | write++; | |
348 | } | |
41ec9222 | 349 | /* Check here using flags as the 'macro' does an OR */ |
350 | if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB)) | |
b0498dc6 PJ |
351 | { |
352 | vty_out (vty, "debug zebra rib%s", VTY_NEWLINE); | |
353 | write++; | |
354 | } | |
41ec9222 | 355 | if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) |
b0498dc6 | 356 | { |
41ec9222 | 357 | vty_out (vty, "debug zebra rib detailed%s", VTY_NEWLINE); |
b0498dc6 PJ |
358 | write++; |
359 | } | |
5adc2528 AS |
360 | if (IS_ZEBRA_DEBUG_FPM) |
361 | { | |
362 | vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE); | |
363 | write++; | |
364 | } | |
718e3744 | 365 | return write; |
366 | } | |
367 | ||
368 | void | |
a1ac18c4 | 369 | zebra_debug_init (void) |
718e3744 | 370 | { |
371 | zebra_debug_event = 0; | |
372 | zebra_debug_packet = 0; | |
b0498dc6 PJ |
373 | zebra_debug_kernel = 0; |
374 | zebra_debug_rib = 0; | |
5adc2528 | 375 | zebra_debug_fpm = 0; |
718e3744 | 376 | |
377 | install_node (&debug_node, config_write_debug); | |
378 | ||
379 | install_element (VIEW_NODE, &show_debugging_zebra_cmd); | |
380 | ||
381 | install_element (ENABLE_NODE, &show_debugging_zebra_cmd); | |
382 | install_element (ENABLE_NODE, &debug_zebra_events_cmd); | |
fb018d25 | 383 | install_element (ENABLE_NODE, &debug_zebra_nht_cmd); |
718e3744 | 384 | install_element (ENABLE_NODE, &debug_zebra_packet_cmd); |
385 | install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd); | |
386 | install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd); | |
387 | install_element (ENABLE_NODE, &debug_zebra_kernel_cmd); | |
b0498dc6 | 388 | install_element (ENABLE_NODE, &debug_zebra_rib_cmd); |
41ec9222 | 389 | install_element (ENABLE_NODE, &debug_zebra_rib_detailed_cmd); |
5adc2528 | 390 | install_element (ENABLE_NODE, &debug_zebra_fpm_cmd); |
718e3744 | 391 | install_element (ENABLE_NODE, &no_debug_zebra_events_cmd); |
fb018d25 | 392 | install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd); |
718e3744 | 393 | install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd); |
394 | install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd); | |
b0498dc6 | 395 | install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd); |
41ec9222 | 396 | install_element (ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd); |
5adc2528 | 397 | install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd); |
718e3744 | 398 | |
399 | install_element (CONFIG_NODE, &debug_zebra_events_cmd); | |
fb018d25 | 400 | install_element (CONFIG_NODE, &debug_zebra_nht_cmd); |
718e3744 | 401 | install_element (CONFIG_NODE, &debug_zebra_packet_cmd); |
402 | install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd); | |
403 | install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd); | |
404 | install_element (CONFIG_NODE, &debug_zebra_kernel_cmd); | |
b0498dc6 | 405 | install_element (CONFIG_NODE, &debug_zebra_rib_cmd); |
41ec9222 | 406 | install_element (CONFIG_NODE, &debug_zebra_rib_detailed_cmd); |
5adc2528 | 407 | install_element (CONFIG_NODE, &debug_zebra_fpm_cmd); |
718e3744 | 408 | install_element (CONFIG_NODE, &no_debug_zebra_events_cmd); |
fb018d25 | 409 | install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd); |
718e3744 | 410 | install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd); |
411 | install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd); | |
b0498dc6 | 412 | install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd); |
41ec9222 | 413 | install_element (CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd); |
5adc2528 | 414 | install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd); |
718e3744 | 415 | } |