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"
33 #include "bgpd/bgpd.h"
34 #include "bgpd/bgp_aspath.h"
35 #include "bgpd/bgp_route.h"
36 #include "bgpd/bgp_attr.h"
37 #include "bgpd/bgp_debug.h"
38 #include "bgpd/bgp_community.h"
40 unsigned long conf_bgp_debug_as4;
41 unsigned long conf_bgp_debug_fsm;
42 unsigned long conf_bgp_debug_events;
43 unsigned long conf_bgp_debug_packet;
44 unsigned long conf_bgp_debug_filter;
45 unsigned long conf_bgp_debug_keepalive;
46 unsigned long conf_bgp_debug_update;
47 unsigned long conf_bgp_debug_normal;
48 unsigned long conf_bgp_debug_zebra;
49 unsigned long conf_bgp_debug_allow_martians;
50 unsigned long conf_bgp_debug_nht;
52 unsigned long term_bgp_debug_as4;
53 unsigned long term_bgp_debug_fsm;
54 unsigned long term_bgp_debug_events;
55 unsigned long term_bgp_debug_packet;
56 unsigned long term_bgp_debug_filter;
57 unsigned long term_bgp_debug_keepalive;
58 unsigned long term_bgp_debug_update;
59 unsigned long term_bgp_debug_normal;
60 unsigned long term_bgp_debug_zebra;
61 unsigned long term_bgp_debug_allow_martians;
62 unsigned long term_bgp_debug_nht;
64 /* messages for BGP-4 status */
65 const struct message bgp_status_msg[] =
68 { Connect, "Connect" },
70 { OpenSent, "OpenSent" },
71 { OpenConfirm, "OpenConfirm" },
72 { Established, "Established" },
73 { Clearing, "Clearing" },
74 { Deleted, "Deleted" },
76 const int bgp_status_msg_max = BGP_STATUS_MAX;
78 /* BGP message type string. */
79 const char *bgp_type_str[] =
90 /* message for BGP-4 Notify */
91 static const struct message bgp_notify_msg[] =
93 { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
94 { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
95 { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
96 { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
97 { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
98 { BGP_NOTIFY_CEASE, "Cease"},
99 { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
101 static const int bgp_notify_msg_max = BGP_NOTIFY_MAX;
103 static const struct message bgp_notify_head_msg[] =
105 { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
106 { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
107 { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}
109 static const int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX;
111 static const struct message bgp_notify_open_msg[] =
113 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
114 { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
115 { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
116 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
117 { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
118 { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
119 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
120 { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
122 static const int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX;
124 static const struct message bgp_notify_update_msg[] =
126 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
127 { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
128 { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
129 { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
130 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
131 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
132 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
133 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
134 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
135 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
136 { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
137 { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
139 static const int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX;
141 static const struct message bgp_notify_cease_msg[] =
143 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
144 { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
145 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
146 { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
147 { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
148 { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
149 { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
150 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"},
151 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
153 static const int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX;
155 static const struct message bgp_notify_capability_msg[] =
157 { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"},
158 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" },
159 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
160 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
162 static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
164 /* Origin strings. */
165 const char *bgp_origin_str[] = {"i","e","?"};
166 const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
168 /* Dump attribute. */
170 bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
175 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
176 snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
178 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
179 snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
180 bgp_origin_str[attr->origin]);
184 char addrbuf[BUFSIZ];
187 if (attr->extra->mp_nexthop_len == 16
188 || attr->extra->mp_nexthop_len == 32)
189 snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
190 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
193 if (attr->extra->mp_nexthop_len == 32)
194 snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
195 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
199 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
200 snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u",
203 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
204 snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u",
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 %u %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;
249 const char *code_str;
252 code_str = LOOKUP_DEF (bgp_notify_msg, bgp_notify->code,
253 "Unrecognized Error Code");
255 switch (bgp_notify->code)
257 case BGP_NOTIFY_HEADER_ERR:
258 subcode_str = LOOKUP_DEF (bgp_notify_head_msg, bgp_notify->subcode,
259 "Unrecognized Error Subcode");
261 case BGP_NOTIFY_OPEN_ERR:
262 subcode_str = LOOKUP_DEF (bgp_notify_open_msg, bgp_notify->subcode,
263 "Unrecognized Error Subcode");
265 case BGP_NOTIFY_UPDATE_ERR:
266 subcode_str = LOOKUP_DEF (bgp_notify_update_msg, bgp_notify->subcode,
267 "Unrecognized Error Subcode");
269 case BGP_NOTIFY_HOLD_ERR:
271 case BGP_NOTIFY_FSM_ERR:
273 case BGP_NOTIFY_CEASE:
274 subcode_str = LOOKUP_DEF (bgp_notify_cease_msg, bgp_notify->subcode,
275 "Unrecognized Error Subcode");
277 case BGP_NOTIFY_CAPABILITY_ERR:
278 subcode_str = LOOKUP_DEF (bgp_notify_capability_msg, bgp_notify->subcode,
279 "Unrecognized Error Subcode");
283 if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
284 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
285 strcmp (direct, "received") == 0 ? "received from" : "sent to",
286 peer->host, bgp_notify->code, bgp_notify->subcode,
287 code_str, subcode_str, bgp_notify->length,
288 bgp_notify->data ? bgp_notify->data : "");
289 else if (BGP_DEBUG (normal, NORMAL))
290 plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
291 peer ? peer->host : "",
292 direct, bgp_notify->code, bgp_notify->subcode,
293 code_str, subcode_str, bgp_notify->length,
294 bgp_notify->data ? bgp_notify->data : "");
297 /* Debug option setting interface. */
298 unsigned long bgp_debug_option = 0;
301 debug (unsigned int option)
303 return bgp_debug_option & option;
306 DEFUN (debug_bgp_as4,
313 if (vty->node == CONFIG_NODE)
317 TERM_DEBUG_ON (as4, AS4);
318 vty_out (vty, "BGP as4 debugging is on%s", VTY_NEWLINE);
323 DEFUN (no_debug_bgp_as4,
324 no_debug_bgp_as4_cmd,
331 if (vty->node == CONFIG_NODE)
332 DEBUG_OFF (as4, AS4);
335 TERM_DEBUG_OFF (as4, AS4);
336 vty_out (vty, "BGP as4 debugging is off%s", VTY_NEWLINE);
341 ALIAS (no_debug_bgp_as4,
348 DEFUN (debug_bgp_as4_segment,
349 debug_bgp_as4_segment_cmd,
350 "debug bgp as4 segment",
354 "BGP AS4 aspath segment handling\n")
356 if (vty->node == CONFIG_NODE)
357 DEBUG_ON (as4, AS4_SEGMENT);
360 TERM_DEBUG_ON (as4, AS4_SEGMENT);
361 vty_out (vty, "BGP as4 segment debugging is on%s", VTY_NEWLINE);
366 DEFUN (no_debug_bgp_as4_segment,
367 no_debug_bgp_as4_segment_cmd,
368 "no debug bgp as4 segment",
373 "BGP AS4 aspath segment handling\n")
375 if (vty->node == CONFIG_NODE)
376 DEBUG_OFF (as4, AS4_SEGMENT);
379 TERM_DEBUG_OFF (as4, AS4_SEGMENT);
380 vty_out (vty, "BGP as4 segment debugging is off%s", VTY_NEWLINE);
385 ALIAS (no_debug_bgp_as4_segment,
386 undebug_bgp_as4_segment_cmd,
387 "undebug bgp as4 segment",
391 "BGP AS4 aspath segment handling\n")
393 DEFUN (debug_bgp_fsm,
398 "BGP Finite State Machine\n")
400 if (vty->node == CONFIG_NODE)
404 TERM_DEBUG_ON (fsm, FSM);
405 vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
410 DEFUN (no_debug_bgp_fsm,
411 no_debug_bgp_fsm_cmd,
416 "Finite State Machine\n")
418 if (vty->node == CONFIG_NODE)
419 DEBUG_OFF (fsm, FSM);
422 TERM_DEBUG_OFF (fsm, FSM);
423 vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
428 ALIAS (no_debug_bgp_fsm,
433 "Finite State Machine\n")
435 DEFUN (debug_bgp_events,
436 debug_bgp_events_cmd,
442 if (vty->node == CONFIG_NODE)
443 DEBUG_ON (events, EVENTS);
446 TERM_DEBUG_ON (events, EVENTS);
447 vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
452 DEFUN (no_debug_bgp_events,
453 no_debug_bgp_events_cmd,
454 "no debug bgp events",
460 if (vty->node == CONFIG_NODE)
461 DEBUG_OFF (events, EVENTS);
464 TERM_DEBUG_OFF (events, EVENTS);
465 vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
470 ALIAS (no_debug_bgp_events,
471 undebug_bgp_events_cmd,
472 "undebug bgp events",
477 DEFUN (debug_bgp_nht,
482 "BGP nexthop tracking events\n")
484 if (vty->node == CONFIG_NODE)
488 TERM_DEBUG_ON (nht, NHT);
489 vty_out (vty, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE);
494 DEFUN (no_debug_bgp_nht,
495 no_debug_bgp_nht_cmd,
500 "BGP nexthop tracking events\n")
502 if (vty->node == CONFIG_NODE)
503 DEBUG_OFF (nht, NHT);
506 TERM_DEBUG_OFF (nht, NHT);
507 vty_out (vty, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE);
512 ALIAS (no_debug_bgp_nht,
517 "BGP next-hop tracking updates\n")
519 DEFUN (debug_bgp_filter,
520 debug_bgp_filter_cmd,
526 if (vty->node == CONFIG_NODE)
527 DEBUG_ON (filter, FILTER);
530 TERM_DEBUG_ON (filter, FILTER);
531 vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
536 DEFUN (no_debug_bgp_filter,
537 no_debug_bgp_filter_cmd,
538 "no debug bgp filters",
544 if (vty->node == CONFIG_NODE)
545 DEBUG_OFF (filter, FILTER);
548 TERM_DEBUG_OFF (filter, FILTER);
549 vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
554 ALIAS (no_debug_bgp_filter,
555 undebug_bgp_filter_cmd,
556 "undebug bgp filters",
561 DEFUN (debug_bgp_keepalive,
562 debug_bgp_keepalive_cmd,
563 "debug bgp keepalives",
568 if (vty->node == CONFIG_NODE)
569 DEBUG_ON (keepalive, KEEPALIVE);
572 TERM_DEBUG_ON (keepalive, KEEPALIVE);
573 vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
578 DEFUN (no_debug_bgp_keepalive,
579 no_debug_bgp_keepalive_cmd,
580 "no debug bgp keepalives",
586 if (vty->node == CONFIG_NODE)
587 DEBUG_OFF (keepalive, KEEPALIVE);
590 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
591 vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
596 ALIAS (no_debug_bgp_keepalive,
597 undebug_bgp_keepalive_cmd,
598 "undebug bgp keepalives",
603 DEFUN (debug_bgp_update,
604 debug_bgp_update_cmd,
610 if (vty->node == CONFIG_NODE)
612 DEBUG_ON (update, UPDATE_IN);
613 DEBUG_ON (update, UPDATE_OUT);
617 TERM_DEBUG_ON (update, UPDATE_IN);
618 TERM_DEBUG_ON (update, UPDATE_OUT);
619 vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
624 DEFUN (debug_bgp_update_direct,
625 debug_bgp_update_direct_cmd,
626 "debug bgp updates (in|out)",
631 "Outbound updates\n")
633 if (vty->node == CONFIG_NODE)
635 if (strncmp ("i", argv[0], 1) == 0)
637 DEBUG_OFF (update, UPDATE_OUT);
638 DEBUG_ON (update, UPDATE_IN);
642 DEBUG_OFF (update, UPDATE_IN);
643 DEBUG_ON (update, UPDATE_OUT);
648 if (strncmp ("i", argv[0], 1) == 0)
650 TERM_DEBUG_OFF (update, UPDATE_OUT);
651 TERM_DEBUG_ON (update, UPDATE_IN);
652 vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
656 TERM_DEBUG_OFF (update, UPDATE_IN);
657 TERM_DEBUG_ON (update, UPDATE_OUT);
658 vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
664 DEFUN (no_debug_bgp_update,
665 no_debug_bgp_update_cmd,
666 "no debug bgp updates",
672 if (vty->node == CONFIG_NODE)
674 DEBUG_OFF (update, UPDATE_IN);
675 DEBUG_OFF (update, UPDATE_OUT);
679 TERM_DEBUG_OFF (update, UPDATE_IN);
680 TERM_DEBUG_OFF (update, UPDATE_OUT);
681 vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
686 ALIAS (no_debug_bgp_update,
687 undebug_bgp_update_cmd,
688 "undebug bgp updates",
693 DEFUN (debug_bgp_normal,
694 debug_bgp_normal_cmd,
699 if (vty->node == CONFIG_NODE)
700 DEBUG_ON (normal, NORMAL);
703 TERM_DEBUG_ON (normal, NORMAL);
704 vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
709 DEFUN (no_debug_bgp_normal,
710 no_debug_bgp_normal_cmd,
716 if (vty->node == CONFIG_NODE)
717 DEBUG_OFF (normal, NORMAL);
720 TERM_DEBUG_OFF (normal, NORMAL);
721 vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
726 ALIAS (no_debug_bgp_normal,
727 undebug_bgp_normal_cmd,
732 DEFUN (debug_bgp_zebra,
737 "BGP Zebra messages\n")
739 if (vty->node == CONFIG_NODE)
740 DEBUG_ON (zebra, ZEBRA);
743 TERM_DEBUG_ON (zebra, ZEBRA);
744 vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE);
749 DEFUN (no_debug_bgp_zebra,
750 no_debug_bgp_zebra_cmd,
751 "no debug bgp zebra",
755 "BGP Zebra messages\n")
757 if (vty->node == CONFIG_NODE)
758 DEBUG_OFF (zebra, ZEBRA);
761 TERM_DEBUG_OFF (zebra, ZEBRA);
762 vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE);
767 ALIAS (no_debug_bgp_zebra,
768 undebug_bgp_zebra_cmd,
772 "BGP Zebra messages\n")
774 DEFUN (debug_bgp_allow_martians,
775 debug_bgp_allow_martians_cmd,
776 "debug bgp allow-martians",
779 "BGP allow martian next hops\n")
781 if (vty->node == CONFIG_NODE)
782 DEBUG_ON (allow_martians, ALLOW_MARTIANS);
785 TERM_DEBUG_ON (allow_martians, ALLOW_MARTIANS);
786 vty_out (vty, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE);
791 DEFUN (no_debug_bgp_allow_martians,
792 no_debug_bgp_allow_martians_cmd,
793 "no debug bgp allow-martians",
797 "BGP allow martian next hops\n")
799 if (vty->node == CONFIG_NODE)
800 DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
803 TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
804 vty_out (vty, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE);
809 ALIAS (no_debug_bgp_allow_martians,
810 undebug_bgp_allow_martians_cmd,
811 "undebug bgp allow-martians",
814 "BGP allow martian next hops\n")
816 DEFUN (no_debug_bgp_all,
817 no_debug_bgp_all_cmd,
821 "Enable all debugging\n"
824 TERM_DEBUG_OFF (normal, NORMAL);
825 TERM_DEBUG_OFF (events, EVENTS);
826 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
827 TERM_DEBUG_OFF (update, UPDATE_IN);
828 TERM_DEBUG_OFF (update, UPDATE_OUT);
829 TERM_DEBUG_OFF (as4, AS4);
830 TERM_DEBUG_OFF (as4, AS4_SEGMENT);
831 TERM_DEBUG_OFF (fsm, FSM);
832 TERM_DEBUG_OFF (filter, FILTER);
833 TERM_DEBUG_OFF (zebra, ZEBRA);
834 TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS);
835 vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
840 ALIAS (no_debug_bgp_all,
844 "Enable all debugging\n"
847 DEFUN (show_debugging_bgp,
848 show_debugging_bgp_cmd,
849 "show debugging bgp",
854 vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
856 if (BGP_DEBUG (normal, NORMAL))
857 vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE);
858 if (BGP_DEBUG (events, EVENTS))
859 vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE);
860 if (BGP_DEBUG (keepalive, KEEPALIVE))
861 vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE);
862 if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
863 vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE);
864 else if (BGP_DEBUG (update, UPDATE_IN))
865 vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
866 else if (BGP_DEBUG (update, UPDATE_OUT))
867 vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
868 if (BGP_DEBUG (fsm, FSM))
869 vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
870 if (BGP_DEBUG (filter, FILTER))
871 vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
872 if (BGP_DEBUG (zebra, ZEBRA))
873 vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE);
874 if (BGP_DEBUG (as4, AS4))
875 vty_out (vty, " BGP as4 debugging is on%s", VTY_NEWLINE);
876 if (BGP_DEBUG (as4, AS4_SEGMENT))
877 vty_out (vty, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE);
878 if (BGP_DEBUG (allow_martians, ALLOW_MARTIANS))
879 vty_out (vty, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE);
880 if (BGP_DEBUG (nht, NHT))
881 vty_out (vty, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE);
882 vty_out (vty, "%s", VTY_NEWLINE);
887 bgp_config_write_debug (struct vty *vty)
891 if (CONF_BGP_DEBUG (normal, NORMAL))
893 vty_out (vty, "debug bgp%s", VTY_NEWLINE);
897 if (CONF_BGP_DEBUG (as4, AS4))
899 vty_out (vty, "debug bgp as4%s", VTY_NEWLINE);
903 if (CONF_BGP_DEBUG (as4, AS4_SEGMENT))
905 vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE);
909 if (CONF_BGP_DEBUG (events, EVENTS))
911 vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
915 if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
917 vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
921 if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
923 vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
926 else if (CONF_BGP_DEBUG (update, UPDATE_IN))
928 vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
931 else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
933 vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
937 if (CONF_BGP_DEBUG (fsm, FSM))
939 vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
943 if (CONF_BGP_DEBUG (filter, FILTER))
945 vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
949 if (CONF_BGP_DEBUG (zebra, ZEBRA))
951 vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE);
955 if (CONF_BGP_DEBUG (allow_martians, ALLOW_MARTIANS))
957 vty_out (vty, "debug bgp allow-martians%s", VTY_NEWLINE);
961 if (CONF_BGP_DEBUG (nht, NHT))
963 vty_out (vty, "debug bgp nht%s", VTY_NEWLINE);
970 static struct cmd_node debug_node =
978 bgp_debug_init (void)
980 install_node (&debug_node, bgp_config_write_debug);
982 install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
984 install_element (ENABLE_NODE, &debug_bgp_as4_cmd);
985 install_element (CONFIG_NODE, &debug_bgp_as4_cmd);
986 install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd);
987 install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd);
989 install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
990 install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
991 install_element (ENABLE_NODE, &debug_bgp_events_cmd);
992 install_element (CONFIG_NODE, &debug_bgp_events_cmd);
993 install_element (ENABLE_NODE, &debug_bgp_nht_cmd);
994 install_element (CONFIG_NODE, &debug_bgp_nht_cmd);
995 install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
996 install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
997 install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
998 install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
999 install_element (ENABLE_NODE, &debug_bgp_update_cmd);
1000 install_element (CONFIG_NODE, &debug_bgp_update_cmd);
1001 install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
1002 install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
1003 install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
1004 install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
1005 install_element (ENABLE_NODE, &debug_bgp_zebra_cmd);
1006 install_element (CONFIG_NODE, &debug_bgp_zebra_cmd);
1007 install_element (ENABLE_NODE, &debug_bgp_allow_martians_cmd);
1008 install_element (CONFIG_NODE, &debug_bgp_allow_martians_cmd);
1010 install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd);
1011 install_element (ENABLE_NODE, &undebug_bgp_as4_cmd);
1012 install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd);
1013 install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd);
1014 install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd);
1015 install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd);
1017 install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
1018 install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
1019 install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
1020 install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
1021 install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
1022 install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
1023 install_element (ENABLE_NODE, &no_debug_bgp_nht_cmd);
1024 install_element (ENABLE_NODE, &undebug_bgp_nht_cmd);
1025 install_element (CONFIG_NODE, &no_debug_bgp_nht_cmd);
1026 install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
1027 install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
1028 install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
1029 install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
1030 install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
1031 install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
1032 install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
1033 install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
1034 install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
1035 install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
1036 install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
1037 install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
1038 install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
1039 install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd);
1040 install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
1041 install_element (ENABLE_NODE, &no_debug_bgp_allow_martians_cmd);
1042 install_element (ENABLE_NODE, &undebug_bgp_allow_martians_cmd);
1043 install_element (CONFIG_NODE, &no_debug_bgp_allow_martians_cmd);
1044 install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
1045 install_element (ENABLE_NODE, &undebug_bgp_all_cmd);