[bgpd] fix mtype in XFREE and NULL out freed pointer
[jleu-quagga.git] / bgpd / bgp_debug.c
blob1b398ee8b1b681334809827701c99cb2d18169dd
1 /* BGP-4, BGP-4+ packet debug routine
2 Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 #include <zebra.h>
23 #include <lib/version.h>
24 #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"
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"
39 unsigned long conf_bgp_debug_fsm;
40 unsigned long conf_bgp_debug_events;
41 unsigned long conf_bgp_debug_packet;
42 unsigned long conf_bgp_debug_filter;
43 unsigned long conf_bgp_debug_keepalive;
44 unsigned long conf_bgp_debug_update;
45 unsigned long conf_bgp_debug_normal;
47 unsigned long term_bgp_debug_fsm;
48 unsigned long term_bgp_debug_events;
49 unsigned long term_bgp_debug_packet;
50 unsigned long term_bgp_debug_filter;
51 unsigned long term_bgp_debug_keepalive;
52 unsigned long term_bgp_debug_update;
53 unsigned long term_bgp_debug_normal;
55 /* messages for BGP-4 status */
56 struct message bgp_status_msg[] =
58 { 0, "null" },
59 { Idle, "Idle" },
60 { Connect, "Connect" },
61 { Active, "Active" },
62 { OpenSent, "OpenSent" },
63 { OpenConfirm, "OpenConfirm" },
64 { Established, "Established" },
66 int bgp_status_msg_max = BGP_STATUS_MAX;
68 /* BGP message type string. */
69 const char *bgp_type_str[] =
71 NULL,
72 "OPEN",
73 "UPDATE",
74 "NOTIFICATION",
75 "KEEPALIVE",
76 "ROUTE-REFRESH",
77 "CAPABILITY"
80 /* message for BGP-4 Notify */
81 struct message bgp_notify_msg[] =
83 { 0, "" },
84 { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
85 { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
86 { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
87 { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
88 { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
89 { BGP_NOTIFY_CEASE, "Cease"},
90 { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
92 int bgp_notify_msg_max = BGP_NOTIFY_MAX;
94 struct message bgp_notify_head_msg[] =
96 { 0, "null"},
97 { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
98 { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
99 { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}
101 int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX;
103 struct message bgp_notify_open_msg[] =
105 { 0, "null" },
106 { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
107 { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
108 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
109 { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
110 { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
111 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
112 { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
114 int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX;
116 struct message bgp_notify_update_msg[] =
118 { 0, "null"},
119 { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
120 { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
121 { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
122 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
123 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
124 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
125 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
126 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
127 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
128 { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
129 { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
131 int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX;
133 struct message bgp_notify_cease_msg[] =
135 { 0, ""},
136 { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
137 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
138 { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
139 { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
140 { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
141 { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
142 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"},
143 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
145 int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX;
147 struct message bgp_notify_capability_msg[] =
149 { 0, "null" },
150 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" },
151 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
152 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
154 int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
156 /* Origin strings. */
157 const char *bgp_origin_str[] = {"i","e","?"};
158 const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
160 /* Dump attribute. */
162 bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
164 if (! attr)
165 return 0;
167 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
168 snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
170 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
171 snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
172 bgp_origin_str[attr->origin]);
174 #ifdef HAVE_IPV6
176 char addrbuf[BUFSIZ];
178 /* Add MP case. */
179 if (attr->mp_nexthop_len == 16 || attr->mp_nexthop_len == 32)
180 snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
181 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
182 addrbuf, BUFSIZ));
184 if (attr->mp_nexthop_len == 32)
185 snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
186 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
187 addrbuf, BUFSIZ));
189 #endif /* HAVE_IPV6 */
191 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
192 snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %d",
193 attr->local_pref);
195 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
196 snprintf (buf + strlen (buf), size - strlen (buf), ", metric %d",
197 attr->med);
199 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
200 snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
201 community_str (attr->community));
203 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
204 snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
206 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
207 snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
208 attr->aggregator_as, inet_ntoa (attr->aggregator_addr));
210 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
211 snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
212 inet_ntoa (attr->originator_id));
214 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
216 int i;
218 snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
219 for (i = 0; i < attr->cluster->length / 4; i++)
220 snprintf (buf + strlen (buf), size - strlen (buf), " %s",
221 inet_ntoa (attr->cluster->list[i]));
224 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
225 snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
226 aspath_print (attr->aspath));
228 if (strlen (buf) > 1)
229 return 1;
230 else
231 return 0;
234 /* dump notify packet */
235 void
236 bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
237 const char *direct)
239 const char *subcode_str;
241 subcode_str = "";
243 switch (bgp_notify->code)
245 case BGP_NOTIFY_HEADER_ERR:
246 subcode_str = LOOKUP (bgp_notify_head_msg, bgp_notify->subcode);
247 break;
248 case BGP_NOTIFY_OPEN_ERR:
249 subcode_str = LOOKUP (bgp_notify_open_msg, bgp_notify->subcode);
250 break;
251 case BGP_NOTIFY_UPDATE_ERR:
252 subcode_str = LOOKUP (bgp_notify_update_msg, bgp_notify->subcode);
253 break;
254 case BGP_NOTIFY_HOLD_ERR:
255 subcode_str = "";
256 break;
257 case BGP_NOTIFY_FSM_ERR:
258 subcode_str = "";
259 break;
260 case BGP_NOTIFY_CEASE:
261 subcode_str = LOOKUP (bgp_notify_cease_msg, bgp_notify->subcode);
262 break;
263 case BGP_NOTIFY_CAPABILITY_ERR:
264 subcode_str = LOOKUP (bgp_notify_capability_msg, bgp_notify->subcode);
265 break;
268 if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
269 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
270 strcmp (direct, "received") == 0 ? "received from" : "sent to",
271 peer->host, bgp_notify->code, bgp_notify->subcode,
272 LOOKUP (bgp_notify_msg, bgp_notify->code),
273 subcode_str, bgp_notify->length,
274 bgp_notify->data ? bgp_notify->data : "");
275 else if (BGP_DEBUG (normal, NORMAL))
276 plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
277 peer ? peer->host : "",
278 direct, 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 : "");
284 /* Debug option setting interface. */
285 unsigned long bgp_debug_option = 0;
287 int
288 debug (unsigned int option)
290 return bgp_debug_option & option;
293 DEFUN (debug_bgp_fsm,
294 debug_bgp_fsm_cmd,
295 "debug bgp fsm",
296 DEBUG_STR
297 BGP_STR
298 "BGP Finite State Machine\n")
300 if (vty->node == CONFIG_NODE)
301 DEBUG_ON (fsm, FSM);
302 else
304 TERM_DEBUG_ON (fsm, FSM);
305 vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
307 return CMD_SUCCESS;
310 DEFUN (no_debug_bgp_fsm,
311 no_debug_bgp_fsm_cmd,
312 "no debug bgp fsm",
313 NO_STR
314 DEBUG_STR
315 BGP_STR
316 "Finite State Machine\n")
318 if (vty->node == CONFIG_NODE)
319 DEBUG_OFF (fsm, FSM);
320 else
322 TERM_DEBUG_OFF (fsm, FSM);
323 vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
325 return CMD_SUCCESS;
328 ALIAS (no_debug_bgp_fsm,
329 undebug_bgp_fsm_cmd,
330 "undebug bgp fsm",
331 UNDEBUG_STR
332 DEBUG_STR
333 BGP_STR
334 "Finite State Machine\n")
336 DEFUN (debug_bgp_events,
337 debug_bgp_events_cmd,
338 "debug bgp events",
339 DEBUG_STR
340 BGP_STR
341 "BGP events\n")
343 if (vty->node == CONFIG_NODE)
344 DEBUG_ON (events, EVENTS);
345 else
347 TERM_DEBUG_ON (events, EVENTS);
348 vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
350 return CMD_SUCCESS;
353 DEFUN (no_debug_bgp_events,
354 no_debug_bgp_events_cmd,
355 "no debug bgp events",
356 NO_STR
357 DEBUG_STR
358 BGP_STR
359 "BGP events\n")
361 if (vty->node == CONFIG_NODE)
362 DEBUG_OFF (events, EVENTS);
363 else
365 TERM_DEBUG_OFF (events, EVENTS);
366 vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
368 return CMD_SUCCESS;
371 ALIAS (no_debug_bgp_events,
372 undebug_bgp_events_cmd,
373 "undebug bgp events",
374 UNDEBUG_STR
375 BGP_STR
376 "BGP events\n")
378 DEFUN (debug_bgp_filter,
379 debug_bgp_filter_cmd,
380 "debug bgp filters",
381 DEBUG_STR
382 BGP_STR
383 "BGP filters\n")
385 if (vty->node == CONFIG_NODE)
386 DEBUG_ON (filter, FILTER);
387 else
389 TERM_DEBUG_ON (filter, FILTER);
390 vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
392 return CMD_SUCCESS;
395 DEFUN (no_debug_bgp_filter,
396 no_debug_bgp_filter_cmd,
397 "no debug bgp filters",
398 NO_STR
399 DEBUG_STR
400 BGP_STR
401 "BGP filters\n")
403 if (vty->node == CONFIG_NODE)
404 DEBUG_OFF (filter, FILTER);
405 else
407 TERM_DEBUG_OFF (filter, FILTER);
408 vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
410 return CMD_SUCCESS;
413 ALIAS (no_debug_bgp_filter,
414 undebug_bgp_filter_cmd,
415 "undebug bgp filters",
416 UNDEBUG_STR
417 BGP_STR
418 "BGP filters\n")
420 DEFUN (debug_bgp_keepalive,
421 debug_bgp_keepalive_cmd,
422 "debug bgp keepalives",
423 DEBUG_STR
424 BGP_STR
425 "BGP keepalives\n")
427 if (vty->node == CONFIG_NODE)
428 DEBUG_ON (keepalive, KEEPALIVE);
429 else
431 TERM_DEBUG_ON (keepalive, KEEPALIVE);
432 vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
434 return CMD_SUCCESS;
437 DEFUN (no_debug_bgp_keepalive,
438 no_debug_bgp_keepalive_cmd,
439 "no debug bgp keepalives",
440 NO_STR
441 DEBUG_STR
442 BGP_STR
443 "BGP keepalives\n")
445 if (vty->node == CONFIG_NODE)
446 DEBUG_OFF (keepalive, KEEPALIVE);
447 else
449 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
450 vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
452 return CMD_SUCCESS;
455 ALIAS (no_debug_bgp_keepalive,
456 undebug_bgp_keepalive_cmd,
457 "undebug bgp keepalives",
458 UNDEBUG_STR
459 BGP_STR
460 "BGP keepalives\n")
462 DEFUN (debug_bgp_update,
463 debug_bgp_update_cmd,
464 "debug bgp updates",
465 DEBUG_STR
466 BGP_STR
467 "BGP updates\n")
469 if (vty->node == CONFIG_NODE)
471 DEBUG_ON (update, UPDATE_IN);
472 DEBUG_ON (update, UPDATE_OUT);
474 else
476 TERM_DEBUG_ON (update, UPDATE_IN);
477 TERM_DEBUG_ON (update, UPDATE_OUT);
478 vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
480 return CMD_SUCCESS;
483 DEFUN (debug_bgp_update_direct,
484 debug_bgp_update_direct_cmd,
485 "debug bgp updates (in|out)",
486 DEBUG_STR
487 BGP_STR
488 "BGP updates\n"
489 "Inbound updates\n"
490 "Outbound updates\n")
492 if (vty->node == CONFIG_NODE)
494 if (strncmp ("i", argv[0], 1) == 0)
496 DEBUG_OFF (update, UPDATE_OUT);
497 DEBUG_ON (update, UPDATE_IN);
499 else
501 DEBUG_OFF (update, UPDATE_IN);
502 DEBUG_ON (update, UPDATE_OUT);
505 else
507 if (strncmp ("i", argv[0], 1) == 0)
509 TERM_DEBUG_OFF (update, UPDATE_OUT);
510 TERM_DEBUG_ON (update, UPDATE_IN);
511 vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
513 else
515 TERM_DEBUG_OFF (update, UPDATE_IN);
516 TERM_DEBUG_ON (update, UPDATE_OUT);
517 vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
520 return CMD_SUCCESS;
523 DEFUN (no_debug_bgp_update,
524 no_debug_bgp_update_cmd,
525 "no debug bgp updates",
526 NO_STR
527 DEBUG_STR
528 BGP_STR
529 "BGP updates\n")
531 if (vty->node == CONFIG_NODE)
533 DEBUG_OFF (update, UPDATE_IN);
534 DEBUG_OFF (update, UPDATE_OUT);
536 else
538 TERM_DEBUG_OFF (update, UPDATE_IN);
539 TERM_DEBUG_OFF (update, UPDATE_OUT);
540 vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
542 return CMD_SUCCESS;
545 ALIAS (no_debug_bgp_update,
546 undebug_bgp_update_cmd,
547 "undebug bgp updates",
548 UNDEBUG_STR
549 BGP_STR
550 "BGP updates\n")
552 DEFUN (debug_bgp_normal,
553 debug_bgp_normal_cmd,
554 "debug bgp",
555 DEBUG_STR
556 BGP_STR)
558 if (vty->node == CONFIG_NODE)
559 DEBUG_ON (normal, NORMAL);
560 else
562 TERM_DEBUG_ON (normal, NORMAL);
563 vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
565 return CMD_SUCCESS;
568 DEFUN (no_debug_bgp_normal,
569 no_debug_bgp_normal_cmd,
570 "no debug bgp",
571 NO_STR
572 DEBUG_STR
573 BGP_STR)
575 if (vty->node == CONFIG_NODE)
576 DEBUG_OFF (normal, NORMAL);
577 else
579 TERM_DEBUG_OFF (normal, NORMAL);
580 vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
582 return CMD_SUCCESS;
585 ALIAS (no_debug_bgp_normal,
586 undebug_bgp_normal_cmd,
587 "undebug bgp",
588 UNDEBUG_STR
589 BGP_STR)
591 DEFUN (no_debug_bgp_all,
592 no_debug_bgp_all_cmd,
593 "no debug all bgp",
594 NO_STR
595 DEBUG_STR
596 "Enable all debugging\n"
597 BGP_STR)
599 TERM_DEBUG_OFF (normal, NORMAL);
600 TERM_DEBUG_OFF (events, EVENTS);
601 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
602 TERM_DEBUG_OFF (update, UPDATE_IN);
603 TERM_DEBUG_OFF (update, UPDATE_OUT);
604 TERM_DEBUG_OFF (fsm, FSM);
605 TERM_DEBUG_OFF (filter, FILTER);
606 vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
608 return CMD_SUCCESS;
611 ALIAS (no_debug_bgp_all,
612 undebug_bgp_all_cmd,
613 "undebug all bgp",
614 UNDEBUG_STR
615 "Enable all debugging\n"
616 BGP_STR)
618 DEFUN (show_debugging_bgp,
619 show_debugging_bgp_cmd,
620 "show debugging bgp",
621 SHOW_STR
622 DEBUG_STR
623 BGP_STR)
625 vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
627 if (BGP_DEBUG (normal, NORMAL))
628 vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE);
629 if (BGP_DEBUG (events, EVENTS))
630 vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE);
631 if (BGP_DEBUG (keepalive, KEEPALIVE))
632 vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE);
633 if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
634 vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE);
635 else if (BGP_DEBUG (update, UPDATE_IN))
636 vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
637 else if (BGP_DEBUG (update, UPDATE_OUT))
638 vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
639 if (BGP_DEBUG (fsm, FSM))
640 vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
641 if (BGP_DEBUG (filter, FILTER))
642 vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
643 vty_out (vty, "%s", VTY_NEWLINE);
644 return CMD_SUCCESS;
647 static int
648 bgp_config_write_debug (struct vty *vty)
650 int write = 0;
652 if (CONF_BGP_DEBUG (normal, NORMAL))
654 vty_out (vty, "debug bgp%s", VTY_NEWLINE);
655 write++;
658 if (CONF_BGP_DEBUG (events, EVENTS))
660 vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
661 write++;
664 if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
666 vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
667 write++;
670 if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
672 vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
673 write++;
675 else if (CONF_BGP_DEBUG (update, UPDATE_IN))
677 vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
678 write++;
680 else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
682 vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
683 write++;
686 if (CONF_BGP_DEBUG (fsm, FSM))
688 vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
689 write++;
692 if (CONF_BGP_DEBUG (filter, FILTER))
694 vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
695 write++;
698 return write;
701 struct cmd_node debug_node =
703 DEBUG_NODE,
708 void
709 bgp_debug_init (void)
711 install_node (&debug_node, bgp_config_write_debug);
713 install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
715 install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
716 install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
717 install_element (ENABLE_NODE, &debug_bgp_events_cmd);
718 install_element (CONFIG_NODE, &debug_bgp_events_cmd);
719 install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
720 install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
721 install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
722 install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
723 install_element (ENABLE_NODE, &debug_bgp_update_cmd);
724 install_element (CONFIG_NODE, &debug_bgp_update_cmd);
725 install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
726 install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
727 install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
728 install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
730 install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
731 install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
732 install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
733 install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
734 install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
735 install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
736 install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
737 install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
738 install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
739 install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
740 install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
741 install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
742 install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
743 install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
744 install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
745 install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
746 install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
747 install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
748 install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
749 install_element (ENABLE_NODE, &undebug_bgp_all_cmd);