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"
34 #include "bgpd/bgpd.h"
35 #include "bgpd/bgp_aspath.h"
36 #include "bgpd/bgp_route.h"
37 #include "bgpd/bgp_attr.h"
38 #include "bgpd/bgp_debug.h"
39 #include "bgpd/bgp_community.h"
41 unsigned long conf_bgp_debug_as4;
42 unsigned long conf_bgp_debug_fsm;
43 unsigned long conf_bgp_debug_events;
44 unsigned long conf_bgp_debug_packet;
45 unsigned long conf_bgp_debug_filter;
46 unsigned long conf_bgp_debug_keepalive;
47 unsigned long conf_bgp_debug_update;
48 unsigned long conf_bgp_debug_normal;
49 unsigned long conf_bgp_debug_zebra;
50 unsigned long conf_bgp_debug_allow_martians;
51 unsigned long conf_bgp_debug_nht;
53 unsigned long term_bgp_debug_as4;
54 unsigned long term_bgp_debug_fsm;
55 unsigned long term_bgp_debug_events;
56 unsigned long term_bgp_debug_packet;
57 unsigned long term_bgp_debug_filter;
58 unsigned long term_bgp_debug_keepalive;
59 unsigned long term_bgp_debug_update;
60 unsigned long term_bgp_debug_normal;
61 unsigned long term_bgp_debug_zebra;
62 unsigned long term_bgp_debug_allow_martians;
63 unsigned long term_bgp_debug_nht;
65 /* messages for BGP-4 status */
66 const struct message bgp_status_msg[] =
69 { Connect, "Connect" },
71 { OpenSent, "OpenSent" },
72 { OpenConfirm, "OpenConfirm" },
73 { Established, "Established" },
74 { Clearing, "Clearing" },
75 { Deleted, "Deleted" },
77 #define BGP_DEBUG_MSG_MAX(msg) const int msg ## _max = array_size (msg)
78 BGP_DEBUG_MSG_MAX (bgp_status_msg);
80 /* BGP message type string. */
81 const char *bgp_type_str[] =
93 /* message for BGP-4 Notify */
94 static const struct message bgp_notify_msg[] =
96 { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
97 { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
98 { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
99 { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
100 { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
101 { BGP_NOTIFY_CEASE, "Cease"},
102 { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
104 BGP_DEBUG_MSG_MAX (bgp_notify_msg);
106 static const struct message bgp_notify_head_msg[] =
108 { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
109 { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
110 { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"},
112 BGP_DEBUG_MSG_MAX (bgp_notify_head_msg);
114 static const struct message bgp_notify_open_msg[] =
116 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
117 { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
118 { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
119 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
120 { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
121 { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
122 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
123 { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
125 BGP_DEBUG_MSG_MAX (bgp_notify_open_msg);
127 static const struct message bgp_notify_update_msg[] =
129 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
130 { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
131 { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
132 { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
133 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
134 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
135 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
136 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
137 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
138 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
139 { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
140 { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
142 BGP_DEBUG_MSG_MAX (bgp_notify_update_msg);
144 static const struct message bgp_notify_cease_msg[] =
146 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
147 { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
148 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
149 { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
150 { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
151 { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
152 { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
153 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"},
154 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
156 BGP_DEBUG_MSG_MAX (bgp_notify_cease_msg);
158 static const struct message bgp_notify_capability_msg[] =
160 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
161 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" },
162 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
163 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
165 BGP_DEBUG_MSG_MAX (bgp_notify_capability_msg);
167 /* Origin strings. */
168 const char *bgp_origin_str[] = {"i","e","?"};
169 const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
171 /* Dump attribute. */
173 bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
178 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
179 snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
181 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
182 snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
183 bgp_origin_str[attr->origin]);
187 char addrbuf[BUFSIZ];
190 if (attr->extra->mp_nexthop_len == 16
191 || attr->extra->mp_nexthop_len == 32)
192 snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
193 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
196 if (attr->extra->mp_nexthop_len == 32)
197 snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
198 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
202 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
203 snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u",
206 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
207 snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u",
210 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
211 snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
212 community_str (attr->community));
214 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
215 snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
217 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
218 snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s",
219 attr->extra->aggregator_as,
220 inet_ntoa (attr->extra->aggregator_addr));
222 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
223 snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
224 inet_ntoa (attr->extra->originator_id));
226 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
230 snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
231 for (i = 0; i < attr->extra->cluster->length / 4; i++)
232 snprintf (buf + strlen (buf), size - strlen (buf), " %s",
233 inet_ntoa (attr->extra->cluster->list[i]));
236 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
237 snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
238 aspath_print (attr->aspath));
240 if (strlen (buf) > 1)
246 /* dump notify packet */
248 bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
251 const char *subcode_str;
252 const char *code_str;
255 code_str = LOOKUP_DEF (bgp_notify_msg, bgp_notify->code,
256 "Unrecognized Error Code");
258 switch (bgp_notify->code)
260 case BGP_NOTIFY_HEADER_ERR:
261 subcode_str = LOOKUP_DEF (bgp_notify_head_msg, bgp_notify->subcode,
262 "Unrecognized Error Subcode");
264 case BGP_NOTIFY_OPEN_ERR:
265 subcode_str = LOOKUP_DEF (bgp_notify_open_msg, bgp_notify->subcode,
266 "Unrecognized Error Subcode");
268 case BGP_NOTIFY_UPDATE_ERR:
269 subcode_str = LOOKUP_DEF (bgp_notify_update_msg, bgp_notify->subcode,
270 "Unrecognized Error Subcode");
272 case BGP_NOTIFY_HOLD_ERR:
274 case BGP_NOTIFY_FSM_ERR:
276 case BGP_NOTIFY_CEASE:
277 subcode_str = LOOKUP_DEF (bgp_notify_cease_msg, bgp_notify->subcode,
278 "Unrecognized Error Subcode");
280 case BGP_NOTIFY_CAPABILITY_ERR:
281 subcode_str = LOOKUP_DEF (bgp_notify_capability_msg, bgp_notify->subcode,
282 "Unrecognized Error Subcode");
286 if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
287 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
288 strcmp (direct, "received") == 0 ? "received from" : "sent to",
289 peer->host, bgp_notify->code, bgp_notify->subcode,
290 code_str, subcode_str, bgp_notify->length,
291 bgp_notify->data ? bgp_notify->data : "");
292 else if (BGP_DEBUG (normal, NORMAL))
293 plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
294 peer ? peer->host : "",
295 direct, bgp_notify->code, bgp_notify->subcode,
296 code_str, subcode_str, bgp_notify->length,
297 bgp_notify->data ? bgp_notify->data : "");
300 /* Debug option setting interface. */
301 unsigned long bgp_debug_option = 0;
304 debug (unsigned int option)
306 return bgp_debug_option & option;
309 DEFUN (debug_bgp_as4,
316 if (vty->node == CONFIG_NODE)
320 TERM_DEBUG_ON (as4, AS4);
321 vty_out (vty, "BGP as4 debugging is on%s", VTY_NEWLINE);
326 DEFUN (no_debug_bgp_as4,
327 no_debug_bgp_as4_cmd,
334 if (vty->node == CONFIG_NODE)
335 DEBUG_OFF (as4, AS4);
338 TERM_DEBUG_OFF (as4, AS4);
339 vty_out (vty, "BGP as4 debugging is off%s", VTY_NEWLINE);
344 ALIAS (no_debug_bgp_as4,
351 DEFUN (debug_bgp_as4_segment,
352 debug_bgp_as4_segment_cmd,
353 "debug bgp as4 segment",
357 "BGP AS4 aspath segment handling\n")
359 if (vty->node == CONFIG_NODE)
360 DEBUG_ON (as4, AS4_SEGMENT);
363 TERM_DEBUG_ON (as4, AS4_SEGMENT);
364 vty_out (vty, "BGP as4 segment debugging is on%s", VTY_NEWLINE);
369 DEFUN (no_debug_bgp_as4_segment,
370 no_debug_bgp_as4_segment_cmd,
371 "no debug bgp as4 segment",
376 "BGP AS4 aspath segment handling\n")
378 if (vty->node == CONFIG_NODE)
379 DEBUG_OFF (as4, AS4_SEGMENT);
382 TERM_DEBUG_OFF (as4, AS4_SEGMENT);
383 vty_out (vty, "BGP as4 segment debugging is off%s", VTY_NEWLINE);
388 ALIAS (no_debug_bgp_as4_segment,
389 undebug_bgp_as4_segment_cmd,
390 "undebug bgp as4 segment",
394 "BGP AS4 aspath segment handling\n")
396 DEFUN (debug_bgp_fsm,
401 "BGP Finite State Machine\n")
403 if (vty->node == CONFIG_NODE)
407 TERM_DEBUG_ON (fsm, FSM);
408 vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
413 DEFUN (no_debug_bgp_fsm,
414 no_debug_bgp_fsm_cmd,
419 "Finite State Machine\n")
421 if (vty->node == CONFIG_NODE)
422 DEBUG_OFF (fsm, FSM);
425 TERM_DEBUG_OFF (fsm, FSM);
426 vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
431 ALIAS (no_debug_bgp_fsm,
436 "Finite State Machine\n")
438 DEFUN (debug_bgp_events,
439 debug_bgp_events_cmd,
445 if (vty->node == CONFIG_NODE)
446 DEBUG_ON (events, EVENTS);
449 TERM_DEBUG_ON (events, EVENTS);
450 vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
455 DEFUN (no_debug_bgp_events,
456 no_debug_bgp_events_cmd,
457 "no debug bgp events",
463 if (vty->node == CONFIG_NODE)
464 DEBUG_OFF (events, EVENTS);
467 TERM_DEBUG_OFF (events, EVENTS);
468 vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
473 ALIAS (no_debug_bgp_events,
474 undebug_bgp_events_cmd,
475 "undebug bgp events",
480 DEFUN (debug_bgp_nht,
485 "BGP nexthop tracking events\n")
487 if (vty->node == CONFIG_NODE)
491 TERM_DEBUG_ON (nht, NHT);
492 vty_out (vty, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE);
497 DEFUN (no_debug_bgp_nht,
498 no_debug_bgp_nht_cmd,
503 "BGP nexthop tracking events\n")
505 if (vty->node == CONFIG_NODE)
506 DEBUG_OFF (nht, NHT);
509 TERM_DEBUG_OFF (nht, NHT);
510 vty_out (vty, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE);
515 ALIAS (no_debug_bgp_nht,
520 "BGP next-hop tracking updates\n")
522 DEFUN (debug_bgp_filter,
523 debug_bgp_filter_cmd,
529 if (vty->node == CONFIG_NODE)
530 DEBUG_ON (filter, FILTER);
533 TERM_DEBUG_ON (filter, FILTER);
534 vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
539 DEFUN (no_debug_bgp_filter,
540 no_debug_bgp_filter_cmd,
541 "no debug bgp filters",
547 if (vty->node == CONFIG_NODE)
548 DEBUG_OFF (filter, FILTER);
551 TERM_DEBUG_OFF (filter, FILTER);
552 vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
557 ALIAS (no_debug_bgp_filter,
558 undebug_bgp_filter_cmd,
559 "undebug bgp filters",
564 DEFUN (debug_bgp_keepalive,
565 debug_bgp_keepalive_cmd,
566 "debug bgp keepalives",
571 if (vty->node == CONFIG_NODE)
572 DEBUG_ON (keepalive, KEEPALIVE);
575 TERM_DEBUG_ON (keepalive, KEEPALIVE);
576 vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
581 DEFUN (no_debug_bgp_keepalive,
582 no_debug_bgp_keepalive_cmd,
583 "no debug bgp keepalives",
589 if (vty->node == CONFIG_NODE)
590 DEBUG_OFF (keepalive, KEEPALIVE);
593 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
594 vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
599 ALIAS (no_debug_bgp_keepalive,
600 undebug_bgp_keepalive_cmd,
601 "undebug bgp keepalives",
606 DEFUN (debug_bgp_update,
607 debug_bgp_update_cmd,
613 if (vty->node == CONFIG_NODE)
615 DEBUG_ON (update, UPDATE_IN);
616 DEBUG_ON (update, UPDATE_OUT);
620 TERM_DEBUG_ON (update, UPDATE_IN);
621 TERM_DEBUG_ON (update, UPDATE_OUT);
622 vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
627 DEFUN (debug_bgp_update_direct,
628 debug_bgp_update_direct_cmd,
629 "debug bgp updates (in|out)",
634 "Outbound updates\n")
636 if (vty->node == CONFIG_NODE)
638 if (strncmp ("i", argv[0], 1) == 0)
640 DEBUG_OFF (update, UPDATE_OUT);
641 DEBUG_ON (update, UPDATE_IN);
645 DEBUG_OFF (update, UPDATE_IN);
646 DEBUG_ON (update, UPDATE_OUT);
651 if (strncmp ("i", argv[0], 1) == 0)
653 TERM_DEBUG_OFF (update, UPDATE_OUT);
654 TERM_DEBUG_ON (update, UPDATE_IN);
655 vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
659 TERM_DEBUG_OFF (update, UPDATE_IN);
660 TERM_DEBUG_ON (update, UPDATE_OUT);
661 vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
667 DEFUN (no_debug_bgp_update,
668 no_debug_bgp_update_cmd,
669 "no debug bgp updates",
675 if (vty->node == CONFIG_NODE)
677 DEBUG_OFF (update, UPDATE_IN);
678 DEBUG_OFF (update, UPDATE_OUT);
682 TERM_DEBUG_OFF (update, UPDATE_IN);
683 TERM_DEBUG_OFF (update, UPDATE_OUT);
684 vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
689 ALIAS (no_debug_bgp_update,
690 undebug_bgp_update_cmd,
691 "undebug bgp updates",
696 DEFUN (debug_bgp_normal,
697 debug_bgp_normal_cmd,
702 if (vty->node == CONFIG_NODE)
703 DEBUG_ON (normal, NORMAL);
706 TERM_DEBUG_ON (normal, NORMAL);
707 vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
712 DEFUN (no_debug_bgp_normal,
713 no_debug_bgp_normal_cmd,
719 if (vty->node == CONFIG_NODE)
720 DEBUG_OFF (normal, NORMAL);
723 TERM_DEBUG_OFF (normal, NORMAL);
724 vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
729 ALIAS (no_debug_bgp_normal,
730 undebug_bgp_normal_cmd,
735 DEFUN (debug_bgp_zebra,
740 "BGP Zebra messages\n")
742 if (vty->node == CONFIG_NODE)
743 DEBUG_ON (zebra, ZEBRA);
746 TERM_DEBUG_ON (zebra, ZEBRA);
747 vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE);
752 DEFUN (no_debug_bgp_zebra,
753 no_debug_bgp_zebra_cmd,
754 "no debug bgp zebra",
758 "BGP Zebra messages\n")
760 if (vty->node == CONFIG_NODE)
761 DEBUG_OFF (zebra, ZEBRA);
764 TERM_DEBUG_OFF (zebra, ZEBRA);
765 vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
770 ALIAS (no_debug_bgp_zebra,
771 undebug_bgp_zebra_cmd,
775 "BGP Zebra messages\n")
777 DEFUN (debug_bgp_allow_martians,
778 debug_bgp_allow_martians_cmd,
779 "debug bgp allow-martians",
782 "BGP allow martian next hops\n")
784 if (vty->node == CONFIG_NODE)
785 DEBUG_ON (allow_martians, ALLOW_MARTIANS);
788 TERM_DEBUG_ON (allow_martians, ALLOW_MARTIANS);
789 vty_out (vty, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE);
794 DEFUN (no_debug_bgp_allow_martians,
795 no_debug_bgp_allow_martians_cmd,
796 "no debug bgp allow-martians",
800 "BGP allow martian next hops\n")
802 if (vty->node == CONFIG_NODE)
803 DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
806 TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
807 vty_out (vty, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE);
812 ALIAS (no_debug_bgp_allow_martians,
813 undebug_bgp_allow_martians_cmd,
814 "undebug bgp allow-martians",
817 "BGP allow martian next hops\n")
819 DEFUN (no_debug_bgp_all,
820 no_debug_bgp_all_cmd,
824 "Enable all debugging\n"
827 TERM_DEBUG_OFF (normal, NORMAL);
828 TERM_DEBUG_OFF (events, EVENTS);
829 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
830 TERM_DEBUG_OFF (update, UPDATE_IN);
831 TERM_DEBUG_OFF (update, UPDATE_OUT);
832 TERM_DEBUG_OFF (as4, AS4);
833 TERM_DEBUG_OFF (as4, AS4_SEGMENT);
834 TERM_DEBUG_OFF (fsm, FSM);
835 TERM_DEBUG_OFF (filter, FILTER);
836 TERM_DEBUG_OFF (zebra, ZEBRA);
837 TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
838 vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
843 ALIAS (no_debug_bgp_all,
847 "Enable all debugging\n"
850 DEFUN (show_debugging_bgp,
851 show_debugging_bgp_cmd,
852 "show debugging bgp",
857 vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
859 if (BGP_DEBUG (normal, NORMAL))
860 vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE);
861 if (BGP_DEBUG (events, EVENTS))
862 vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE);
863 if (BGP_DEBUG (keepalive, KEEPALIVE))
864 vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE);
865 if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
866 vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE);
867 else if (BGP_DEBUG (update, UPDATE_IN))
868 vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
869 else if (BGP_DEBUG (update, UPDATE_OUT))
870 vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
871 if (BGP_DEBUG (fsm, FSM))
872 vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
873 if (BGP_DEBUG (filter, FILTER))
874 vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
875 if (BGP_DEBUG (zebra, ZEBRA))
876 vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE);
877 if (BGP_DEBUG (as4, AS4))
878 vty_out (vty, " BGP as4 debugging is on%s", VTY_NEWLINE);
879 if (BGP_DEBUG (as4, AS4_SEGMENT))
880 vty_out (vty, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE);
881 if (BGP_DEBUG (allow_martians, ALLOW_MARTIANS))
882 vty_out (vty, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE);
883 if (BGP_DEBUG (nht, NHT))
884 vty_out (vty, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE);
885 vty_out (vty, "%s", VTY_NEWLINE);
890 bgp_config_write_debug (struct vty *vty)
894 if (CONF_BGP_DEBUG (normal, NORMAL))
896 vty_out (vty, "debug bgp%s", VTY_NEWLINE);
900 if (CONF_BGP_DEBUG (as4, AS4))
902 vty_out (vty, "debug bgp as4%s", VTY_NEWLINE);
906 if (CONF_BGP_DEBUG (as4, AS4_SEGMENT))
908 vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE);
912 if (CONF_BGP_DEBUG (events, EVENTS))
914 vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
918 if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
920 vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
924 if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
926 vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
929 else if (CONF_BGP_DEBUG (update, UPDATE_IN))
931 vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
934 else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
936 vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
940 if (CONF_BGP_DEBUG (fsm, FSM))
942 vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
946 if (CONF_BGP_DEBUG (filter, FILTER))
948 vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
952 if (CONF_BGP_DEBUG (zebra, ZEBRA))
954 vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE);
958 if (CONF_BGP_DEBUG (allow_martians, ALLOW_MARTIANS))
960 vty_out (vty, "debug bgp allow-martians%s", VTY_NEWLINE);
964 if (CONF_BGP_DEBUG (nht, NHT))
966 vty_out (vty, "debug bgp nht%s", VTY_NEWLINE);
973 static struct cmd_node debug_node =
981 bgp_debug_init (void)
983 install_node (&debug_node, bgp_config_write_debug);
985 install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
987 install_element (ENABLE_NODE, &debug_bgp_as4_cmd);
988 install_element (CONFIG_NODE, &debug_bgp_as4_cmd);
989 install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd);
990 install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd);
992 install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
993 install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
994 install_element (ENABLE_NODE, &debug_bgp_events_cmd);
995 install_element (CONFIG_NODE, &debug_bgp_events_cmd);
996 install_element (ENABLE_NODE, &debug_bgp_nht_cmd);
997 install_element (CONFIG_NODE, &debug_bgp_nht_cmd);
998 install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
999 install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
1000 install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
1001 install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
1002 install_element (ENABLE_NODE, &debug_bgp_update_cmd);
1003 install_element (CONFIG_NODE, &debug_bgp_update_cmd);
1004 install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
1005 install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
1006 install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
1007 install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
1008 install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
1009 install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
1010 install_element (ENABLE_NODE, &debug_bgp_allow_martians_cmd);
1011 install_element (CONFIG_NODE, &debug_bgp_allow_martians_cmd);
1013 install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd);
1014 install_element (ENABLE_NODE, &undebug_bgp_as4_cmd);
1015 install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd);
1016 install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd);
1017 install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd);
1018 install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd);
1020 install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
1021 install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
1022 install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
1023 install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
1024 install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
1025 install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
1026 install_element (ENABLE_NODE, &no_debug_bgp_nht_cmd);
1027 install_element (ENABLE_NODE, &undebug_bgp_nht_cmd);
1028 install_element (CONFIG_NODE, &no_debug_bgp_nht_cmd);
1029 install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
1030 install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
1031 install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
1032 install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
1033 install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
1034 install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
1035 install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
1036 install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
1037 install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
1038 install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
1039 install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
1040 install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
1041 install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
1042 install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
1043 install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
1044 install_element (ENABLE_NODE, &no_debug_bgp_allow_martians_cmd);
1045 install_element (ENABLE_NODE, &undebug_bgp_allow_martians_cmd);
1046 install_element (CONFIG_NODE, &no_debug_bgp_allow_martians_cmd);
1047 install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
1048 install_element (ENABLE_NODE, &undebug_bgp_all_cmd);