blob: 60284a2d8c4cd6dd382c670dc96d2b439fdd5703 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP-4, BGP-4+ packet debug routine
2 Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
gdt5e4fa162004-03-16 14:38:36 +000023#include <lib/version.h>
paul718e3742002-12-13 20:15:29 +000024#include "prefix.h"
25#include "linklist.h"
26#include "stream.h"
27#include "command.h"
28#include "str.h"
29#include "log.h"
30#include "sockunion.h"
31
32#include "bgpd/bgpd.h"
33#include "bgpd/bgp_aspath.h"
34#include "bgpd/bgp_route.h"
35#include "bgpd/bgp_attr.h"
36#include "bgpd/bgp_debug.h"
37#include "bgpd/bgp_community.h"
38
39unsigned long conf_bgp_debug_fsm;
40unsigned long conf_bgp_debug_events;
41unsigned long conf_bgp_debug_packet;
42unsigned long conf_bgp_debug_filter;
43unsigned long conf_bgp_debug_keepalive;
44unsigned long conf_bgp_debug_update;
45unsigned long conf_bgp_debug_normal;
Andrew J. Schorra39275d2006-11-30 16:36:57 +000046unsigned long conf_bgp_debug_zebra;
paul718e3742002-12-13 20:15:29 +000047
48unsigned long term_bgp_debug_fsm;
49unsigned long term_bgp_debug_events;
50unsigned long term_bgp_debug_packet;
51unsigned long term_bgp_debug_filter;
52unsigned long term_bgp_debug_keepalive;
53unsigned long term_bgp_debug_update;
54unsigned long term_bgp_debug_normal;
Andrew J. Schorra39275d2006-11-30 16:36:57 +000055unsigned long term_bgp_debug_zebra;
paul718e3742002-12-13 20:15:29 +000056
57/* messages for BGP-4 status */
58struct message bgp_status_msg[] =
59{
60 { 0, "null" },
61 { Idle, "Idle" },
62 { Connect, "Connect" },
63 { Active, "Active" },
64 { OpenSent, "OpenSent" },
65 { OpenConfirm, "OpenConfirm" },
66 { Established, "Established" },
Paul Jakmaca058a32006-09-14 02:58:49 +000067 { Clearing, "Clearing" },
68 { Deleted, "Deleted" },
paul718e3742002-12-13 20:15:29 +000069};
70int bgp_status_msg_max = BGP_STATUS_MAX;
71
72/* BGP message type string. */
paulfd79ac92004-10-13 05:06:08 +000073const char *bgp_type_str[] =
paul718e3742002-12-13 20:15:29 +000074{
75 NULL,
76 "OPEN",
77 "UPDATE",
78 "NOTIFICATION",
79 "KEEPALIVE",
80 "ROUTE-REFRESH",
81 "CAPABILITY"
82};
83
84/* message for BGP-4 Notify */
85struct message bgp_notify_msg[] =
86{
87 { 0, "" },
88 { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
89 { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
90 { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
91 { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
92 { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
93 { BGP_NOTIFY_CEASE, "Cease"},
94 { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
95};
96int bgp_notify_msg_max = BGP_NOTIFY_MAX;
97
98struct message bgp_notify_head_msg[] =
99{
100 { 0, "null"},
hasso3950fda2004-05-20 10:22:49 +0000101 { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
102 { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
103 { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}
paul718e3742002-12-13 20:15:29 +0000104};
105int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX;
106
107struct message bgp_notify_open_msg[] =
108{
109 { 0, "null" },
hasso3950fda2004-05-20 10:22:49 +0000110 { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
111 { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
112 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
113 { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
114 { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
115 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
116 { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
paul718e3742002-12-13 20:15:29 +0000117};
118int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX;
119
120struct message bgp_notify_update_msg[] =
121{
122 { 0, "null"},
hasso3950fda2004-05-20 10:22:49 +0000123 { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
124 { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
125 { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
126 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
127 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
128 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
129 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
130 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
131 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
132 { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
133 { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
paul718e3742002-12-13 20:15:29 +0000134};
135int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX;
136
137struct message bgp_notify_cease_msg[] =
138{
139 { 0, ""},
hasso3950fda2004-05-20 10:22:49 +0000140 { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
141 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
142 { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
143 { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
144 { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
145 { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
146 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"},
147 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
paul718e3742002-12-13 20:15:29 +0000148};
149int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX;
150
151struct message bgp_notify_capability_msg[] =
152{
153 { 0, "null" },
hasso3950fda2004-05-20 10:22:49 +0000154 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" },
155 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
156 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
paul718e3742002-12-13 20:15:29 +0000157};
158int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
159
160/* Origin strings. */
paulfd79ac92004-10-13 05:06:08 +0000161const char *bgp_origin_str[] = {"i","e","?"};
162const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
paul718e3742002-12-13 20:15:29 +0000163
164/* Dump attribute. */
paule01f9cb2004-07-09 17:48:53 +0000165int
paul718e3742002-12-13 20:15:29 +0000166bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
167{
paul718e3742002-12-13 20:15:29 +0000168 if (! attr)
paule01f9cb2004-07-09 17:48:53 +0000169 return 0;
paul718e3742002-12-13 20:15:29 +0000170
paule01f9cb2004-07-09 17:48:53 +0000171 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
172 snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
173
174 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
175 snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
176 bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +0000177
178#ifdef HAVE_IPV6
Paul Jakmafb982c22007-05-04 20:15:47 +0000179 if (attr->extra)
180 {
181 char addrbuf[BUFSIZ];
paul718e3742002-12-13 20:15:29 +0000182
Paul Jakmafb982c22007-05-04 20:15:47 +0000183 /* Add MP case. */
184 if (attr->extra->mp_nexthop_len == 16
185 || attr->extra->mp_nexthop_len == 32)
186 snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
187 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
188 addrbuf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +0000189
Paul Jakmafb982c22007-05-04 20:15:47 +0000190 if (attr->extra->mp_nexthop_len == 32)
191 snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
192 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
193 addrbuf, BUFSIZ));
194 }
paul718e3742002-12-13 20:15:29 +0000195#endif /* HAVE_IPV6 */
196
paule01f9cb2004-07-09 17:48:53 +0000197 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
paul718e3742002-12-13 20:15:29 +0000198 snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %d",
199 attr->local_pref);
200
paule01f9cb2004-07-09 17:48:53 +0000201 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
paul718e3742002-12-13 20:15:29 +0000202 snprintf (buf + strlen (buf), size - strlen (buf), ", metric %d",
203 attr->med);
204
paule01f9cb2004-07-09 17:48:53 +0000205 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
paul718e3742002-12-13 20:15:29 +0000206 snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
207 community_str (attr->community));
208
paule01f9cb2004-07-09 17:48:53 +0000209 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
paul718e3742002-12-13 20:15:29 +0000210 snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
211
paule01f9cb2004-07-09 17:48:53 +0000212 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
paul718e3742002-12-13 20:15:29 +0000213 snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
Paul Jakmafb982c22007-05-04 20:15:47 +0000214 attr->extra->aggregator_as,
215 inet_ntoa (attr->extra->aggregator_addr));
paul718e3742002-12-13 20:15:29 +0000216
paule01f9cb2004-07-09 17:48:53 +0000217 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
paul718e3742002-12-13 20:15:29 +0000218 snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
Paul Jakmafb982c22007-05-04 20:15:47 +0000219 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +0000220
paule01f9cb2004-07-09 17:48:53 +0000221 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
paul718e3742002-12-13 20:15:29 +0000222 {
223 int i;
224
paule01f9cb2004-07-09 17:48:53 +0000225 snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
Paul Jakmafb982c22007-05-04 20:15:47 +0000226 for (i = 0; i < attr->extra->cluster->length / 4; i++)
paule01f9cb2004-07-09 17:48:53 +0000227 snprintf (buf + strlen (buf), size - strlen (buf), " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +0000228 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +0000229 }
230
paule01f9cb2004-07-09 17:48:53 +0000231 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
paul718e3742002-12-13 20:15:29 +0000232 snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
233 aspath_print (attr->aspath));
paule01f9cb2004-07-09 17:48:53 +0000234
235 if (strlen (buf) > 1)
236 return 1;
237 else
238 return 0;
paul718e3742002-12-13 20:15:29 +0000239}
240
241/* dump notify packet */
242void
paulfd79ac92004-10-13 05:06:08 +0000243bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
244 const char *direct)
paul718e3742002-12-13 20:15:29 +0000245{
paulfd79ac92004-10-13 05:06:08 +0000246 const char *subcode_str;
paul718e3742002-12-13 20:15:29 +0000247
248 subcode_str = "";
249
250 switch (bgp_notify->code)
251 {
252 case BGP_NOTIFY_HEADER_ERR:
253 subcode_str = LOOKUP (bgp_notify_head_msg, bgp_notify->subcode);
254 break;
255 case BGP_NOTIFY_OPEN_ERR:
256 subcode_str = LOOKUP (bgp_notify_open_msg, bgp_notify->subcode);
257 break;
258 case BGP_NOTIFY_UPDATE_ERR:
259 subcode_str = LOOKUP (bgp_notify_update_msg, bgp_notify->subcode);
260 break;
261 case BGP_NOTIFY_HOLD_ERR:
262 subcode_str = "";
263 break;
264 case BGP_NOTIFY_FSM_ERR:
265 subcode_str = "";
266 break;
267 case BGP_NOTIFY_CEASE:
268 subcode_str = LOOKUP (bgp_notify_cease_msg, bgp_notify->subcode);
269 break;
270 case BGP_NOTIFY_CAPABILITY_ERR:
271 subcode_str = LOOKUP (bgp_notify_capability_msg, bgp_notify->subcode);
272 break;
273 }
hasso3950fda2004-05-20 10:22:49 +0000274
275 if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
276 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
277 strcmp (direct, "received") == 0 ? "received from" : "sent to",
278 peer->host, bgp_notify->code, bgp_notify->subcode,
279 LOOKUP (bgp_notify_msg, bgp_notify->code),
280 subcode_str, bgp_notify->length,
281 bgp_notify->data ? bgp_notify->data : "");
282 else if (BGP_DEBUG (normal, NORMAL))
ajs557865c2004-12-08 19:59:11 +0000283 plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
paul718e3742002-12-13 20:15:29 +0000284 peer ? peer->host : "",
285 direct, bgp_notify->code, bgp_notify->subcode,
286 LOOKUP (bgp_notify_msg, bgp_notify->code),
287 subcode_str, bgp_notify->length,
288 bgp_notify->data ? bgp_notify->data : "");
289}
290
291/* Debug option setting interface. */
292unsigned long bgp_debug_option = 0;
293
294int
295debug (unsigned int option)
296{
297 return bgp_debug_option & option;
298}
299
300DEFUN (debug_bgp_fsm,
301 debug_bgp_fsm_cmd,
302 "debug bgp fsm",
303 DEBUG_STR
304 BGP_STR
305 "BGP Finite State Machine\n")
306{
307 if (vty->node == CONFIG_NODE)
308 DEBUG_ON (fsm, FSM);
309 else
310 {
311 TERM_DEBUG_ON (fsm, FSM);
312 vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
313 }
314 return CMD_SUCCESS;
315}
316
317DEFUN (no_debug_bgp_fsm,
318 no_debug_bgp_fsm_cmd,
319 "no debug bgp fsm",
320 NO_STR
321 DEBUG_STR
322 BGP_STR
323 "Finite State Machine\n")
324{
325 if (vty->node == CONFIG_NODE)
326 DEBUG_OFF (fsm, FSM);
327 else
328 {
329 TERM_DEBUG_OFF (fsm, FSM);
330 vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
331 }
332 return CMD_SUCCESS;
333}
334
335ALIAS (no_debug_bgp_fsm,
336 undebug_bgp_fsm_cmd,
337 "undebug bgp fsm",
338 UNDEBUG_STR
339 DEBUG_STR
340 BGP_STR
341 "Finite State Machine\n")
342
343DEFUN (debug_bgp_events,
344 debug_bgp_events_cmd,
345 "debug bgp events",
346 DEBUG_STR
347 BGP_STR
348 "BGP events\n")
349{
350 if (vty->node == CONFIG_NODE)
351 DEBUG_ON (events, EVENTS);
352 else
353 {
354 TERM_DEBUG_ON (events, EVENTS);
355 vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
356 }
357 return CMD_SUCCESS;
358}
359
360DEFUN (no_debug_bgp_events,
361 no_debug_bgp_events_cmd,
362 "no debug bgp events",
363 NO_STR
364 DEBUG_STR
365 BGP_STR
366 "BGP events\n")
367{
368 if (vty->node == CONFIG_NODE)
369 DEBUG_OFF (events, EVENTS);
370 else
371 {
372 TERM_DEBUG_OFF (events, EVENTS);
373 vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
374 }
375 return CMD_SUCCESS;
376}
377
378ALIAS (no_debug_bgp_events,
379 undebug_bgp_events_cmd,
380 "undebug bgp events",
381 UNDEBUG_STR
382 BGP_STR
383 "BGP events\n")
384
385DEFUN (debug_bgp_filter,
386 debug_bgp_filter_cmd,
387 "debug bgp filters",
388 DEBUG_STR
389 BGP_STR
390 "BGP filters\n")
391{
392 if (vty->node == CONFIG_NODE)
393 DEBUG_ON (filter, FILTER);
394 else
395 {
396 TERM_DEBUG_ON (filter, FILTER);
397 vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
398 }
399 return CMD_SUCCESS;
400}
401
402DEFUN (no_debug_bgp_filter,
403 no_debug_bgp_filter_cmd,
404 "no debug bgp filters",
405 NO_STR
406 DEBUG_STR
407 BGP_STR
408 "BGP filters\n")
409{
410 if (vty->node == CONFIG_NODE)
411 DEBUG_OFF (filter, FILTER);
412 else
413 {
414 TERM_DEBUG_OFF (filter, FILTER);
415 vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
416 }
417 return CMD_SUCCESS;
418}
419
420ALIAS (no_debug_bgp_filter,
421 undebug_bgp_filter_cmd,
422 "undebug bgp filters",
423 UNDEBUG_STR
424 BGP_STR
425 "BGP filters\n")
426
427DEFUN (debug_bgp_keepalive,
428 debug_bgp_keepalive_cmd,
429 "debug bgp keepalives",
430 DEBUG_STR
431 BGP_STR
432 "BGP keepalives\n")
433{
434 if (vty->node == CONFIG_NODE)
435 DEBUG_ON (keepalive, KEEPALIVE);
436 else
437 {
438 TERM_DEBUG_ON (keepalive, KEEPALIVE);
439 vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
440 }
441 return CMD_SUCCESS;
442}
443
444DEFUN (no_debug_bgp_keepalive,
445 no_debug_bgp_keepalive_cmd,
446 "no debug bgp keepalives",
447 NO_STR
448 DEBUG_STR
449 BGP_STR
450 "BGP keepalives\n")
451{
452 if (vty->node == CONFIG_NODE)
453 DEBUG_OFF (keepalive, KEEPALIVE);
454 else
455 {
456 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
457 vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
458 }
459 return CMD_SUCCESS;
460}
461
462ALIAS (no_debug_bgp_keepalive,
463 undebug_bgp_keepalive_cmd,
464 "undebug bgp keepalives",
465 UNDEBUG_STR
466 BGP_STR
467 "BGP keepalives\n")
468
469DEFUN (debug_bgp_update,
470 debug_bgp_update_cmd,
471 "debug bgp updates",
472 DEBUG_STR
473 BGP_STR
474 "BGP updates\n")
475{
476 if (vty->node == CONFIG_NODE)
477 {
478 DEBUG_ON (update, UPDATE_IN);
479 DEBUG_ON (update, UPDATE_OUT);
480 }
481 else
482 {
483 TERM_DEBUG_ON (update, UPDATE_IN);
484 TERM_DEBUG_ON (update, UPDATE_OUT);
485 vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
486 }
487 return CMD_SUCCESS;
488}
489
490DEFUN (debug_bgp_update_direct,
491 debug_bgp_update_direct_cmd,
492 "debug bgp updates (in|out)",
493 DEBUG_STR
494 BGP_STR
495 "BGP updates\n"
496 "Inbound updates\n"
497 "Outbound updates\n")
498{
499 if (vty->node == CONFIG_NODE)
500 {
501 if (strncmp ("i", argv[0], 1) == 0)
502 {
503 DEBUG_OFF (update, UPDATE_OUT);
504 DEBUG_ON (update, UPDATE_IN);
505 }
506 else
507 {
508 DEBUG_OFF (update, UPDATE_IN);
509 DEBUG_ON (update, UPDATE_OUT);
510 }
511 }
512 else
513 {
514 if (strncmp ("i", argv[0], 1) == 0)
515 {
516 TERM_DEBUG_OFF (update, UPDATE_OUT);
517 TERM_DEBUG_ON (update, UPDATE_IN);
518 vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
519 }
520 else
521 {
522 TERM_DEBUG_OFF (update, UPDATE_IN);
523 TERM_DEBUG_ON (update, UPDATE_OUT);
524 vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
525 }
526 }
527 return CMD_SUCCESS;
528}
529
530DEFUN (no_debug_bgp_update,
531 no_debug_bgp_update_cmd,
532 "no debug bgp updates",
533 NO_STR
534 DEBUG_STR
535 BGP_STR
536 "BGP updates\n")
537{
538 if (vty->node == CONFIG_NODE)
539 {
540 DEBUG_OFF (update, UPDATE_IN);
541 DEBUG_OFF (update, UPDATE_OUT);
542 }
543 else
544 {
545 TERM_DEBUG_OFF (update, UPDATE_IN);
546 TERM_DEBUG_OFF (update, UPDATE_OUT);
547 vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
548 }
549 return CMD_SUCCESS;
550}
551
552ALIAS (no_debug_bgp_update,
553 undebug_bgp_update_cmd,
554 "undebug bgp updates",
555 UNDEBUG_STR
556 BGP_STR
557 "BGP updates\n")
558
559DEFUN (debug_bgp_normal,
560 debug_bgp_normal_cmd,
561 "debug bgp",
562 DEBUG_STR
563 BGP_STR)
564{
565 if (vty->node == CONFIG_NODE)
566 DEBUG_ON (normal, NORMAL);
567 else
568 {
569 TERM_DEBUG_ON (normal, NORMAL);
570 vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
571 }
572 return CMD_SUCCESS;
573}
574
575DEFUN (no_debug_bgp_normal,
576 no_debug_bgp_normal_cmd,
577 "no debug bgp",
578 NO_STR
579 DEBUG_STR
580 BGP_STR)
581{
582 if (vty->node == CONFIG_NODE)
583 DEBUG_OFF (normal, NORMAL);
584 else
585 {
586 TERM_DEBUG_OFF (normal, NORMAL);
587 vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
588 }
589 return CMD_SUCCESS;
590}
591
592ALIAS (no_debug_bgp_normal,
593 undebug_bgp_normal_cmd,
594 "undebug bgp",
595 UNDEBUG_STR
596 BGP_STR)
597
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000598DEFUN (debug_bgp_zebra,
599 debug_bgp_zebra_cmd,
600 "debug bgp zebra",
601 DEBUG_STR
602 BGP_STR
603 "BGP Zebra messages\n")
604{
605 if (vty->node == CONFIG_NODE)
606 DEBUG_ON (zebra, ZEBRA);
607 else
608 {
609 TERM_DEBUG_ON (zebra, ZEBRA);
610 vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE);
611 }
612 return CMD_SUCCESS;
613}
614
615DEFUN (no_debug_bgp_zebra,
616 no_debug_bgp_zebra_cmd,
617 "no debug bgp zebra",
618 NO_STR
619 DEBUG_STR
620 BGP_STR
621 "BGP Zebra messages\n")
622{
623 if (vty->node == CONFIG_NODE)
624 DEBUG_OFF (zebra, ZEBRA);
625 else
626 {
627 TERM_DEBUG_OFF (zebra, ZEBRA);
628 vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
629 }
630 return CMD_SUCCESS;
631}
632
633ALIAS (no_debug_bgp_zebra,
634 undebug_bgp_zebra_cmd,
635 "undebug bgp zebra",
636 UNDEBUG_STR
637 DEBUG_STR
638 BGP_STR
639 "BGP Zebra messages\n")
640
paul718e3742002-12-13 20:15:29 +0000641DEFUN (no_debug_bgp_all,
642 no_debug_bgp_all_cmd,
643 "no debug all bgp",
644 NO_STR
645 DEBUG_STR
646 "Enable all debugging\n"
647 BGP_STR)
648{
649 TERM_DEBUG_OFF (normal, NORMAL);
650 TERM_DEBUG_OFF (events, EVENTS);
651 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
652 TERM_DEBUG_OFF (update, UPDATE_IN);
653 TERM_DEBUG_OFF (update, UPDATE_OUT);
654 TERM_DEBUG_OFF (fsm, FSM);
655 TERM_DEBUG_OFF (filter, FILTER);
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000656 TERM_DEBUG_OFF (zebra, ZEBRA);
paul718e3742002-12-13 20:15:29 +0000657 vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
658
659 return CMD_SUCCESS;
660}
661
662ALIAS (no_debug_bgp_all,
663 undebug_bgp_all_cmd,
664 "undebug all bgp",
665 UNDEBUG_STR
666 "Enable all debugging\n"
667 BGP_STR)
668
669DEFUN (show_debugging_bgp,
670 show_debugging_bgp_cmd,
671 "show debugging bgp",
672 SHOW_STR
673 DEBUG_STR
674 BGP_STR)
675{
676 vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
677
678 if (BGP_DEBUG (normal, NORMAL))
679 vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE);
680 if (BGP_DEBUG (events, EVENTS))
681 vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE);
682 if (BGP_DEBUG (keepalive, KEEPALIVE))
683 vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE);
684 if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
685 vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE);
686 else if (BGP_DEBUG (update, UPDATE_IN))
687 vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
688 else if (BGP_DEBUG (update, UPDATE_OUT))
689 vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
690 if (BGP_DEBUG (fsm, FSM))
691 vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
692 if (BGP_DEBUG (filter, FILTER))
693 vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000694 if (BGP_DEBUG (zebra, ZEBRA))
695 vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000696 vty_out (vty, "%s", VTY_NEWLINE);
697 return CMD_SUCCESS;
698}
699
paul94f2b392005-06-28 12:44:16 +0000700static int
paul718e3742002-12-13 20:15:29 +0000701bgp_config_write_debug (struct vty *vty)
702{
703 int write = 0;
704
705 if (CONF_BGP_DEBUG (normal, NORMAL))
706 {
707 vty_out (vty, "debug bgp%s", VTY_NEWLINE);
708 write++;
709 }
710
711 if (CONF_BGP_DEBUG (events, EVENTS))
712 {
713 vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
714 write++;
715 }
716
717 if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
718 {
719 vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
720 write++;
721 }
722
723 if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
724 {
725 vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
726 write++;
727 }
728 else if (CONF_BGP_DEBUG (update, UPDATE_IN))
729 {
730 vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
731 write++;
732 }
733 else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
734 {
735 vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
736 write++;
737 }
738
739 if (CONF_BGP_DEBUG (fsm, FSM))
740 {
741 vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
742 write++;
743 }
744
745 if (CONF_BGP_DEBUG (filter, FILTER))
746 {
747 vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
748 write++;
749 }
750
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000751 if (CONF_BGP_DEBUG (zebra, ZEBRA))
752 {
753 vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE);
754 write++;
755 }
756
paul718e3742002-12-13 20:15:29 +0000757 return write;
758}
759
760struct cmd_node debug_node =
761{
762 DEBUG_NODE,
763 "",
764 1
765};
766
767void
paul94f2b392005-06-28 12:44:16 +0000768bgp_debug_init (void)
paul718e3742002-12-13 20:15:29 +0000769{
770 install_node (&debug_node, bgp_config_write_debug);
771
772 install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
773
774 install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
775 install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
776 install_element (ENABLE_NODE, &debug_bgp_events_cmd);
777 install_element (CONFIG_NODE, &debug_bgp_events_cmd);
778 install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
779 install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
780 install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
781 install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
782 install_element (ENABLE_NODE, &debug_bgp_update_cmd);
783 install_element (CONFIG_NODE, &debug_bgp_update_cmd);
784 install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
785 install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
786 install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
787 install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000788 install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
789 install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
paul718e3742002-12-13 20:15:29 +0000790
791 install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
792 install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
793 install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
794 install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
795 install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
796 install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
797 install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
798 install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
799 install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
800 install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
801 install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
802 install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
803 install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
804 install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
805 install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
806 install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
807 install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
808 install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
Andrew J. Schorra39275d2006-11-30 16:36:57 +0000809 install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
810 install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
811 install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
paul718e3742002-12-13 20:15:29 +0000812 install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
813 install_element (ENABLE_NODE, &undebug_bgp_all_cmd);
814}