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 const struct message bgp_status_msg
[] =
63 { Connect
, "Connect" },
65 { OpenSent
, "OpenSent" },
66 { OpenConfirm
, "OpenConfirm" },
67 { Established
, "Established" },
68 { Clearing
, "Clearing" },
69 { Deleted
, "Deleted" },
71 const int bgp_status_msg_max
= BGP_STATUS_MAX
;
73 /* BGP message type string. */
74 const char *bgp_type_str
[] =
85 /* message for BGP-4 Notify */
86 static const struct message bgp_notify_msg
[] =
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"},
96 static const int bgp_notify_msg_max
= BGP_NOTIFY_MAX
;
98 static const struct message bgp_notify_head_msg
[] =
100 { BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
101 { BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
102 { BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"}
104 static const int bgp_notify_head_msg_max
= BGP_NOTIFY_HEADER_MAX
;
106 static const struct message bgp_notify_open_msg
[] =
108 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
109 { BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
110 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
111 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
112 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
113 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
114 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
115 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
117 static const int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
119 static const struct message bgp_notify_update_msg
[] =
121 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
122 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
123 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
124 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
125 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
126 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
127 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
128 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
129 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
130 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
131 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
132 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
134 static const int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
136 static const struct message bgp_notify_cease_msg
[] =
138 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
139 { BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
140 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
141 { BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
142 { BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
143 { BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
144 { BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
145 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
, "/Connection collision resolution"},
146 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
148 static const int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
150 static const struct message bgp_notify_capability_msg
[] =
152 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
153 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
154 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
155 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
157 static const int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
159 /* Origin strings. */
160 const char *bgp_origin_str
[] = {"i","e","?"};
161 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
163 /* Dump attribute. */
165 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
170 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
171 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
173 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
174 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
175 bgp_origin_str
[attr
->origin
]);
180 char addrbuf
[BUFSIZ
];
183 if (attr
->extra
->mp_nexthop_len
== 16
184 || attr
->extra
->mp_nexthop_len
== 32)
185 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
186 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
189 if (attr
->extra
->mp_nexthop_len
== 32)
190 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
191 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
194 #endif /* HAVE_IPV6 */
196 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
197 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %u",
200 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
201 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %u",
204 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
205 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
206 community_str (attr
->community
));
208 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
209 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
211 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
212 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
213 attr
->extra
->aggregator_as
,
214 inet_ntoa (attr
->extra
->aggregator_addr
));
216 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
217 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
218 inet_ntoa (attr
->extra
->originator_id
));
220 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
224 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
225 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
226 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
227 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
230 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
231 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
232 aspath_print (attr
->aspath
));
234 if (strlen (buf
) > 1)
240 /* dump notify packet */
242 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
245 const char *subcode_str
;
249 switch (bgp_notify
->code
)
251 case BGP_NOTIFY_HEADER_ERR
:
252 subcode_str
= LOOKUP (bgp_notify_head_msg
, bgp_notify
->subcode
);
254 case BGP_NOTIFY_OPEN_ERR
:
255 subcode_str
= LOOKUP (bgp_notify_open_msg
, bgp_notify
->subcode
);
257 case BGP_NOTIFY_UPDATE_ERR
:
258 subcode_str
= LOOKUP (bgp_notify_update_msg
, bgp_notify
->subcode
);
260 case BGP_NOTIFY_HOLD_ERR
:
263 case BGP_NOTIFY_FSM_ERR
:
266 case BGP_NOTIFY_CEASE
:
267 subcode_str
= LOOKUP (bgp_notify_cease_msg
, bgp_notify
->subcode
);
269 case BGP_NOTIFY_CAPABILITY_ERR
:
270 subcode_str
= LOOKUP (bgp_notify_capability_msg
, bgp_notify
->subcode
);
274 if (bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
275 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
276 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
277 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
278 LOOKUP (bgp_notify_msg
, bgp_notify
->code
),
279 subcode_str
, bgp_notify
->length
,
280 bgp_notify
->data
? bgp_notify
->data
: "");
281 else if (BGP_DEBUG (normal
, NORMAL
))
282 plog_debug (peer
->log
, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
283 peer
? peer
->host
: "",
284 direct
, bgp_notify
->code
, bgp_notify
->subcode
,
285 LOOKUP (bgp_notify_msg
, bgp_notify
->code
),
286 subcode_str
, bgp_notify
->length
,
287 bgp_notify
->data
? bgp_notify
->data
: "");
290 /* Debug option setting interface. */
291 unsigned long bgp_debug_option
= 0;
294 debug (unsigned int option
)
296 return bgp_debug_option
& option
;
299 DEFUN (debug_bgp_as4
,
306 if (vty
->node
== CONFIG_NODE
)
310 TERM_DEBUG_ON (as4
, AS4
);
311 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
316 DEFUN (no_debug_bgp_as4
,
317 no_debug_bgp_as4_cmd
,
324 if (vty
->node
== CONFIG_NODE
)
325 DEBUG_OFF (as4
, AS4
);
328 TERM_DEBUG_OFF (as4
, AS4
);
329 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
334 ALIAS (no_debug_bgp_as4
,
341 DEFUN (debug_bgp_as4_segment
,
342 debug_bgp_as4_segment_cmd
,
343 "debug bgp as4 segment",
347 "BGP AS4 aspath segment handling\n")
349 if (vty
->node
== CONFIG_NODE
)
350 DEBUG_ON (as4
, AS4_SEGMENT
);
353 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
354 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
359 DEFUN (no_debug_bgp_as4_segment
,
360 no_debug_bgp_as4_segment_cmd
,
361 "no debug bgp as4 segment",
366 "BGP AS4 aspath segment handling\n")
368 if (vty
->node
== CONFIG_NODE
)
369 DEBUG_OFF (as4
, AS4_SEGMENT
);
372 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
373 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
378 ALIAS (no_debug_bgp_as4_segment
,
379 undebug_bgp_as4_segment_cmd
,
380 "undebug bgp as4 segment",
384 "BGP AS4 aspath segment handling\n")
386 DEFUN (debug_bgp_fsm
,
391 "BGP Finite State Machine\n")
393 if (vty
->node
== CONFIG_NODE
)
397 TERM_DEBUG_ON (fsm
, FSM
);
398 vty_out (vty
, "BGP fsm debugging is on%s", VTY_NEWLINE
);
403 DEFUN (no_debug_bgp_fsm
,
404 no_debug_bgp_fsm_cmd
,
409 "Finite State Machine\n")
411 if (vty
->node
== CONFIG_NODE
)
412 DEBUG_OFF (fsm
, FSM
);
415 TERM_DEBUG_OFF (fsm
, FSM
);
416 vty_out (vty
, "BGP fsm debugging is off%s", VTY_NEWLINE
);
421 ALIAS (no_debug_bgp_fsm
,
426 "Finite State Machine\n")
428 DEFUN (debug_bgp_events
,
429 debug_bgp_events_cmd
,
435 if (vty
->node
== CONFIG_NODE
)
436 DEBUG_ON (events
, EVENTS
);
439 TERM_DEBUG_ON (events
, EVENTS
);
440 vty_out (vty
, "BGP events debugging is on%s", VTY_NEWLINE
);
445 DEFUN (no_debug_bgp_events
,
446 no_debug_bgp_events_cmd
,
447 "no debug bgp events",
453 if (vty
->node
== CONFIG_NODE
)
454 DEBUG_OFF (events
, EVENTS
);
457 TERM_DEBUG_OFF (events
, EVENTS
);
458 vty_out (vty
, "BGP events debugging is off%s", VTY_NEWLINE
);
463 ALIAS (no_debug_bgp_events
,
464 undebug_bgp_events_cmd
,
465 "undebug bgp events",
470 DEFUN (debug_bgp_filter
,
471 debug_bgp_filter_cmd
,
477 if (vty
->node
== CONFIG_NODE
)
478 DEBUG_ON (filter
, FILTER
);
481 TERM_DEBUG_ON (filter
, FILTER
);
482 vty_out (vty
, "BGP filters debugging is on%s", VTY_NEWLINE
);
487 DEFUN (no_debug_bgp_filter
,
488 no_debug_bgp_filter_cmd
,
489 "no debug bgp filters",
495 if (vty
->node
== CONFIG_NODE
)
496 DEBUG_OFF (filter
, FILTER
);
499 TERM_DEBUG_OFF (filter
, FILTER
);
500 vty_out (vty
, "BGP filters debugging is off%s", VTY_NEWLINE
);
505 ALIAS (no_debug_bgp_filter
,
506 undebug_bgp_filter_cmd
,
507 "undebug bgp filters",
512 DEFUN (debug_bgp_keepalive
,
513 debug_bgp_keepalive_cmd
,
514 "debug bgp keepalives",
519 if (vty
->node
== CONFIG_NODE
)
520 DEBUG_ON (keepalive
, KEEPALIVE
);
523 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
524 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
529 DEFUN (no_debug_bgp_keepalive
,
530 no_debug_bgp_keepalive_cmd
,
531 "no debug bgp keepalives",
537 if (vty
->node
== CONFIG_NODE
)
538 DEBUG_OFF (keepalive
, KEEPALIVE
);
541 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
542 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
547 ALIAS (no_debug_bgp_keepalive
,
548 undebug_bgp_keepalive_cmd
,
549 "undebug bgp keepalives",
554 DEFUN (debug_bgp_update
,
555 debug_bgp_update_cmd
,
561 if (vty
->node
== CONFIG_NODE
)
563 DEBUG_ON (update
, UPDATE_IN
);
564 DEBUG_ON (update
, UPDATE_OUT
);
568 TERM_DEBUG_ON (update
, UPDATE_IN
);
569 TERM_DEBUG_ON (update
, UPDATE_OUT
);
570 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
575 DEFUN (debug_bgp_update_direct
,
576 debug_bgp_update_direct_cmd
,
577 "debug bgp updates (in|out)",
582 "Outbound updates\n")
584 if (vty
->node
== CONFIG_NODE
)
586 if (strncmp ("i", argv
[0], 1) == 0)
588 DEBUG_OFF (update
, UPDATE_OUT
);
589 DEBUG_ON (update
, UPDATE_IN
);
593 DEBUG_OFF (update
, UPDATE_IN
);
594 DEBUG_ON (update
, UPDATE_OUT
);
599 if (strncmp ("i", argv
[0], 1) == 0)
601 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
602 TERM_DEBUG_ON (update
, UPDATE_IN
);
603 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
607 TERM_DEBUG_OFF (update
, UPDATE_IN
);
608 TERM_DEBUG_ON (update
, UPDATE_OUT
);
609 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
615 DEFUN (no_debug_bgp_update
,
616 no_debug_bgp_update_cmd
,
617 "no debug bgp updates",
623 if (vty
->node
== CONFIG_NODE
)
625 DEBUG_OFF (update
, UPDATE_IN
);
626 DEBUG_OFF (update
, UPDATE_OUT
);
630 TERM_DEBUG_OFF (update
, UPDATE_IN
);
631 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
632 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
637 ALIAS (no_debug_bgp_update
,
638 undebug_bgp_update_cmd
,
639 "undebug bgp updates",
644 DEFUN (debug_bgp_normal
,
645 debug_bgp_normal_cmd
,
650 if (vty
->node
== CONFIG_NODE
)
651 DEBUG_ON (normal
, NORMAL
);
654 TERM_DEBUG_ON (normal
, NORMAL
);
655 vty_out (vty
, "BGP debugging is on%s", VTY_NEWLINE
);
660 DEFUN (no_debug_bgp_normal
,
661 no_debug_bgp_normal_cmd
,
667 if (vty
->node
== CONFIG_NODE
)
668 DEBUG_OFF (normal
, NORMAL
);
671 TERM_DEBUG_OFF (normal
, NORMAL
);
672 vty_out (vty
, "BGP debugging is off%s", VTY_NEWLINE
);
677 ALIAS (no_debug_bgp_normal
,
678 undebug_bgp_normal_cmd
,
683 DEFUN (debug_bgp_zebra
,
688 "BGP Zebra messages\n")
690 if (vty
->node
== CONFIG_NODE
)
691 DEBUG_ON (zebra
, ZEBRA
);
694 TERM_DEBUG_ON (zebra
, ZEBRA
);
695 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
700 DEFUN (no_debug_bgp_zebra
,
701 no_debug_bgp_zebra_cmd
,
702 "no debug bgp zebra",
706 "BGP Zebra messages\n")
708 if (vty
->node
== CONFIG_NODE
)
709 DEBUG_OFF (zebra
, ZEBRA
);
712 TERM_DEBUG_OFF (zebra
, ZEBRA
);
713 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
718 ALIAS (no_debug_bgp_zebra
,
719 undebug_bgp_zebra_cmd
,
723 "BGP Zebra messages\n")
725 DEFUN (no_debug_bgp_all
,
726 no_debug_bgp_all_cmd
,
730 "Enable all debugging\n"
733 TERM_DEBUG_OFF (normal
, NORMAL
);
734 TERM_DEBUG_OFF (events
, EVENTS
);
735 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
736 TERM_DEBUG_OFF (update
, UPDATE_IN
);
737 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
738 TERM_DEBUG_OFF (as4
, AS4
);
739 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
740 TERM_DEBUG_OFF (fsm
, FSM
);
741 TERM_DEBUG_OFF (filter
, FILTER
);
742 TERM_DEBUG_OFF (zebra
, ZEBRA
);
743 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
748 ALIAS (no_debug_bgp_all
,
752 "Enable all debugging\n"
755 DEFUN (show_debugging_bgp
,
756 show_debugging_bgp_cmd
,
757 "show debugging bgp",
762 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
764 if (BGP_DEBUG (normal
, NORMAL
))
765 vty_out (vty
, " BGP debugging is on%s", VTY_NEWLINE
);
766 if (BGP_DEBUG (events
, EVENTS
))
767 vty_out (vty
, " BGP events debugging is on%s", VTY_NEWLINE
);
768 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
769 vty_out (vty
, " BGP keepalives debugging is on%s", VTY_NEWLINE
);
770 if (BGP_DEBUG (update
, UPDATE_IN
) && BGP_DEBUG (update
, UPDATE_OUT
))
771 vty_out (vty
, " BGP updates debugging is on%s", VTY_NEWLINE
);
772 else if (BGP_DEBUG (update
, UPDATE_IN
))
773 vty_out (vty
, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
774 else if (BGP_DEBUG (update
, UPDATE_OUT
))
775 vty_out (vty
, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
776 if (BGP_DEBUG (fsm
, FSM
))
777 vty_out (vty
, " BGP fsm debugging is on%s", VTY_NEWLINE
);
778 if (BGP_DEBUG (filter
, FILTER
))
779 vty_out (vty
, " BGP filter debugging is on%s", VTY_NEWLINE
);
780 if (BGP_DEBUG (zebra
, ZEBRA
))
781 vty_out (vty
, " BGP zebra debugging is on%s", VTY_NEWLINE
);
782 if (BGP_DEBUG (as4
, AS4
))
783 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
784 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
785 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
786 vty_out (vty
, "%s", VTY_NEWLINE
);
791 bgp_config_write_debug (struct vty
*vty
)
795 if (CONF_BGP_DEBUG (normal
, NORMAL
))
797 vty_out (vty
, "debug bgp%s", VTY_NEWLINE
);
801 if (CONF_BGP_DEBUG (as4
, AS4
))
803 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
807 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
809 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
813 if (CONF_BGP_DEBUG (events
, EVENTS
))
815 vty_out (vty
, "debug bgp events%s", VTY_NEWLINE
);
819 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
821 vty_out (vty
, "debug bgp keepalives%s", VTY_NEWLINE
);
825 if (CONF_BGP_DEBUG (update
, UPDATE_IN
) && CONF_BGP_DEBUG (update
, UPDATE_OUT
))
827 vty_out (vty
, "debug bgp updates%s", VTY_NEWLINE
);
830 else if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
832 vty_out (vty
, "debug bgp updates in%s", VTY_NEWLINE
);
835 else if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
837 vty_out (vty
, "debug bgp updates out%s", VTY_NEWLINE
);
841 if (CONF_BGP_DEBUG (fsm
, FSM
))
843 vty_out (vty
, "debug bgp fsm%s", VTY_NEWLINE
);
847 if (CONF_BGP_DEBUG (filter
, FILTER
))
849 vty_out (vty
, "debug bgp filters%s", VTY_NEWLINE
);
853 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
855 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
862 static struct cmd_node debug_node
=
870 bgp_debug_init (void)
872 install_node (&debug_node
, bgp_config_write_debug
);
874 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
876 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
877 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
878 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
879 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
881 install_element (ENABLE_NODE
, &debug_bgp_fsm_cmd
);
882 install_element (CONFIG_NODE
, &debug_bgp_fsm_cmd
);
883 install_element (ENABLE_NODE
, &debug_bgp_events_cmd
);
884 install_element (CONFIG_NODE
, &debug_bgp_events_cmd
);
885 install_element (ENABLE_NODE
, &debug_bgp_filter_cmd
);
886 install_element (CONFIG_NODE
, &debug_bgp_filter_cmd
);
887 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
888 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
889 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
890 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
891 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
892 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
893 install_element (ENABLE_NODE
, &debug_bgp_normal_cmd
);
894 install_element (CONFIG_NODE
, &debug_bgp_normal_cmd
);
895 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
896 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
898 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
899 install_element (ENABLE_NODE
, &undebug_bgp_as4_cmd
);
900 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
901 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
902 install_element (ENABLE_NODE
, &undebug_bgp_as4_segment_cmd
);
903 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
905 install_element (ENABLE_NODE
, &no_debug_bgp_fsm_cmd
);
906 install_element (ENABLE_NODE
, &undebug_bgp_fsm_cmd
);
907 install_element (CONFIG_NODE
, &no_debug_bgp_fsm_cmd
);
908 install_element (ENABLE_NODE
, &no_debug_bgp_events_cmd
);
909 install_element (ENABLE_NODE
, &undebug_bgp_events_cmd
);
910 install_element (CONFIG_NODE
, &no_debug_bgp_events_cmd
);
911 install_element (ENABLE_NODE
, &no_debug_bgp_filter_cmd
);
912 install_element (ENABLE_NODE
, &undebug_bgp_filter_cmd
);
913 install_element (CONFIG_NODE
, &no_debug_bgp_filter_cmd
);
914 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
915 install_element (ENABLE_NODE
, &undebug_bgp_keepalive_cmd
);
916 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
917 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
918 install_element (ENABLE_NODE
, &undebug_bgp_update_cmd
);
919 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
920 install_element (ENABLE_NODE
, &no_debug_bgp_normal_cmd
);
921 install_element (ENABLE_NODE
, &undebug_bgp_normal_cmd
);
922 install_element (CONFIG_NODE
, &no_debug_bgp_normal_cmd
);
923 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
924 install_element (ENABLE_NODE
, &undebug_bgp_zebra_cmd
);
925 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
926 install_element (ENABLE_NODE
, &no_debug_bgp_all_cmd
);
927 install_element (ENABLE_NODE
, &undebug_bgp_all_cmd
);