paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP-4, BGP-4+ packet debug routine |
| 2 | Copyright (C) 1996, 97, 99 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 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 |
| 9 | later version. |
| 10 | |
| 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. |
| 15 | |
| 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 |
| 19 | 02111-1307, USA. */ |
| 20 | |
| 21 | #include <zebra.h> |
| 22 | |
gdt | 5e4fa16 | 2004-03-16 14:38:36 +0000 | [diff] [blame] | 23 | #include <lib/version.h> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 24 | #include "prefix.h" |
| 25 | #include "linklist.h" |
| 26 | #include "stream.h" |
| 27 | #include "command.h" |
| 28 | #include "str.h" |
| 29 | #include "log.h" |
| 30 | #include "sockunion.h" |
| 31 | |
| 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" |
| 38 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 39 | unsigned long conf_bgp_debug_as4; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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; |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 47 | unsigned long conf_bgp_debug_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 49 | unsigned long term_bgp_debug_as4; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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; |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 57 | unsigned long term_bgp_debug_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | |
| 59 | /* messages for BGP-4 status */ |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 60 | const struct message bgp_status_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | { Idle, "Idle" }, |
| 63 | { Connect, "Connect" }, |
| 64 | { Active, "Active" }, |
| 65 | { OpenSent, "OpenSent" }, |
| 66 | { OpenConfirm, "OpenConfirm" }, |
| 67 | { Established, "Established" }, |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 68 | { Clearing, "Clearing" }, |
| 69 | { Deleted, "Deleted" }, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 70 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 71 | const int bgp_status_msg_max = BGP_STATUS_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | |
| 73 | /* BGP message type string. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 74 | const char *bgp_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | { |
| 76 | NULL, |
| 77 | "OPEN", |
| 78 | "UPDATE", |
| 79 | "NOTIFICATION", |
| 80 | "KEEPALIVE", |
| 81 | "ROUTE-REFRESH", |
| 82 | "CAPABILITY" |
| 83 | }; |
| 84 | |
| 85 | /* message for BGP-4 Notify */ |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 86 | static const struct message bgp_notify_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 87 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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"}, |
| 95 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 96 | static const int bgp_notify_msg_max = BGP_NOTIFY_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 97 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 98 | static const struct message bgp_notify_head_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 99 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 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"} |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 104 | static const int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 105 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 106 | static const struct message bgp_notify_open_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 107 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 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"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 116 | static const int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 118 | static const struct message bgp_notify_update_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 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"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 132 | static const int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 134 | static const struct message bgp_notify_cease_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 135 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 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"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 144 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 145 | static const int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 147 | static const struct message bgp_notify_capability_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 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"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 152 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 153 | static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 154 | |
| 155 | /* Origin strings. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 156 | const char *bgp_origin_str[] = {"i","e","?"}; |
| 157 | const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"}; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
| 159 | /* Dump attribute. */ |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 160 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) |
| 162 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 163 | if (! attr) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 164 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 166 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP))) |
| 167 | snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); |
| 168 | |
| 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]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 172 | |
| 173 | #ifdef HAVE_IPV6 |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 174 | if (attr->extra) |
| 175 | { |
| 176 | char addrbuf[BUFSIZ]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 177 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 178 | /* Add MP case. */ |
| 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, |
| 183 | addrbuf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 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, |
| 188 | addrbuf, BUFSIZ)); |
| 189 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 190 | #endif /* HAVE_IPV6 */ |
| 191 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 192 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 193 | snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %d", |
| 194 | attr->local_pref); |
| 195 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 196 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 197 | snprintf (buf + strlen (buf), size - strlen (buf), ", metric %d", |
| 198 | attr->med); |
| 199 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 200 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | snprintf (buf + strlen (buf), size - strlen (buf), ", community %s", |
| 202 | community_str (attr->community)); |
| 203 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 204 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate"); |
| 206 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 207 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 208 | snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 209 | attr->extra->aggregator_as, |
| 210 | inet_ntoa (attr->extra->aggregator_addr)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 211 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 212 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 213 | snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 214 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 215 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 216 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | { |
| 218 | int i; |
| 219 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 220 | snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 221 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 222 | snprintf (buf + strlen (buf), size - strlen (buf), " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 223 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 224 | } |
| 225 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 226 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | snprintf (buf + strlen (buf), size - strlen (buf), ", path %s", |
| 228 | aspath_print (attr->aspath)); |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 229 | |
| 230 | if (strlen (buf) > 1) |
| 231 | return 1; |
| 232 | else |
| 233 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* dump notify packet */ |
| 237 | void |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 238 | bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, |
| 239 | const char *direct) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 240 | { |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 241 | const char *subcode_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | |
| 243 | subcode_str = ""; |
| 244 | |
| 245 | switch (bgp_notify->code) |
| 246 | { |
| 247 | case BGP_NOTIFY_HEADER_ERR: |
| 248 | subcode_str = LOOKUP (bgp_notify_head_msg, bgp_notify->subcode); |
| 249 | break; |
| 250 | case BGP_NOTIFY_OPEN_ERR: |
| 251 | subcode_str = LOOKUP (bgp_notify_open_msg, bgp_notify->subcode); |
| 252 | break; |
| 253 | case BGP_NOTIFY_UPDATE_ERR: |
| 254 | subcode_str = LOOKUP (bgp_notify_update_msg, bgp_notify->subcode); |
| 255 | break; |
| 256 | case BGP_NOTIFY_HOLD_ERR: |
| 257 | subcode_str = ""; |
| 258 | break; |
| 259 | case BGP_NOTIFY_FSM_ERR: |
| 260 | subcode_str = ""; |
| 261 | break; |
| 262 | case BGP_NOTIFY_CEASE: |
| 263 | subcode_str = LOOKUP (bgp_notify_cease_msg, bgp_notify->subcode); |
| 264 | break; |
| 265 | case BGP_NOTIFY_CAPABILITY_ERR: |
| 266 | subcode_str = LOOKUP (bgp_notify_capability_msg, bgp_notify->subcode); |
| 267 | break; |
| 268 | } |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 269 | |
| 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)) |
ajs | 557865c | 2004-12-08 19:59:11 +0000 | [diff] [blame] | 278 | plog_debug (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 : ""); |
| 284 | } |
| 285 | |
| 286 | /* Debug option setting interface. */ |
| 287 | unsigned long bgp_debug_option = 0; |
| 288 | |
| 289 | int |
| 290 | debug (unsigned int option) |
| 291 | { |
| 292 | return bgp_debug_option & option; |
| 293 | } |
| 294 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 295 | DEFUN (debug_bgp_as4, |
| 296 | debug_bgp_as4_cmd, |
| 297 | "debug bgp as4", |
| 298 | DEBUG_STR |
| 299 | BGP_STR |
| 300 | "BGP AS4 actions\n") |
| 301 | { |
| 302 | if (vty->node == CONFIG_NODE) |
| 303 | DEBUG_ON (as4, AS4); |
| 304 | else |
| 305 | { |
| 306 | TERM_DEBUG_ON (as4, AS4); |
| 307 | vty_out (vty, "BGP as4 debugging is on%s", VTY_NEWLINE); |
| 308 | } |
| 309 | return CMD_SUCCESS; |
| 310 | } |
| 311 | |
| 312 | DEFUN (no_debug_bgp_as4, |
| 313 | no_debug_bgp_as4_cmd, |
| 314 | "no debug bgp as4", |
| 315 | NO_STR |
| 316 | DEBUG_STR |
| 317 | BGP_STR |
| 318 | "BGP AS4 actions\n") |
| 319 | { |
| 320 | if (vty->node == CONFIG_NODE) |
| 321 | DEBUG_OFF (as4, AS4); |
| 322 | else |
| 323 | { |
| 324 | TERM_DEBUG_OFF (as4, AS4); |
| 325 | vty_out (vty, "BGP as4 debugging is off%s", VTY_NEWLINE); |
| 326 | } |
| 327 | return CMD_SUCCESS; |
| 328 | } |
| 329 | |
| 330 | ALIAS (no_debug_bgp_as4, |
| 331 | undebug_bgp_as4_cmd, |
| 332 | "undebug bgp as4", |
| 333 | UNDEBUG_STR |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 334 | BGP_STR |
| 335 | "BGP AS4 actions\n") |
| 336 | |
| 337 | DEFUN (debug_bgp_as4_segment, |
| 338 | debug_bgp_as4_segment_cmd, |
| 339 | "debug bgp as4 segment", |
| 340 | DEBUG_STR |
| 341 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame^] | 342 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 343 | "BGP AS4 aspath segment handling\n") |
| 344 | { |
| 345 | if (vty->node == CONFIG_NODE) |
| 346 | DEBUG_ON (as4, AS4_SEGMENT); |
| 347 | else |
| 348 | { |
| 349 | TERM_DEBUG_ON (as4, AS4_SEGMENT); |
| 350 | vty_out (vty, "BGP as4 segment debugging is on%s", VTY_NEWLINE); |
| 351 | } |
| 352 | return CMD_SUCCESS; |
| 353 | } |
| 354 | |
| 355 | DEFUN (no_debug_bgp_as4_segment, |
| 356 | no_debug_bgp_as4_segment_cmd, |
| 357 | "no debug bgp as4 segment", |
| 358 | NO_STR |
| 359 | DEBUG_STR |
| 360 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame^] | 361 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 362 | "BGP AS4 aspath segment handling\n") |
| 363 | { |
| 364 | if (vty->node == CONFIG_NODE) |
| 365 | DEBUG_OFF (as4, AS4_SEGMENT); |
| 366 | else |
| 367 | { |
| 368 | TERM_DEBUG_OFF (as4, AS4_SEGMENT); |
| 369 | vty_out (vty, "BGP as4 segment debugging is off%s", VTY_NEWLINE); |
| 370 | } |
| 371 | return CMD_SUCCESS; |
| 372 | } |
| 373 | |
| 374 | ALIAS (no_debug_bgp_as4_segment, |
| 375 | undebug_bgp_as4_segment_cmd, |
| 376 | "undebug bgp as4 segment", |
| 377 | UNDEBUG_STR |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 378 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame^] | 379 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 380 | "BGP AS4 aspath segment handling\n") |
| 381 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | DEFUN (debug_bgp_fsm, |
| 383 | debug_bgp_fsm_cmd, |
| 384 | "debug bgp fsm", |
| 385 | DEBUG_STR |
| 386 | BGP_STR |
| 387 | "BGP Finite State Machine\n") |
| 388 | { |
| 389 | if (vty->node == CONFIG_NODE) |
| 390 | DEBUG_ON (fsm, FSM); |
| 391 | else |
| 392 | { |
| 393 | TERM_DEBUG_ON (fsm, FSM); |
| 394 | vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE); |
| 395 | } |
| 396 | return CMD_SUCCESS; |
| 397 | } |
| 398 | |
| 399 | DEFUN (no_debug_bgp_fsm, |
| 400 | no_debug_bgp_fsm_cmd, |
| 401 | "no debug bgp fsm", |
| 402 | NO_STR |
| 403 | DEBUG_STR |
| 404 | BGP_STR |
| 405 | "Finite State Machine\n") |
| 406 | { |
| 407 | if (vty->node == CONFIG_NODE) |
| 408 | DEBUG_OFF (fsm, FSM); |
| 409 | else |
| 410 | { |
| 411 | TERM_DEBUG_OFF (fsm, FSM); |
| 412 | vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE); |
| 413 | } |
| 414 | return CMD_SUCCESS; |
| 415 | } |
| 416 | |
| 417 | ALIAS (no_debug_bgp_fsm, |
| 418 | undebug_bgp_fsm_cmd, |
| 419 | "undebug bgp fsm", |
| 420 | UNDEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 421 | BGP_STR |
| 422 | "Finite State Machine\n") |
| 423 | |
| 424 | DEFUN (debug_bgp_events, |
| 425 | debug_bgp_events_cmd, |
| 426 | "debug bgp events", |
| 427 | DEBUG_STR |
| 428 | BGP_STR |
| 429 | "BGP events\n") |
| 430 | { |
| 431 | if (vty->node == CONFIG_NODE) |
| 432 | DEBUG_ON (events, EVENTS); |
| 433 | else |
| 434 | { |
| 435 | TERM_DEBUG_ON (events, EVENTS); |
| 436 | vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE); |
| 437 | } |
| 438 | return CMD_SUCCESS; |
| 439 | } |
| 440 | |
| 441 | DEFUN (no_debug_bgp_events, |
| 442 | no_debug_bgp_events_cmd, |
| 443 | "no debug bgp events", |
| 444 | NO_STR |
| 445 | DEBUG_STR |
| 446 | BGP_STR |
| 447 | "BGP events\n") |
| 448 | { |
| 449 | if (vty->node == CONFIG_NODE) |
| 450 | DEBUG_OFF (events, EVENTS); |
| 451 | else |
| 452 | { |
| 453 | TERM_DEBUG_OFF (events, EVENTS); |
| 454 | vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE); |
| 455 | } |
| 456 | return CMD_SUCCESS; |
| 457 | } |
| 458 | |
| 459 | ALIAS (no_debug_bgp_events, |
| 460 | undebug_bgp_events_cmd, |
| 461 | "undebug bgp events", |
| 462 | UNDEBUG_STR |
| 463 | BGP_STR |
| 464 | "BGP events\n") |
| 465 | |
| 466 | DEFUN (debug_bgp_filter, |
| 467 | debug_bgp_filter_cmd, |
| 468 | "debug bgp filters", |
| 469 | DEBUG_STR |
| 470 | BGP_STR |
| 471 | "BGP filters\n") |
| 472 | { |
| 473 | if (vty->node == CONFIG_NODE) |
| 474 | DEBUG_ON (filter, FILTER); |
| 475 | else |
| 476 | { |
| 477 | TERM_DEBUG_ON (filter, FILTER); |
| 478 | vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE); |
| 479 | } |
| 480 | return CMD_SUCCESS; |
| 481 | } |
| 482 | |
| 483 | DEFUN (no_debug_bgp_filter, |
| 484 | no_debug_bgp_filter_cmd, |
| 485 | "no debug bgp filters", |
| 486 | NO_STR |
| 487 | DEBUG_STR |
| 488 | BGP_STR |
| 489 | "BGP filters\n") |
| 490 | { |
| 491 | if (vty->node == CONFIG_NODE) |
| 492 | DEBUG_OFF (filter, FILTER); |
| 493 | else |
| 494 | { |
| 495 | TERM_DEBUG_OFF (filter, FILTER); |
| 496 | vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE); |
| 497 | } |
| 498 | return CMD_SUCCESS; |
| 499 | } |
| 500 | |
| 501 | ALIAS (no_debug_bgp_filter, |
| 502 | undebug_bgp_filter_cmd, |
| 503 | "undebug bgp filters", |
| 504 | UNDEBUG_STR |
| 505 | BGP_STR |
| 506 | "BGP filters\n") |
| 507 | |
| 508 | DEFUN (debug_bgp_keepalive, |
| 509 | debug_bgp_keepalive_cmd, |
| 510 | "debug bgp keepalives", |
| 511 | DEBUG_STR |
| 512 | BGP_STR |
| 513 | "BGP keepalives\n") |
| 514 | { |
| 515 | if (vty->node == CONFIG_NODE) |
| 516 | DEBUG_ON (keepalive, KEEPALIVE); |
| 517 | else |
| 518 | { |
| 519 | TERM_DEBUG_ON (keepalive, KEEPALIVE); |
| 520 | vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 521 | } |
| 522 | return CMD_SUCCESS; |
| 523 | } |
| 524 | |
| 525 | DEFUN (no_debug_bgp_keepalive, |
| 526 | no_debug_bgp_keepalive_cmd, |
| 527 | "no debug bgp keepalives", |
| 528 | NO_STR |
| 529 | DEBUG_STR |
| 530 | BGP_STR |
| 531 | "BGP keepalives\n") |
| 532 | { |
| 533 | if (vty->node == CONFIG_NODE) |
| 534 | DEBUG_OFF (keepalive, KEEPALIVE); |
| 535 | else |
| 536 | { |
| 537 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 538 | vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE); |
| 539 | } |
| 540 | return CMD_SUCCESS; |
| 541 | } |
| 542 | |
| 543 | ALIAS (no_debug_bgp_keepalive, |
| 544 | undebug_bgp_keepalive_cmd, |
| 545 | "undebug bgp keepalives", |
| 546 | UNDEBUG_STR |
| 547 | BGP_STR |
| 548 | "BGP keepalives\n") |
| 549 | |
| 550 | DEFUN (debug_bgp_update, |
| 551 | debug_bgp_update_cmd, |
| 552 | "debug bgp updates", |
| 553 | DEBUG_STR |
| 554 | BGP_STR |
| 555 | "BGP updates\n") |
| 556 | { |
| 557 | if (vty->node == CONFIG_NODE) |
| 558 | { |
| 559 | DEBUG_ON (update, UPDATE_IN); |
| 560 | DEBUG_ON (update, UPDATE_OUT); |
| 561 | } |
| 562 | else |
| 563 | { |
| 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); |
| 567 | } |
| 568 | return CMD_SUCCESS; |
| 569 | } |
| 570 | |
| 571 | DEFUN (debug_bgp_update_direct, |
| 572 | debug_bgp_update_direct_cmd, |
| 573 | "debug bgp updates (in|out)", |
| 574 | DEBUG_STR |
| 575 | BGP_STR |
| 576 | "BGP updates\n" |
| 577 | "Inbound updates\n" |
| 578 | "Outbound updates\n") |
| 579 | { |
| 580 | if (vty->node == CONFIG_NODE) |
| 581 | { |
| 582 | if (strncmp ("i", argv[0], 1) == 0) |
| 583 | { |
| 584 | DEBUG_OFF (update, UPDATE_OUT); |
| 585 | DEBUG_ON (update, UPDATE_IN); |
| 586 | } |
| 587 | else |
| 588 | { |
| 589 | DEBUG_OFF (update, UPDATE_IN); |
| 590 | DEBUG_ON (update, UPDATE_OUT); |
| 591 | } |
| 592 | } |
| 593 | else |
| 594 | { |
| 595 | if (strncmp ("i", argv[0], 1) == 0) |
| 596 | { |
| 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); |
| 600 | } |
| 601 | else |
| 602 | { |
| 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); |
| 606 | } |
| 607 | } |
| 608 | return CMD_SUCCESS; |
| 609 | } |
| 610 | |
| 611 | DEFUN (no_debug_bgp_update, |
| 612 | no_debug_bgp_update_cmd, |
| 613 | "no debug bgp updates", |
| 614 | NO_STR |
| 615 | DEBUG_STR |
| 616 | BGP_STR |
| 617 | "BGP updates\n") |
| 618 | { |
| 619 | if (vty->node == CONFIG_NODE) |
| 620 | { |
| 621 | DEBUG_OFF (update, UPDATE_IN); |
| 622 | DEBUG_OFF (update, UPDATE_OUT); |
| 623 | } |
| 624 | else |
| 625 | { |
| 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); |
| 629 | } |
| 630 | return CMD_SUCCESS; |
| 631 | } |
| 632 | |
| 633 | ALIAS (no_debug_bgp_update, |
| 634 | undebug_bgp_update_cmd, |
| 635 | "undebug bgp updates", |
| 636 | UNDEBUG_STR |
| 637 | BGP_STR |
| 638 | "BGP updates\n") |
| 639 | |
| 640 | DEFUN (debug_bgp_normal, |
| 641 | debug_bgp_normal_cmd, |
| 642 | "debug bgp", |
| 643 | DEBUG_STR |
| 644 | BGP_STR) |
| 645 | { |
| 646 | if (vty->node == CONFIG_NODE) |
| 647 | DEBUG_ON (normal, NORMAL); |
| 648 | else |
| 649 | { |
| 650 | TERM_DEBUG_ON (normal, NORMAL); |
| 651 | vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE); |
| 652 | } |
| 653 | return CMD_SUCCESS; |
| 654 | } |
| 655 | |
| 656 | DEFUN (no_debug_bgp_normal, |
| 657 | no_debug_bgp_normal_cmd, |
| 658 | "no debug bgp", |
| 659 | NO_STR |
| 660 | DEBUG_STR |
| 661 | BGP_STR) |
| 662 | { |
| 663 | if (vty->node == CONFIG_NODE) |
| 664 | DEBUG_OFF (normal, NORMAL); |
| 665 | else |
| 666 | { |
| 667 | TERM_DEBUG_OFF (normal, NORMAL); |
| 668 | vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE); |
| 669 | } |
| 670 | return CMD_SUCCESS; |
| 671 | } |
| 672 | |
| 673 | ALIAS (no_debug_bgp_normal, |
| 674 | undebug_bgp_normal_cmd, |
| 675 | "undebug bgp", |
| 676 | UNDEBUG_STR |
| 677 | BGP_STR) |
| 678 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 679 | DEFUN (debug_bgp_zebra, |
| 680 | debug_bgp_zebra_cmd, |
| 681 | "debug bgp zebra", |
| 682 | DEBUG_STR |
| 683 | BGP_STR |
| 684 | "BGP Zebra messages\n") |
| 685 | { |
| 686 | if (vty->node == CONFIG_NODE) |
| 687 | DEBUG_ON (zebra, ZEBRA); |
| 688 | else |
| 689 | { |
| 690 | TERM_DEBUG_ON (zebra, ZEBRA); |
| 691 | vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE); |
| 692 | } |
| 693 | return CMD_SUCCESS; |
| 694 | } |
| 695 | |
| 696 | DEFUN (no_debug_bgp_zebra, |
| 697 | no_debug_bgp_zebra_cmd, |
| 698 | "no debug bgp zebra", |
| 699 | NO_STR |
| 700 | DEBUG_STR |
| 701 | BGP_STR |
| 702 | "BGP Zebra messages\n") |
| 703 | { |
| 704 | if (vty->node == CONFIG_NODE) |
| 705 | DEBUG_OFF (zebra, ZEBRA); |
| 706 | else |
| 707 | { |
| 708 | TERM_DEBUG_OFF (zebra, ZEBRA); |
| 709 | vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE); |
| 710 | } |
| 711 | return CMD_SUCCESS; |
| 712 | } |
| 713 | |
| 714 | ALIAS (no_debug_bgp_zebra, |
| 715 | undebug_bgp_zebra_cmd, |
| 716 | "undebug bgp zebra", |
| 717 | UNDEBUG_STR |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 718 | BGP_STR |
| 719 | "BGP Zebra messages\n") |
| 720 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | DEFUN (no_debug_bgp_all, |
| 722 | no_debug_bgp_all_cmd, |
| 723 | "no debug all bgp", |
| 724 | NO_STR |
| 725 | DEBUG_STR |
| 726 | "Enable all debugging\n" |
| 727 | BGP_STR) |
| 728 | { |
| 729 | TERM_DEBUG_OFF (normal, NORMAL); |
| 730 | TERM_DEBUG_OFF (events, EVENTS); |
| 731 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 732 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 733 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 734 | TERM_DEBUG_OFF (as4, AS4); |
| 735 | TERM_DEBUG_OFF (as4, AS4_SEGMENT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 736 | TERM_DEBUG_OFF (fsm, FSM); |
| 737 | TERM_DEBUG_OFF (filter, FILTER); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 738 | TERM_DEBUG_OFF (zebra, ZEBRA); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 739 | vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE); |
| 740 | |
| 741 | return CMD_SUCCESS; |
| 742 | } |
| 743 | |
| 744 | ALIAS (no_debug_bgp_all, |
| 745 | undebug_bgp_all_cmd, |
| 746 | "undebug all bgp", |
| 747 | UNDEBUG_STR |
| 748 | "Enable all debugging\n" |
| 749 | BGP_STR) |
| 750 | |
| 751 | DEFUN (show_debugging_bgp, |
| 752 | show_debugging_bgp_cmd, |
| 753 | "show debugging bgp", |
| 754 | SHOW_STR |
| 755 | DEBUG_STR |
| 756 | BGP_STR) |
| 757 | { |
| 758 | vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE); |
| 759 | |
| 760 | if (BGP_DEBUG (normal, NORMAL)) |
| 761 | vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE); |
| 762 | if (BGP_DEBUG (events, EVENTS)) |
| 763 | vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE); |
| 764 | if (BGP_DEBUG (keepalive, KEEPALIVE)) |
| 765 | vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 766 | if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT)) |
| 767 | vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE); |
| 768 | else if (BGP_DEBUG (update, UPDATE_IN)) |
| 769 | vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 770 | else if (BGP_DEBUG (update, UPDATE_OUT)) |
| 771 | vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 772 | if (BGP_DEBUG (fsm, FSM)) |
| 773 | vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE); |
| 774 | if (BGP_DEBUG (filter, FILTER)) |
| 775 | vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 776 | if (BGP_DEBUG (zebra, ZEBRA)) |
| 777 | vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 778 | if (BGP_DEBUG (as4, AS4)) |
| 779 | vty_out (vty, " BGP as4 debugging is on%s", VTY_NEWLINE); |
| 780 | if (BGP_DEBUG (as4, AS4_SEGMENT)) |
| 781 | vty_out (vty, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 782 | vty_out (vty, "%s", VTY_NEWLINE); |
| 783 | return CMD_SUCCESS; |
| 784 | } |
| 785 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 786 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | bgp_config_write_debug (struct vty *vty) |
| 788 | { |
| 789 | int write = 0; |
| 790 | |
| 791 | if (CONF_BGP_DEBUG (normal, NORMAL)) |
| 792 | { |
| 793 | vty_out (vty, "debug bgp%s", VTY_NEWLINE); |
| 794 | write++; |
| 795 | } |
| 796 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 797 | if (CONF_BGP_DEBUG (as4, AS4)) |
| 798 | { |
| 799 | vty_out (vty, "debug bgp as4%s", VTY_NEWLINE); |
| 800 | write++; |
| 801 | } |
| 802 | |
| 803 | if (CONF_BGP_DEBUG (as4, AS4_SEGMENT)) |
| 804 | { |
| 805 | vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE); |
| 806 | write++; |
| 807 | } |
| 808 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | if (CONF_BGP_DEBUG (events, EVENTS)) |
| 810 | { |
| 811 | vty_out (vty, "debug bgp events%s", VTY_NEWLINE); |
| 812 | write++; |
| 813 | } |
| 814 | |
| 815 | if (CONF_BGP_DEBUG (keepalive, KEEPALIVE)) |
| 816 | { |
| 817 | vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE); |
| 818 | write++; |
| 819 | } |
| 820 | |
| 821 | if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 822 | { |
| 823 | vty_out (vty, "debug bgp updates%s", VTY_NEWLINE); |
| 824 | write++; |
| 825 | } |
| 826 | else if (CONF_BGP_DEBUG (update, UPDATE_IN)) |
| 827 | { |
| 828 | vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE); |
| 829 | write++; |
| 830 | } |
| 831 | else if (CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 832 | { |
| 833 | vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE); |
| 834 | write++; |
| 835 | } |
| 836 | |
| 837 | if (CONF_BGP_DEBUG (fsm, FSM)) |
| 838 | { |
| 839 | vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE); |
| 840 | write++; |
| 841 | } |
| 842 | |
| 843 | if (CONF_BGP_DEBUG (filter, FILTER)) |
| 844 | { |
| 845 | vty_out (vty, "debug bgp filters%s", VTY_NEWLINE); |
| 846 | write++; |
| 847 | } |
| 848 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 849 | if (CONF_BGP_DEBUG (zebra, ZEBRA)) |
| 850 | { |
| 851 | vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE); |
| 852 | write++; |
| 853 | } |
| 854 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 855 | return write; |
| 856 | } |
| 857 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 858 | static struct cmd_node debug_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | { |
| 860 | DEBUG_NODE, |
| 861 | "", |
| 862 | 1 |
| 863 | }; |
| 864 | |
| 865 | void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 866 | bgp_debug_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 867 | { |
| 868 | install_node (&debug_node, bgp_config_write_debug); |
| 869 | |
| 870 | install_element (ENABLE_NODE, &show_debugging_bgp_cmd); |
| 871 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 872 | install_element (ENABLE_NODE, &debug_bgp_as4_cmd); |
| 873 | install_element (CONFIG_NODE, &debug_bgp_as4_cmd); |
| 874 | install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd); |
| 875 | install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd); |
| 876 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | install_element (ENABLE_NODE, &debug_bgp_fsm_cmd); |
| 878 | install_element (CONFIG_NODE, &debug_bgp_fsm_cmd); |
| 879 | install_element (ENABLE_NODE, &debug_bgp_events_cmd); |
| 880 | install_element (CONFIG_NODE, &debug_bgp_events_cmd); |
| 881 | install_element (ENABLE_NODE, &debug_bgp_filter_cmd); |
| 882 | install_element (CONFIG_NODE, &debug_bgp_filter_cmd); |
| 883 | install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd); |
| 884 | install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd); |
| 885 | install_element (ENABLE_NODE, &debug_bgp_update_cmd); |
| 886 | install_element (CONFIG_NODE, &debug_bgp_update_cmd); |
| 887 | install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd); |
| 888 | install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd); |
| 889 | install_element (ENABLE_NODE, &debug_bgp_normal_cmd); |
| 890 | install_element (CONFIG_NODE, &debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 891 | install_element (ENABLE_NODE, &debug_bgp_zebra_cmd); |
| 892 | install_element (CONFIG_NODE, &debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 893 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 894 | install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd); |
| 895 | install_element (ENABLE_NODE, &undebug_bgp_as4_cmd); |
| 896 | install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd); |
| 897 | install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd); |
| 898 | install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd); |
| 899 | install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd); |
| 900 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd); |
| 902 | install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd); |
| 903 | install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd); |
| 904 | install_element (ENABLE_NODE, &no_debug_bgp_events_cmd); |
| 905 | install_element (ENABLE_NODE, &undebug_bgp_events_cmd); |
| 906 | install_element (CONFIG_NODE, &no_debug_bgp_events_cmd); |
| 907 | install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd); |
| 908 | install_element (ENABLE_NODE, &undebug_bgp_filter_cmd); |
| 909 | install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd); |
| 910 | install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd); |
| 911 | install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd); |
| 912 | install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd); |
| 913 | install_element (ENABLE_NODE, &no_debug_bgp_update_cmd); |
| 914 | install_element (ENABLE_NODE, &undebug_bgp_update_cmd); |
| 915 | install_element (CONFIG_NODE, &no_debug_bgp_update_cmd); |
| 916 | install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd); |
| 917 | install_element (ENABLE_NODE, &undebug_bgp_normal_cmd); |
| 918 | install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 919 | install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd); |
| 920 | install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd); |
| 921 | install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 922 | install_element (ENABLE_NODE, &no_debug_bgp_all_cmd); |
| 923 | install_element (ENABLE_NODE, &undebug_bgp_all_cmd); |
| 924 | } |