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
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
23 #include <lib/version.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_as4
;
40 unsigned long conf_bgp_debug_fsm
;
41 unsigned long conf_bgp_debug_events
;
42 unsigned long conf_bgp_debug_packet
;
43 unsigned long conf_bgp_debug_filter
;
44 unsigned long conf_bgp_debug_keepalive
;
45 unsigned long conf_bgp_debug_update
;
46 unsigned long conf_bgp_debug_normal
;
47 unsigned long conf_bgp_debug_zebra
;
49 unsigned long term_bgp_debug_as4
;
50 unsigned long term_bgp_debug_fsm
;
51 unsigned long term_bgp_debug_events
;
52 unsigned long term_bgp_debug_packet
;
53 unsigned long term_bgp_debug_filter
;
54 unsigned long term_bgp_debug_keepalive
;
55 unsigned long term_bgp_debug_update
;
56 unsigned long term_bgp_debug_normal
;
57 unsigned long term_bgp_debug_zebra
;
59 /* messages for BGP-4 status */
60 struct message bgp_status_msg
[] =
64 { Connect
, "Connect" },
66 { OpenSent
, "OpenSent" },
67 { OpenConfirm
, "OpenConfirm" },
68 { Established
, "Established" },
69 { Clearing
, "Clearing" },
70 { Deleted
, "Deleted" },
72 int bgp_status_msg_max
= BGP_STATUS_MAX
;
74 /* BGP message type string. */
75 const char *bgp_type_str
[] =
86 /* message for BGP-4 Notify */
87 struct message bgp_notify_msg
[] =
90 { BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
91 { BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
92 { BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
93 { BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
94 { BGP_NOTIFY_FSM_ERR
, "Finite State Machine Error"},
95 { BGP_NOTIFY_CEASE
, "Cease"},
96 { BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
98 int bgp_notify_msg_max
= BGP_NOTIFY_MAX
;
100 struct message bgp_notify_head_msg
[] =
103 { BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
104 { BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
105 { BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"}
107 int bgp_notify_head_msg_max
= BGP_NOTIFY_HEADER_MAX
;
109 struct message bgp_notify_open_msg
[] =
112 { BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
113 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
114 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
115 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
116 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
117 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
118 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
120 int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
122 struct message bgp_notify_update_msg
[] =
125 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
126 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
127 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
128 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
129 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
130 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
131 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
132 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
133 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
134 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
135 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
137 int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
139 struct message bgp_notify_cease_msg
[] =
142 { BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
143 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
144 { BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
145 { BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
146 { BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
147 { BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
148 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
, "/Connection collision resolution"},
149 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
151 int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
153 struct message bgp_notify_capability_msg
[] =
156 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
157 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
158 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
160 int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
162 /* Origin strings. */
163 const char *bgp_origin_str
[] = {"i","e","?"};
164 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
166 /* Dump attribute. */
168 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
173 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
174 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
176 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
177 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
178 bgp_origin_str
[attr
->origin
]);
183 char addrbuf
[BUFSIZ
];
186 if (attr
->extra
->mp_nexthop_len
== 16
187 || attr
->extra
->mp_nexthop_len
== 32)
188 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
189 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
192 if (attr
->extra
->mp_nexthop_len
== 32)
193 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
194 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
197 #endif /* HAVE_IPV6 */
199 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
200 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %d",
203 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
204 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %d",
207 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
208 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
209 community_str (attr
->community
));
211 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
212 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
214 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
215 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %d %s",
216 attr
->extra
->aggregator_as
,
217 inet_ntoa (attr
->extra
->aggregator_addr
));
219 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
220 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
221 inet_ntoa (attr
->extra
->originator_id
));
223 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
227 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
228 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
229 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
230 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
233 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
234 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
235 aspath_print (attr
->aspath
));
237 if (strlen (buf
) > 1)
243 /* dump notify packet */
245 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
248 const char *subcode_str
;
252 switch (bgp_notify
->code
)
254 case BGP_NOTIFY_HEADER_ERR
:
255 subcode_str
= LOOKUP (bgp_notify_head_msg
, bgp_notify
->subcode
);
257 case BGP_NOTIFY_OPEN_ERR
:
258 subcode_str
= LOOKUP (bgp_notify_open_msg
, bgp_notify
->subcode
);
260 case BGP_NOTIFY_UPDATE_ERR
:
261 subcode_str
= LOOKUP (bgp_notify_update_msg
, bgp_notify
->subcode
);
263 case BGP_NOTIFY_HOLD_ERR
:
266 case BGP_NOTIFY_FSM_ERR
:
269 case BGP_NOTIFY_CEASE
:
270 subcode_str
= LOOKUP (bgp_notify_cease_msg
, bgp_notify
->subcode
);
272 case BGP_NOTIFY_CAPABILITY_ERR
:
273 subcode_str
= LOOKUP (bgp_notify_capability_msg
, bgp_notify
->subcode
);
277 if (bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
278 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
279 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
280 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
281 LOOKUP (bgp_notify_msg
, bgp_notify
->code
),
282 subcode_str
, bgp_notify
->length
,
283 bgp_notify
->data
? bgp_notify
->data
: "");
284 else if (BGP_DEBUG (normal
, NORMAL
))
285 plog_debug (peer
->log
, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
286 peer
? peer
->host
: "",
287 direct
, bgp_notify
->code
, bgp_notify
->subcode
,
288 LOOKUP (bgp_notify_msg
, bgp_notify
->code
),
289 subcode_str
, bgp_notify
->length
,
290 bgp_notify
->data
? bgp_notify
->data
: "");
293 /* Debug option setting interface. */
294 unsigned long bgp_debug_option
= 0;
297 debug (unsigned int option
)
299 return bgp_debug_option
& option
;
302 DEFUN (debug_bgp_as4
,
309 if (vty
->node
== CONFIG_NODE
)
313 TERM_DEBUG_ON (as4
, AS4
);
314 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
319 DEFUN (no_debug_bgp_as4
,
320 no_debug_bgp_as4_cmd
,
327 if (vty
->node
== CONFIG_NODE
)
328 DEBUG_OFF (as4
, AS4
);
331 TERM_DEBUG_OFF (as4
, AS4
);
332 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
337 ALIAS (no_debug_bgp_as4
,
345 DEFUN (debug_bgp_as4_segment
,
346 debug_bgp_as4_segment_cmd
,
347 "debug bgp as4 segment",
350 "BGP AS4 aspath segment handling\n")
352 if (vty
->node
== CONFIG_NODE
)
353 DEBUG_ON (as4
, AS4_SEGMENT
);
356 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
357 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
362 DEFUN (no_debug_bgp_as4_segment
,
363 no_debug_bgp_as4_segment_cmd
,
364 "no debug bgp as4 segment",
368 "BGP AS4 aspath segment handling\n")
370 if (vty
->node
== CONFIG_NODE
)
371 DEBUG_OFF (as4
, AS4_SEGMENT
);
374 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
375 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
380 ALIAS (no_debug_bgp_as4_segment
,
381 undebug_bgp_as4_segment_cmd
,
382 "undebug bgp as4 segment",
386 "BGP AS4 aspath segment handling\n")
388 DEFUN (debug_bgp_fsm
,
393 "BGP Finite State Machine\n")
395 if (vty
->node
== CONFIG_NODE
)
399 TERM_DEBUG_ON (fsm
, FSM
);
400 vty_out (vty
, "BGP fsm debugging is on%s", VTY_NEWLINE
);
405 DEFUN (no_debug_bgp_fsm
,
406 no_debug_bgp_fsm_cmd
,
411 "Finite State Machine\n")
413 if (vty
->node
== CONFIG_NODE
)
414 DEBUG_OFF (fsm
, FSM
);
417 TERM_DEBUG_OFF (fsm
, FSM
);
418 vty_out (vty
, "BGP fsm debugging is off%s", VTY_NEWLINE
);
423 ALIAS (no_debug_bgp_fsm
,
429 "Finite State Machine\n")
431 DEFUN (debug_bgp_events
,
432 debug_bgp_events_cmd
,
438 if (vty
->node
== CONFIG_NODE
)
439 DEBUG_ON (events
, EVENTS
);
442 TERM_DEBUG_ON (events
, EVENTS
);
443 vty_out (vty
, "BGP events debugging is on%s", VTY_NEWLINE
);
448 DEFUN (no_debug_bgp_events
,
449 no_debug_bgp_events_cmd
,
450 "no debug bgp events",
456 if (vty
->node
== CONFIG_NODE
)
457 DEBUG_OFF (events
, EVENTS
);
460 TERM_DEBUG_OFF (events
, EVENTS
);
461 vty_out (vty
, "BGP events debugging is off%s", VTY_NEWLINE
);
466 ALIAS (no_debug_bgp_events
,
467 undebug_bgp_events_cmd
,
468 "undebug bgp events",
473 DEFUN (debug_bgp_filter
,
474 debug_bgp_filter_cmd
,
480 if (vty
->node
== CONFIG_NODE
)
481 DEBUG_ON (filter
, FILTER
);
484 TERM_DEBUG_ON (filter
, FILTER
);
485 vty_out (vty
, "BGP filters debugging is on%s", VTY_NEWLINE
);
490 DEFUN (no_debug_bgp_filter
,
491 no_debug_bgp_filter_cmd
,
492 "no debug bgp filters",
498 if (vty
->node
== CONFIG_NODE
)
499 DEBUG_OFF (filter
, FILTER
);
502 TERM_DEBUG_OFF (filter
, FILTER
);
503 vty_out (vty
, "BGP filters debugging is off%s", VTY_NEWLINE
);
508 ALIAS (no_debug_bgp_filter
,
509 undebug_bgp_filter_cmd
,
510 "undebug bgp filters",
515 DEFUN (debug_bgp_keepalive
,
516 debug_bgp_keepalive_cmd
,
517 "debug bgp keepalives",
522 if (vty
->node
== CONFIG_NODE
)
523 DEBUG_ON (keepalive
, KEEPALIVE
);
526 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
527 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
532 DEFUN (no_debug_bgp_keepalive
,
533 no_debug_bgp_keepalive_cmd
,
534 "no debug bgp keepalives",
540 if (vty
->node
== CONFIG_NODE
)
541 DEBUG_OFF (keepalive
, KEEPALIVE
);
544 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
545 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
550 ALIAS (no_debug_bgp_keepalive
,
551 undebug_bgp_keepalive_cmd
,
552 "undebug bgp keepalives",
557 DEFUN (debug_bgp_update
,
558 debug_bgp_update_cmd
,
564 if (vty
->node
== CONFIG_NODE
)
566 DEBUG_ON (update
, UPDATE_IN
);
567 DEBUG_ON (update
, UPDATE_OUT
);
571 TERM_DEBUG_ON (update
, UPDATE_IN
);
572 TERM_DEBUG_ON (update
, UPDATE_OUT
);
573 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
578 DEFUN (debug_bgp_update_direct
,
579 debug_bgp_update_direct_cmd
,
580 "debug bgp updates (in|out)",
585 "Outbound updates\n")
587 if (vty
->node
== CONFIG_NODE
)
589 if (strncmp ("i", argv
[0], 1) == 0)
591 DEBUG_OFF (update
, UPDATE_OUT
);
592 DEBUG_ON (update
, UPDATE_IN
);
596 DEBUG_OFF (update
, UPDATE_IN
);
597 DEBUG_ON (update
, UPDATE_OUT
);
602 if (strncmp ("i", argv
[0], 1) == 0)
604 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
605 TERM_DEBUG_ON (update
, UPDATE_IN
);
606 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
610 TERM_DEBUG_OFF (update
, UPDATE_IN
);
611 TERM_DEBUG_ON (update
, UPDATE_OUT
);
612 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
618 DEFUN (no_debug_bgp_update
,
619 no_debug_bgp_update_cmd
,
620 "no debug bgp updates",
626 if (vty
->node
== CONFIG_NODE
)
628 DEBUG_OFF (update
, UPDATE_IN
);
629 DEBUG_OFF (update
, UPDATE_OUT
);
633 TERM_DEBUG_OFF (update
, UPDATE_IN
);
634 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
635 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
640 ALIAS (no_debug_bgp_update
,
641 undebug_bgp_update_cmd
,
642 "undebug bgp updates",
647 DEFUN (debug_bgp_normal
,
648 debug_bgp_normal_cmd
,
653 if (vty
->node
== CONFIG_NODE
)
654 DEBUG_ON (normal
, NORMAL
);
657 TERM_DEBUG_ON (normal
, NORMAL
);
658 vty_out (vty
, "BGP debugging is on%s", VTY_NEWLINE
);
663 DEFUN (no_debug_bgp_normal
,
664 no_debug_bgp_normal_cmd
,
670 if (vty
->node
== CONFIG_NODE
)
671 DEBUG_OFF (normal
, NORMAL
);
674 TERM_DEBUG_OFF (normal
, NORMAL
);
675 vty_out (vty
, "BGP debugging is off%s", VTY_NEWLINE
);
680 ALIAS (no_debug_bgp_normal
,
681 undebug_bgp_normal_cmd
,
686 DEFUN (debug_bgp_zebra
,
691 "BGP Zebra messages\n")
693 if (vty
->node
== CONFIG_NODE
)
694 DEBUG_ON (zebra
, ZEBRA
);
697 TERM_DEBUG_ON (zebra
, ZEBRA
);
698 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
703 DEFUN (no_debug_bgp_zebra
,
704 no_debug_bgp_zebra_cmd
,
705 "no debug bgp zebra",
709 "BGP Zebra messages\n")
711 if (vty
->node
== CONFIG_NODE
)
712 DEBUG_OFF (zebra
, ZEBRA
);
715 TERM_DEBUG_OFF (zebra
, ZEBRA
);
716 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
721 ALIAS (no_debug_bgp_zebra
,
722 undebug_bgp_zebra_cmd
,
727 "BGP Zebra messages\n")
729 DEFUN (no_debug_bgp_all
,
730 no_debug_bgp_all_cmd
,
734 "Enable all debugging\n"
737 TERM_DEBUG_OFF (normal
, NORMAL
);
738 TERM_DEBUG_OFF (events
, EVENTS
);
739 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
740 TERM_DEBUG_OFF (update
, UPDATE_IN
);
741 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
742 TERM_DEBUG_OFF (as4
, AS4
);
743 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
744 TERM_DEBUG_OFF (fsm
, FSM
);
745 TERM_DEBUG_OFF (filter
, FILTER
);
746 TERM_DEBUG_OFF (zebra
, ZEBRA
);
747 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
752 ALIAS (no_debug_bgp_all
,
756 "Enable all debugging\n"
759 DEFUN (show_debugging_bgp
,
760 show_debugging_bgp_cmd
,
761 "show debugging bgp",
766 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
768 if (BGP_DEBUG (normal
, NORMAL
))
769 vty_out (vty
, " BGP debugging is on%s", VTY_NEWLINE
);
770 if (BGP_DEBUG (events
, EVENTS
))
771 vty_out (vty
, " BGP events debugging is on%s", VTY_NEWLINE
);
772 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
773 vty_out (vty
, " BGP keepalives debugging is on%s", VTY_NEWLINE
);
774 if (BGP_DEBUG (update
, UPDATE_IN
) && BGP_DEBUG (update
, UPDATE_OUT
))
775 vty_out (vty
, " BGP updates debugging is on%s", VTY_NEWLINE
);
776 else if (BGP_DEBUG (update
, UPDATE_IN
))
777 vty_out (vty
, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
778 else if (BGP_DEBUG (update
, UPDATE_OUT
))
779 vty_out (vty
, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
780 if (BGP_DEBUG (fsm
, FSM
))
781 vty_out (vty
, " BGP fsm debugging is on%s", VTY_NEWLINE
);
782 if (BGP_DEBUG (filter
, FILTER
))
783 vty_out (vty
, " BGP filter debugging is on%s", VTY_NEWLINE
);
784 if (BGP_DEBUG (zebra
, ZEBRA
))
785 vty_out (vty
, " BGP zebra debugging is on%s", VTY_NEWLINE
);
786 if (BGP_DEBUG (as4
, AS4
))
787 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
788 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
789 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
790 vty_out (vty
, "%s", VTY_NEWLINE
);
795 bgp_config_write_debug (struct vty
*vty
)
799 if (CONF_BGP_DEBUG (normal
, NORMAL
))
801 vty_out (vty
, "debug bgp%s", VTY_NEWLINE
);
805 if (CONF_BGP_DEBUG (as4
, AS4
))
807 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
811 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
813 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
817 if (CONF_BGP_DEBUG (events
, EVENTS
))
819 vty_out (vty
, "debug bgp events%s", VTY_NEWLINE
);
823 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
825 vty_out (vty
, "debug bgp keepalives%s", VTY_NEWLINE
);
829 if (CONF_BGP_DEBUG (update
, UPDATE_IN
) && CONF_BGP_DEBUG (update
, UPDATE_OUT
))
831 vty_out (vty
, "debug bgp updates%s", VTY_NEWLINE
);
834 else if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
836 vty_out (vty
, "debug bgp updates in%s", VTY_NEWLINE
);
839 else if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
841 vty_out (vty
, "debug bgp updates out%s", VTY_NEWLINE
);
845 if (CONF_BGP_DEBUG (fsm
, FSM
))
847 vty_out (vty
, "debug bgp fsm%s", VTY_NEWLINE
);
851 if (CONF_BGP_DEBUG (filter
, FILTER
))
853 vty_out (vty
, "debug bgp filters%s", VTY_NEWLINE
);
857 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
859 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
866 struct cmd_node debug_node
=
874 bgp_debug_init (void)
876 install_node (&debug_node
, bgp_config_write_debug
);
878 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
880 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
881 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
882 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
883 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
885 install_element (ENABLE_NODE
, &debug_bgp_fsm_cmd
);
886 install_element (CONFIG_NODE
, &debug_bgp_fsm_cmd
);
887 install_element (ENABLE_NODE
, &debug_bgp_events_cmd
);
888 install_element (CONFIG_NODE
, &debug_bgp_events_cmd
);
889 install_element (ENABLE_NODE
, &debug_bgp_filter_cmd
);
890 install_element (CONFIG_NODE
, &debug_bgp_filter_cmd
);
891 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
892 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
893 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
894 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
895 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
896 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
897 install_element (ENABLE_NODE
, &debug_bgp_normal_cmd
);
898 install_element (CONFIG_NODE
, &debug_bgp_normal_cmd
);
899 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
900 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
902 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
903 install_element (ENABLE_NODE
, &undebug_bgp_as4_cmd
);
904 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
905 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
906 install_element (ENABLE_NODE
, &undebug_bgp_as4_segment_cmd
);
907 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
909 install_element (ENABLE_NODE
, &no_debug_bgp_fsm_cmd
);
910 install_element (ENABLE_NODE
, &undebug_bgp_fsm_cmd
);
911 install_element (CONFIG_NODE
, &no_debug_bgp_fsm_cmd
);
912 install_element (ENABLE_NODE
, &no_debug_bgp_events_cmd
);
913 install_element (ENABLE_NODE
, &undebug_bgp_events_cmd
);
914 install_element (CONFIG_NODE
, &no_debug_bgp_events_cmd
);
915 install_element (ENABLE_NODE
, &no_debug_bgp_filter_cmd
);
916 install_element (ENABLE_NODE
, &undebug_bgp_filter_cmd
);
917 install_element (CONFIG_NODE
, &no_debug_bgp_filter_cmd
);
918 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
919 install_element (ENABLE_NODE
, &undebug_bgp_keepalive_cmd
);
920 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
921 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
922 install_element (ENABLE_NODE
, &undebug_bgp_update_cmd
);
923 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
924 install_element (ENABLE_NODE
, &no_debug_bgp_normal_cmd
);
925 install_element (ENABLE_NODE
, &undebug_bgp_normal_cmd
);
926 install_element (CONFIG_NODE
, &no_debug_bgp_normal_cmd
);
927 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
928 install_element (ENABLE_NODE
, &undebug_bgp_zebra_cmd
);
929 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
930 install_element (ENABLE_NODE
, &no_debug_bgp_all_cmd
);
931 install_element (ENABLE_NODE
, &undebug_bgp_all_cmd
);