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_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
109 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
110 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
111 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
112 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
113 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
114 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
116 static const int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
118 static const struct message bgp_notify_update_msg
[] =
120 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
121 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
122 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
123 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
124 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
125 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
126 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
127 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
128 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
129 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
130 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
132 static const int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
134 static const struct message bgp_notify_cease_msg
[] =
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 static const int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
147 static const struct message bgp_notify_capability_msg
[] =
149 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
150 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
151 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
153 static const int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
155 /* Origin strings. */
156 const char *bgp_origin_str
[] = {"i","e","?"};
157 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
159 /* Dump attribute. */
161 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
166 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
167 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
169 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
170 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
171 bgp_origin_str
[attr
->origin
]);
176 char addrbuf
[BUFSIZ
];
179 if (attr
->extra
->mp_nexthop_len
== 16
180 || attr
->extra
->mp_nexthop_len
== 32)
181 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
182 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
185 if (attr
->extra
->mp_nexthop_len
== 32)
186 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
187 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
190 #endif /* HAVE_IPV6 */
192 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
193 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %d",
196 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
197 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %d",
200 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
201 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
202 community_str (attr
->community
));
204 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
205 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
207 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
208 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
209 attr
->extra
->aggregator_as
,
210 inet_ntoa (attr
->extra
->aggregator_addr
));
212 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
213 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
214 inet_ntoa (attr
->extra
->originator_id
));
216 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
220 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
221 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
222 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
223 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
226 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
227 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
228 aspath_print (attr
->aspath
));
230 if (strlen (buf
) > 1)
236 /* dump notify packet */
238 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
241 const char *subcode_str
;
245 switch (bgp_notify
->code
)
247 case BGP_NOTIFY_HEADER_ERR
:
248 subcode_str
= LOOKUP (bgp_notify_head_msg
, bgp_notify
->subcode
);
250 case BGP_NOTIFY_OPEN_ERR
:
251 subcode_str
= LOOKUP (bgp_notify_open_msg
, bgp_notify
->subcode
);
253 case BGP_NOTIFY_UPDATE_ERR
:
254 subcode_str
= LOOKUP (bgp_notify_update_msg
, bgp_notify
->subcode
);
256 case BGP_NOTIFY_HOLD_ERR
:
259 case BGP_NOTIFY_FSM_ERR
:
262 case BGP_NOTIFY_CEASE
:
263 subcode_str
= LOOKUP (bgp_notify_cease_msg
, bgp_notify
->subcode
);
265 case BGP_NOTIFY_CAPABILITY_ERR
:
266 subcode_str
= LOOKUP (bgp_notify_capability_msg
, bgp_notify
->subcode
);
270 if (bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
271 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
272 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
273 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
274 LOOKUP (bgp_notify_msg
, bgp_notify
->code
),
275 subcode_str
, bgp_notify
->length
,
276 bgp_notify
->data
? bgp_notify
->data
: "");
277 else if (BGP_DEBUG (normal
, NORMAL
))
278 plog_debug (peer
->log
, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
279 peer
? peer
->host
: "",
280 direct
, 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
: "");
286 /* Debug option setting interface. */
287 unsigned long bgp_debug_option
= 0;
290 debug (unsigned int option
)
292 return bgp_debug_option
& option
;
295 DEFUN (debug_bgp_as4
,
302 if (vty
->node
== CONFIG_NODE
)
306 TERM_DEBUG_ON (as4
, AS4
);
307 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
312 DEFUN (no_debug_bgp_as4
,
313 no_debug_bgp_as4_cmd
,
320 if (vty
->node
== CONFIG_NODE
)
321 DEBUG_OFF (as4
, AS4
);
324 TERM_DEBUG_OFF (as4
, AS4
);
325 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
330 ALIAS (no_debug_bgp_as4
,
338 DEFUN (debug_bgp_as4_segment
,
339 debug_bgp_as4_segment_cmd
,
340 "debug bgp as4 segment",
343 "BGP AS4 aspath segment handling\n")
345 if (vty
->node
== CONFIG_NODE
)
346 DEBUG_ON (as4
, AS4_SEGMENT
);
349 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
350 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
355 DEFUN (no_debug_bgp_as4_segment
,
356 no_debug_bgp_as4_segment_cmd
,
357 "no debug bgp as4 segment",
361 "BGP AS4 aspath segment handling\n")
363 if (vty
->node
== CONFIG_NODE
)
364 DEBUG_OFF (as4
, AS4_SEGMENT
);
367 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
368 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
373 ALIAS (no_debug_bgp_as4_segment
,
374 undebug_bgp_as4_segment_cmd
,
375 "undebug bgp as4 segment",
379 "BGP AS4 aspath segment handling\n")
381 DEFUN (debug_bgp_fsm
,
386 "BGP Finite State Machine\n")
388 if (vty
->node
== CONFIG_NODE
)
392 TERM_DEBUG_ON (fsm
, FSM
);
393 vty_out (vty
, "BGP fsm debugging is on%s", VTY_NEWLINE
);
398 DEFUN (no_debug_bgp_fsm
,
399 no_debug_bgp_fsm_cmd
,
404 "Finite State Machine\n")
406 if (vty
->node
== CONFIG_NODE
)
407 DEBUG_OFF (fsm
, FSM
);
410 TERM_DEBUG_OFF (fsm
, FSM
);
411 vty_out (vty
, "BGP fsm debugging is off%s", VTY_NEWLINE
);
416 ALIAS (no_debug_bgp_fsm
,
422 "Finite State Machine\n")
424 DEFUN (debug_bgp_events
,
425 debug_bgp_events_cmd
,
431 if (vty
->node
== CONFIG_NODE
)
432 DEBUG_ON (events
, EVENTS
);
435 TERM_DEBUG_ON (events
, EVENTS
);
436 vty_out (vty
, "BGP events debugging is on%s", VTY_NEWLINE
);
441 DEFUN (no_debug_bgp_events
,
442 no_debug_bgp_events_cmd
,
443 "no debug bgp events",
449 if (vty
->node
== CONFIG_NODE
)
450 DEBUG_OFF (events
, EVENTS
);
453 TERM_DEBUG_OFF (events
, EVENTS
);
454 vty_out (vty
, "BGP events debugging is off%s", VTY_NEWLINE
);
459 ALIAS (no_debug_bgp_events
,
460 undebug_bgp_events_cmd
,
461 "undebug bgp events",
466 DEFUN (debug_bgp_filter
,
467 debug_bgp_filter_cmd
,
473 if (vty
->node
== CONFIG_NODE
)
474 DEBUG_ON (filter
, FILTER
);
477 TERM_DEBUG_ON (filter
, FILTER
);
478 vty_out (vty
, "BGP filters debugging is on%s", VTY_NEWLINE
);
483 DEFUN (no_debug_bgp_filter
,
484 no_debug_bgp_filter_cmd
,
485 "no debug bgp filters",
491 if (vty
->node
== CONFIG_NODE
)
492 DEBUG_OFF (filter
, FILTER
);
495 TERM_DEBUG_OFF (filter
, FILTER
);
496 vty_out (vty
, "BGP filters debugging is off%s", VTY_NEWLINE
);
501 ALIAS (no_debug_bgp_filter
,
502 undebug_bgp_filter_cmd
,
503 "undebug bgp filters",
508 DEFUN (debug_bgp_keepalive
,
509 debug_bgp_keepalive_cmd
,
510 "debug bgp keepalives",
515 if (vty
->node
== CONFIG_NODE
)
516 DEBUG_ON (keepalive
, KEEPALIVE
);
519 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
520 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
525 DEFUN (no_debug_bgp_keepalive
,
526 no_debug_bgp_keepalive_cmd
,
527 "no debug bgp keepalives",
533 if (vty
->node
== CONFIG_NODE
)
534 DEBUG_OFF (keepalive
, KEEPALIVE
);
537 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
538 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
543 ALIAS (no_debug_bgp_keepalive
,
544 undebug_bgp_keepalive_cmd
,
545 "undebug bgp keepalives",
550 DEFUN (debug_bgp_update
,
551 debug_bgp_update_cmd
,
557 if (vty
->node
== CONFIG_NODE
)
559 DEBUG_ON (update
, UPDATE_IN
);
560 DEBUG_ON (update
, UPDATE_OUT
);
564 TERM_DEBUG_ON (update
, UPDATE_IN
);
565 TERM_DEBUG_ON (update
, UPDATE_OUT
);
566 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
571 DEFUN (debug_bgp_update_direct
,
572 debug_bgp_update_direct_cmd
,
573 "debug bgp updates (in|out)",
578 "Outbound updates\n")
580 if (vty
->node
== CONFIG_NODE
)
582 if (strncmp ("i", argv
[0], 1) == 0)
584 DEBUG_OFF (update
, UPDATE_OUT
);
585 DEBUG_ON (update
, UPDATE_IN
);
589 DEBUG_OFF (update
, UPDATE_IN
);
590 DEBUG_ON (update
, UPDATE_OUT
);
595 if (strncmp ("i", argv
[0], 1) == 0)
597 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
598 TERM_DEBUG_ON (update
, UPDATE_IN
);
599 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
603 TERM_DEBUG_OFF (update
, UPDATE_IN
);
604 TERM_DEBUG_ON (update
, UPDATE_OUT
);
605 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
611 DEFUN (no_debug_bgp_update
,
612 no_debug_bgp_update_cmd
,
613 "no debug bgp updates",
619 if (vty
->node
== CONFIG_NODE
)
621 DEBUG_OFF (update
, UPDATE_IN
);
622 DEBUG_OFF (update
, UPDATE_OUT
);
626 TERM_DEBUG_OFF (update
, UPDATE_IN
);
627 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
628 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
633 ALIAS (no_debug_bgp_update
,
634 undebug_bgp_update_cmd
,
635 "undebug bgp updates",
640 DEFUN (debug_bgp_normal
,
641 debug_bgp_normal_cmd
,
646 if (vty
->node
== CONFIG_NODE
)
647 DEBUG_ON (normal
, NORMAL
);
650 TERM_DEBUG_ON (normal
, NORMAL
);
651 vty_out (vty
, "BGP debugging is on%s", VTY_NEWLINE
);
656 DEFUN (no_debug_bgp_normal
,
657 no_debug_bgp_normal_cmd
,
663 if (vty
->node
== CONFIG_NODE
)
664 DEBUG_OFF (normal
, NORMAL
);
667 TERM_DEBUG_OFF (normal
, NORMAL
);
668 vty_out (vty
, "BGP debugging is off%s", VTY_NEWLINE
);
673 ALIAS (no_debug_bgp_normal
,
674 undebug_bgp_normal_cmd
,
679 DEFUN (debug_bgp_zebra
,
684 "BGP Zebra messages\n")
686 if (vty
->node
== CONFIG_NODE
)
687 DEBUG_ON (zebra
, ZEBRA
);
690 TERM_DEBUG_ON (zebra
, ZEBRA
);
691 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
696 DEFUN (no_debug_bgp_zebra
,
697 no_debug_bgp_zebra_cmd
,
698 "no debug bgp zebra",
702 "BGP Zebra messages\n")
704 if (vty
->node
== CONFIG_NODE
)
705 DEBUG_OFF (zebra
, ZEBRA
);
708 TERM_DEBUG_OFF (zebra
, ZEBRA
);
709 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
714 ALIAS (no_debug_bgp_zebra
,
715 undebug_bgp_zebra_cmd
,
720 "BGP Zebra messages\n")
722 DEFUN (no_debug_bgp_all
,
723 no_debug_bgp_all_cmd
,
727 "Enable all debugging\n"
730 TERM_DEBUG_OFF (normal
, NORMAL
);
731 TERM_DEBUG_OFF (events
, EVENTS
);
732 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
733 TERM_DEBUG_OFF (update
, UPDATE_IN
);
734 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
735 TERM_DEBUG_OFF (as4
, AS4
);
736 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
737 TERM_DEBUG_OFF (fsm
, FSM
);
738 TERM_DEBUG_OFF (filter
, FILTER
);
739 TERM_DEBUG_OFF (zebra
, ZEBRA
);
740 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
745 ALIAS (no_debug_bgp_all
,
749 "Enable all debugging\n"
752 DEFUN (show_debugging_bgp
,
753 show_debugging_bgp_cmd
,
754 "show debugging bgp",
759 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
761 if (BGP_DEBUG (normal
, NORMAL
))
762 vty_out (vty
, " BGP debugging is on%s", VTY_NEWLINE
);
763 if (BGP_DEBUG (events
, EVENTS
))
764 vty_out (vty
, " BGP events debugging is on%s", VTY_NEWLINE
);
765 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
766 vty_out (vty
, " BGP keepalives debugging is on%s", VTY_NEWLINE
);
767 if (BGP_DEBUG (update
, UPDATE_IN
) && BGP_DEBUG (update
, UPDATE_OUT
))
768 vty_out (vty
, " BGP updates debugging is on%s", VTY_NEWLINE
);
769 else if (BGP_DEBUG (update
, UPDATE_IN
))
770 vty_out (vty
, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
771 else if (BGP_DEBUG (update
, UPDATE_OUT
))
772 vty_out (vty
, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
773 if (BGP_DEBUG (fsm
, FSM
))
774 vty_out (vty
, " BGP fsm debugging is on%s", VTY_NEWLINE
);
775 if (BGP_DEBUG (filter
, FILTER
))
776 vty_out (vty
, " BGP filter debugging is on%s", VTY_NEWLINE
);
777 if (BGP_DEBUG (zebra
, ZEBRA
))
778 vty_out (vty
, " BGP zebra debugging is on%s", VTY_NEWLINE
);
779 if (BGP_DEBUG (as4
, AS4
))
780 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
781 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
782 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
783 vty_out (vty
, "%s", VTY_NEWLINE
);
788 bgp_config_write_debug (struct vty
*vty
)
792 if (CONF_BGP_DEBUG (normal
, NORMAL
))
794 vty_out (vty
, "debug bgp%s", VTY_NEWLINE
);
798 if (CONF_BGP_DEBUG (as4
, AS4
))
800 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
804 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
806 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
810 if (CONF_BGP_DEBUG (events
, EVENTS
))
812 vty_out (vty
, "debug bgp events%s", VTY_NEWLINE
);
816 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
818 vty_out (vty
, "debug bgp keepalives%s", VTY_NEWLINE
);
822 if (CONF_BGP_DEBUG (update
, UPDATE_IN
) && CONF_BGP_DEBUG (update
, UPDATE_OUT
))
824 vty_out (vty
, "debug bgp updates%s", VTY_NEWLINE
);
827 else if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
829 vty_out (vty
, "debug bgp updates in%s", VTY_NEWLINE
);
832 else if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
834 vty_out (vty
, "debug bgp updates out%s", VTY_NEWLINE
);
838 if (CONF_BGP_DEBUG (fsm
, FSM
))
840 vty_out (vty
, "debug bgp fsm%s", VTY_NEWLINE
);
844 if (CONF_BGP_DEBUG (filter
, FILTER
))
846 vty_out (vty
, "debug bgp filters%s", VTY_NEWLINE
);
850 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
852 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
859 static struct cmd_node debug_node
=
867 bgp_debug_init (void)
869 install_node (&debug_node
, bgp_config_write_debug
);
871 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
873 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
874 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
875 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
876 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
878 install_element (ENABLE_NODE
, &debug_bgp_fsm_cmd
);
879 install_element (CONFIG_NODE
, &debug_bgp_fsm_cmd
);
880 install_element (ENABLE_NODE
, &debug_bgp_events_cmd
);
881 install_element (CONFIG_NODE
, &debug_bgp_events_cmd
);
882 install_element (ENABLE_NODE
, &debug_bgp_filter_cmd
);
883 install_element (CONFIG_NODE
, &debug_bgp_filter_cmd
);
884 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
885 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
886 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
887 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
888 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
889 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
890 install_element (ENABLE_NODE
, &debug_bgp_normal_cmd
);
891 install_element (CONFIG_NODE
, &debug_bgp_normal_cmd
);
892 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
893 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
895 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
896 install_element (ENABLE_NODE
, &undebug_bgp_as4_cmd
);
897 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
898 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
899 install_element (ENABLE_NODE
, &undebug_bgp_as4_segment_cmd
);
900 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
902 install_element (ENABLE_NODE
, &no_debug_bgp_fsm_cmd
);
903 install_element (ENABLE_NODE
, &undebug_bgp_fsm_cmd
);
904 install_element (CONFIG_NODE
, &no_debug_bgp_fsm_cmd
);
905 install_element (ENABLE_NODE
, &no_debug_bgp_events_cmd
);
906 install_element (ENABLE_NODE
, &undebug_bgp_events_cmd
);
907 install_element (CONFIG_NODE
, &no_debug_bgp_events_cmd
);
908 install_element (ENABLE_NODE
, &no_debug_bgp_filter_cmd
);
909 install_element (ENABLE_NODE
, &undebug_bgp_filter_cmd
);
910 install_element (CONFIG_NODE
, &no_debug_bgp_filter_cmd
);
911 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
912 install_element (ENABLE_NODE
, &undebug_bgp_keepalive_cmd
);
913 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
914 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
915 install_element (ENABLE_NODE
, &undebug_bgp_update_cmd
);
916 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
917 install_element (ENABLE_NODE
, &no_debug_bgp_normal_cmd
);
918 install_element (ENABLE_NODE
, &undebug_bgp_normal_cmd
);
919 install_element (CONFIG_NODE
, &no_debug_bgp_normal_cmd
);
920 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
921 install_element (ENABLE_NODE
, &undebug_bgp_zebra_cmd
);
922 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
923 install_element (ENABLE_NODE
, &no_debug_bgp_all_cmd
);
924 install_element (ENABLE_NODE
, &undebug_bgp_all_cmd
);