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 | |
| 39 | unsigned long conf_bgp_debug_fsm; |
| 40 | unsigned long conf_bgp_debug_events; |
| 41 | unsigned long conf_bgp_debug_packet; |
| 42 | unsigned long conf_bgp_debug_filter; |
| 43 | unsigned long conf_bgp_debug_keepalive; |
| 44 | unsigned long conf_bgp_debug_update; |
| 45 | unsigned long conf_bgp_debug_normal; |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 46 | unsigned long conf_bgp_debug_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 47 | |
| 48 | unsigned long term_bgp_debug_fsm; |
| 49 | unsigned long term_bgp_debug_events; |
| 50 | unsigned long term_bgp_debug_packet; |
| 51 | unsigned long term_bgp_debug_filter; |
| 52 | unsigned long term_bgp_debug_keepalive; |
| 53 | unsigned long term_bgp_debug_update; |
| 54 | unsigned long term_bgp_debug_normal; |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 55 | unsigned long term_bgp_debug_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | |
| 57 | /* messages for BGP-4 status */ |
| 58 | struct message bgp_status_msg[] = |
| 59 | { |
| 60 | { 0, "null" }, |
| 61 | { Idle, "Idle" }, |
| 62 | { Connect, "Connect" }, |
| 63 | { Active, "Active" }, |
| 64 | { OpenSent, "OpenSent" }, |
| 65 | { OpenConfirm, "OpenConfirm" }, |
| 66 | { Established, "Established" }, |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 67 | { Clearing, "Clearing" }, |
| 68 | { Deleted, "Deleted" }, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | }; |
| 70 | int bgp_status_msg_max = BGP_STATUS_MAX; |
| 71 | |
| 72 | /* BGP message type string. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 73 | const char *bgp_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | { |
| 75 | NULL, |
| 76 | "OPEN", |
| 77 | "UPDATE", |
| 78 | "NOTIFICATION", |
| 79 | "KEEPALIVE", |
| 80 | "ROUTE-REFRESH", |
| 81 | "CAPABILITY" |
| 82 | }; |
| 83 | |
| 84 | /* message for BGP-4 Notify */ |
| 85 | struct message bgp_notify_msg[] = |
| 86 | { |
| 87 | { 0, "" }, |
| 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 | }; |
| 96 | int bgp_notify_msg_max = BGP_NOTIFY_MAX; |
| 97 | |
| 98 | struct message bgp_notify_head_msg[] = |
| 99 | { |
| 100 | { 0, "null"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 101 | { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"}, |
| 102 | { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"}, |
| 103 | { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"} |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 104 | }; |
| 105 | int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX; |
| 106 | |
| 107 | struct message bgp_notify_open_msg[] = |
| 108 | { |
| 109 | { 0, "null" }, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 110 | { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" }, |
| 111 | { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"}, |
| 112 | { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"}, |
| 113 | { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"}, |
| 114 | { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"}, |
| 115 | { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, |
| 116 | { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | }; |
| 118 | int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX; |
| 119 | |
| 120 | struct message bgp_notify_update_msg[] = |
| 121 | { |
| 122 | { 0, "null"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 123 | { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"}, |
| 124 | { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"}, |
| 125 | { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"}, |
| 126 | { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"}, |
| 127 | { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"}, |
| 128 | { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"}, |
| 129 | { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"}, |
| 130 | { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"}, |
| 131 | { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"}, |
| 132 | { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"}, |
| 133 | { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | }; |
| 135 | int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX; |
| 136 | |
| 137 | struct message bgp_notify_cease_msg[] = |
| 138 | { |
| 139 | { 0, ""}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 140 | { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"}, |
| 141 | { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"}, |
| 142 | { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"}, |
| 143 | { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"}, |
| 144 | { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"}, |
| 145 | { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"}, |
| 146 | { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"}, |
| 147 | { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | }; |
| 149 | int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX; |
| 150 | |
| 151 | struct message bgp_notify_capability_msg[] = |
| 152 | { |
| 153 | { 0, "null" }, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 154 | { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" }, |
| 155 | { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"}, |
| 156 | { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | }; |
| 158 | int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX; |
| 159 | |
| 160 | /* Origin strings. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 161 | const char *bgp_origin_str[] = {"i","e","?"}; |
| 162 | const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"}; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 163 | |
| 164 | /* Dump attribute. */ |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 165 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 166 | bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) |
| 167 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 168 | if (! attr) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 169 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 170 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 171 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP))) |
| 172 | snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); |
| 173 | |
| 174 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN))) |
| 175 | snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", |
| 176 | bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 177 | |
| 178 | #ifdef HAVE_IPV6 |
| 179 | { |
| 180 | char addrbuf[BUFSIZ]; |
| 181 | |
| 182 | /* Add MP case. */ |
| 183 | if (attr->mp_nexthop_len == 16 || attr->mp_nexthop_len == 32) |
| 184 | snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", |
| 185 | inet_ntop (AF_INET6, &attr->mp_nexthop_global, |
| 186 | addrbuf, BUFSIZ)); |
| 187 | |
| 188 | if (attr->mp_nexthop_len == 32) |
| 189 | snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", |
| 190 | inet_ntop (AF_INET6, &attr->mp_nexthop_local, |
| 191 | addrbuf, BUFSIZ)); |
| 192 | } |
| 193 | #endif /* HAVE_IPV6 */ |
| 194 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 195 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %d", |
| 197 | attr->local_pref); |
| 198 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 199 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | snprintf (buf + strlen (buf), size - strlen (buf), ", metric %d", |
| 201 | attr->med); |
| 202 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 203 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | snprintf (buf + strlen (buf), size - strlen (buf), ", community %s", |
| 205 | community_str (attr->community)); |
| 206 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 207 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 208 | snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate"); |
| 209 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 210 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 211 | snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s", |
| 212 | attr->aggregator_as, inet_ntoa (attr->aggregator_addr)); |
| 213 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 214 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 215 | snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s", |
| 216 | inet_ntoa (attr->originator_id)); |
| 217 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 218 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 219 | { |
| 220 | int i; |
| 221 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 222 | snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 223 | for (i = 0; i < attr->cluster->length / 4; i++) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 224 | snprintf (buf + strlen (buf), size - strlen (buf), " %s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 225 | inet_ntoa (attr->cluster->list[i])); |
| 226 | } |
| 227 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 228 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 229 | snprintf (buf + strlen (buf), size - strlen (buf), ", path %s", |
| 230 | aspath_print (attr->aspath)); |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 231 | |
| 232 | if (strlen (buf) > 1) |
| 233 | return 1; |
| 234 | else |
| 235 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* dump notify packet */ |
| 239 | void |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 240 | bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, |
| 241 | const char *direct) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | { |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 243 | const char *subcode_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | |
| 245 | subcode_str = ""; |
| 246 | |
| 247 | switch (bgp_notify->code) |
| 248 | { |
| 249 | case BGP_NOTIFY_HEADER_ERR: |
| 250 | subcode_str = LOOKUP (bgp_notify_head_msg, bgp_notify->subcode); |
| 251 | break; |
| 252 | case BGP_NOTIFY_OPEN_ERR: |
| 253 | subcode_str = LOOKUP (bgp_notify_open_msg, bgp_notify->subcode); |
| 254 | break; |
| 255 | case BGP_NOTIFY_UPDATE_ERR: |
| 256 | subcode_str = LOOKUP (bgp_notify_update_msg, bgp_notify->subcode); |
| 257 | break; |
| 258 | case BGP_NOTIFY_HOLD_ERR: |
| 259 | subcode_str = ""; |
| 260 | break; |
| 261 | case BGP_NOTIFY_FSM_ERR: |
| 262 | subcode_str = ""; |
| 263 | break; |
| 264 | case BGP_NOTIFY_CEASE: |
| 265 | subcode_str = LOOKUP (bgp_notify_cease_msg, bgp_notify->subcode); |
| 266 | break; |
| 267 | case BGP_NOTIFY_CAPABILITY_ERR: |
| 268 | subcode_str = LOOKUP (bgp_notify_capability_msg, bgp_notify->subcode); |
| 269 | break; |
| 270 | } |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 271 | |
| 272 | if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) |
| 273 | zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s", |
| 274 | strcmp (direct, "received") == 0 ? "received from" : "sent to", |
| 275 | peer->host, bgp_notify->code, bgp_notify->subcode, |
| 276 | LOOKUP (bgp_notify_msg, bgp_notify->code), |
| 277 | subcode_str, bgp_notify->length, |
| 278 | bgp_notify->data ? bgp_notify->data : ""); |
| 279 | else if (BGP_DEBUG (normal, NORMAL)) |
ajs | 557865c | 2004-12-08 19:59:11 +0000 | [diff] [blame] | 280 | 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] | 281 | peer ? peer->host : "", |
| 282 | direct, bgp_notify->code, bgp_notify->subcode, |
| 283 | LOOKUP (bgp_notify_msg, bgp_notify->code), |
| 284 | subcode_str, bgp_notify->length, |
| 285 | bgp_notify->data ? bgp_notify->data : ""); |
| 286 | } |
| 287 | |
| 288 | /* Debug option setting interface. */ |
| 289 | unsigned long bgp_debug_option = 0; |
| 290 | |
| 291 | int |
| 292 | debug (unsigned int option) |
| 293 | { |
| 294 | return bgp_debug_option & option; |
| 295 | } |
| 296 | |
| 297 | DEFUN (debug_bgp_fsm, |
| 298 | debug_bgp_fsm_cmd, |
| 299 | "debug bgp fsm", |
| 300 | DEBUG_STR |
| 301 | BGP_STR |
| 302 | "BGP Finite State Machine\n") |
| 303 | { |
| 304 | if (vty->node == CONFIG_NODE) |
| 305 | DEBUG_ON (fsm, FSM); |
| 306 | else |
| 307 | { |
| 308 | TERM_DEBUG_ON (fsm, FSM); |
| 309 | vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE); |
| 310 | } |
| 311 | return CMD_SUCCESS; |
| 312 | } |
| 313 | |
| 314 | DEFUN (no_debug_bgp_fsm, |
| 315 | no_debug_bgp_fsm_cmd, |
| 316 | "no debug bgp fsm", |
| 317 | NO_STR |
| 318 | DEBUG_STR |
| 319 | BGP_STR |
| 320 | "Finite State Machine\n") |
| 321 | { |
| 322 | if (vty->node == CONFIG_NODE) |
| 323 | DEBUG_OFF (fsm, FSM); |
| 324 | else |
| 325 | { |
| 326 | TERM_DEBUG_OFF (fsm, FSM); |
| 327 | vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE); |
| 328 | } |
| 329 | return CMD_SUCCESS; |
| 330 | } |
| 331 | |
| 332 | ALIAS (no_debug_bgp_fsm, |
| 333 | undebug_bgp_fsm_cmd, |
| 334 | "undebug bgp fsm", |
| 335 | UNDEBUG_STR |
| 336 | DEBUG_STR |
| 337 | BGP_STR |
| 338 | "Finite State Machine\n") |
| 339 | |
| 340 | DEFUN (debug_bgp_events, |
| 341 | debug_bgp_events_cmd, |
| 342 | "debug bgp events", |
| 343 | DEBUG_STR |
| 344 | BGP_STR |
| 345 | "BGP events\n") |
| 346 | { |
| 347 | if (vty->node == CONFIG_NODE) |
| 348 | DEBUG_ON (events, EVENTS); |
| 349 | else |
| 350 | { |
| 351 | TERM_DEBUG_ON (events, EVENTS); |
| 352 | vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE); |
| 353 | } |
| 354 | return CMD_SUCCESS; |
| 355 | } |
| 356 | |
| 357 | DEFUN (no_debug_bgp_events, |
| 358 | no_debug_bgp_events_cmd, |
| 359 | "no debug bgp events", |
| 360 | NO_STR |
| 361 | DEBUG_STR |
| 362 | BGP_STR |
| 363 | "BGP events\n") |
| 364 | { |
| 365 | if (vty->node == CONFIG_NODE) |
| 366 | DEBUG_OFF (events, EVENTS); |
| 367 | else |
| 368 | { |
| 369 | TERM_DEBUG_OFF (events, EVENTS); |
| 370 | vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE); |
| 371 | } |
| 372 | return CMD_SUCCESS; |
| 373 | } |
| 374 | |
| 375 | ALIAS (no_debug_bgp_events, |
| 376 | undebug_bgp_events_cmd, |
| 377 | "undebug bgp events", |
| 378 | UNDEBUG_STR |
| 379 | BGP_STR |
| 380 | "BGP events\n") |
| 381 | |
| 382 | DEFUN (debug_bgp_filter, |
| 383 | debug_bgp_filter_cmd, |
| 384 | "debug bgp filters", |
| 385 | DEBUG_STR |
| 386 | BGP_STR |
| 387 | "BGP filters\n") |
| 388 | { |
| 389 | if (vty->node == CONFIG_NODE) |
| 390 | DEBUG_ON (filter, FILTER); |
| 391 | else |
| 392 | { |
| 393 | TERM_DEBUG_ON (filter, FILTER); |
| 394 | vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE); |
| 395 | } |
| 396 | return CMD_SUCCESS; |
| 397 | } |
| 398 | |
| 399 | DEFUN (no_debug_bgp_filter, |
| 400 | no_debug_bgp_filter_cmd, |
| 401 | "no debug bgp filters", |
| 402 | NO_STR |
| 403 | DEBUG_STR |
| 404 | BGP_STR |
| 405 | "BGP filters\n") |
| 406 | { |
| 407 | if (vty->node == CONFIG_NODE) |
| 408 | DEBUG_OFF (filter, FILTER); |
| 409 | else |
| 410 | { |
| 411 | TERM_DEBUG_OFF (filter, FILTER); |
| 412 | vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE); |
| 413 | } |
| 414 | return CMD_SUCCESS; |
| 415 | } |
| 416 | |
| 417 | ALIAS (no_debug_bgp_filter, |
| 418 | undebug_bgp_filter_cmd, |
| 419 | "undebug bgp filters", |
| 420 | UNDEBUG_STR |
| 421 | BGP_STR |
| 422 | "BGP filters\n") |
| 423 | |
| 424 | DEFUN (debug_bgp_keepalive, |
| 425 | debug_bgp_keepalive_cmd, |
| 426 | "debug bgp keepalives", |
| 427 | DEBUG_STR |
| 428 | BGP_STR |
| 429 | "BGP keepalives\n") |
| 430 | { |
| 431 | if (vty->node == CONFIG_NODE) |
| 432 | DEBUG_ON (keepalive, KEEPALIVE); |
| 433 | else |
| 434 | { |
| 435 | TERM_DEBUG_ON (keepalive, KEEPALIVE); |
| 436 | vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 437 | } |
| 438 | return CMD_SUCCESS; |
| 439 | } |
| 440 | |
| 441 | DEFUN (no_debug_bgp_keepalive, |
| 442 | no_debug_bgp_keepalive_cmd, |
| 443 | "no debug bgp keepalives", |
| 444 | NO_STR |
| 445 | DEBUG_STR |
| 446 | BGP_STR |
| 447 | "BGP keepalives\n") |
| 448 | { |
| 449 | if (vty->node == CONFIG_NODE) |
| 450 | DEBUG_OFF (keepalive, KEEPALIVE); |
| 451 | else |
| 452 | { |
| 453 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 454 | vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE); |
| 455 | } |
| 456 | return CMD_SUCCESS; |
| 457 | } |
| 458 | |
| 459 | ALIAS (no_debug_bgp_keepalive, |
| 460 | undebug_bgp_keepalive_cmd, |
| 461 | "undebug bgp keepalives", |
| 462 | UNDEBUG_STR |
| 463 | BGP_STR |
| 464 | "BGP keepalives\n") |
| 465 | |
| 466 | DEFUN (debug_bgp_update, |
| 467 | debug_bgp_update_cmd, |
| 468 | "debug bgp updates", |
| 469 | DEBUG_STR |
| 470 | BGP_STR |
| 471 | "BGP updates\n") |
| 472 | { |
| 473 | if (vty->node == CONFIG_NODE) |
| 474 | { |
| 475 | DEBUG_ON (update, UPDATE_IN); |
| 476 | DEBUG_ON (update, UPDATE_OUT); |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | TERM_DEBUG_ON (update, UPDATE_IN); |
| 481 | TERM_DEBUG_ON (update, UPDATE_OUT); |
| 482 | vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE); |
| 483 | } |
| 484 | return CMD_SUCCESS; |
| 485 | } |
| 486 | |
| 487 | DEFUN (debug_bgp_update_direct, |
| 488 | debug_bgp_update_direct_cmd, |
| 489 | "debug bgp updates (in|out)", |
| 490 | DEBUG_STR |
| 491 | BGP_STR |
| 492 | "BGP updates\n" |
| 493 | "Inbound updates\n" |
| 494 | "Outbound updates\n") |
| 495 | { |
| 496 | if (vty->node == CONFIG_NODE) |
| 497 | { |
| 498 | if (strncmp ("i", argv[0], 1) == 0) |
| 499 | { |
| 500 | DEBUG_OFF (update, UPDATE_OUT); |
| 501 | DEBUG_ON (update, UPDATE_IN); |
| 502 | } |
| 503 | else |
| 504 | { |
| 505 | DEBUG_OFF (update, UPDATE_IN); |
| 506 | DEBUG_ON (update, UPDATE_OUT); |
| 507 | } |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | if (strncmp ("i", argv[0], 1) == 0) |
| 512 | { |
| 513 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
| 514 | TERM_DEBUG_ON (update, UPDATE_IN); |
| 515 | vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 516 | } |
| 517 | else |
| 518 | { |
| 519 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 520 | TERM_DEBUG_ON (update, UPDATE_OUT); |
| 521 | vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 522 | } |
| 523 | } |
| 524 | return CMD_SUCCESS; |
| 525 | } |
| 526 | |
| 527 | DEFUN (no_debug_bgp_update, |
| 528 | no_debug_bgp_update_cmd, |
| 529 | "no debug bgp updates", |
| 530 | NO_STR |
| 531 | DEBUG_STR |
| 532 | BGP_STR |
| 533 | "BGP updates\n") |
| 534 | { |
| 535 | if (vty->node == CONFIG_NODE) |
| 536 | { |
| 537 | DEBUG_OFF (update, UPDATE_IN); |
| 538 | DEBUG_OFF (update, UPDATE_OUT); |
| 539 | } |
| 540 | else |
| 541 | { |
| 542 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 543 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
| 544 | vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE); |
| 545 | } |
| 546 | return CMD_SUCCESS; |
| 547 | } |
| 548 | |
| 549 | ALIAS (no_debug_bgp_update, |
| 550 | undebug_bgp_update_cmd, |
| 551 | "undebug bgp updates", |
| 552 | UNDEBUG_STR |
| 553 | BGP_STR |
| 554 | "BGP updates\n") |
| 555 | |
| 556 | DEFUN (debug_bgp_normal, |
| 557 | debug_bgp_normal_cmd, |
| 558 | "debug bgp", |
| 559 | DEBUG_STR |
| 560 | BGP_STR) |
| 561 | { |
| 562 | if (vty->node == CONFIG_NODE) |
| 563 | DEBUG_ON (normal, NORMAL); |
| 564 | else |
| 565 | { |
| 566 | TERM_DEBUG_ON (normal, NORMAL); |
| 567 | vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE); |
| 568 | } |
| 569 | return CMD_SUCCESS; |
| 570 | } |
| 571 | |
| 572 | DEFUN (no_debug_bgp_normal, |
| 573 | no_debug_bgp_normal_cmd, |
| 574 | "no debug bgp", |
| 575 | NO_STR |
| 576 | DEBUG_STR |
| 577 | BGP_STR) |
| 578 | { |
| 579 | if (vty->node == CONFIG_NODE) |
| 580 | DEBUG_OFF (normal, NORMAL); |
| 581 | else |
| 582 | { |
| 583 | TERM_DEBUG_OFF (normal, NORMAL); |
| 584 | vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE); |
| 585 | } |
| 586 | return CMD_SUCCESS; |
| 587 | } |
| 588 | |
| 589 | ALIAS (no_debug_bgp_normal, |
| 590 | undebug_bgp_normal_cmd, |
| 591 | "undebug bgp", |
| 592 | UNDEBUG_STR |
| 593 | BGP_STR) |
| 594 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 595 | DEFUN (debug_bgp_zebra, |
| 596 | debug_bgp_zebra_cmd, |
| 597 | "debug bgp zebra", |
| 598 | DEBUG_STR |
| 599 | BGP_STR |
| 600 | "BGP Zebra messages\n") |
| 601 | { |
| 602 | if (vty->node == CONFIG_NODE) |
| 603 | DEBUG_ON (zebra, ZEBRA); |
| 604 | else |
| 605 | { |
| 606 | TERM_DEBUG_ON (zebra, ZEBRA); |
| 607 | vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE); |
| 608 | } |
| 609 | return CMD_SUCCESS; |
| 610 | } |
| 611 | |
| 612 | DEFUN (no_debug_bgp_zebra, |
| 613 | no_debug_bgp_zebra_cmd, |
| 614 | "no debug bgp zebra", |
| 615 | NO_STR |
| 616 | DEBUG_STR |
| 617 | BGP_STR |
| 618 | "BGP Zebra messages\n") |
| 619 | { |
| 620 | if (vty->node == CONFIG_NODE) |
| 621 | DEBUG_OFF (zebra, ZEBRA); |
| 622 | else |
| 623 | { |
| 624 | TERM_DEBUG_OFF (zebra, ZEBRA); |
| 625 | vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE); |
| 626 | } |
| 627 | return CMD_SUCCESS; |
| 628 | } |
| 629 | |
| 630 | ALIAS (no_debug_bgp_zebra, |
| 631 | undebug_bgp_zebra_cmd, |
| 632 | "undebug bgp zebra", |
| 633 | UNDEBUG_STR |
| 634 | DEBUG_STR |
| 635 | BGP_STR |
| 636 | "BGP Zebra messages\n") |
| 637 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 638 | DEFUN (no_debug_bgp_all, |
| 639 | no_debug_bgp_all_cmd, |
| 640 | "no debug all bgp", |
| 641 | NO_STR |
| 642 | DEBUG_STR |
| 643 | "Enable all debugging\n" |
| 644 | BGP_STR) |
| 645 | { |
| 646 | TERM_DEBUG_OFF (normal, NORMAL); |
| 647 | TERM_DEBUG_OFF (events, EVENTS); |
| 648 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 649 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 650 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
| 651 | TERM_DEBUG_OFF (fsm, FSM); |
| 652 | TERM_DEBUG_OFF (filter, FILTER); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 653 | TERM_DEBUG_OFF (zebra, ZEBRA); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE); |
| 655 | |
| 656 | return CMD_SUCCESS; |
| 657 | } |
| 658 | |
| 659 | ALIAS (no_debug_bgp_all, |
| 660 | undebug_bgp_all_cmd, |
| 661 | "undebug all bgp", |
| 662 | UNDEBUG_STR |
| 663 | "Enable all debugging\n" |
| 664 | BGP_STR) |
| 665 | |
| 666 | DEFUN (show_debugging_bgp, |
| 667 | show_debugging_bgp_cmd, |
| 668 | "show debugging bgp", |
| 669 | SHOW_STR |
| 670 | DEBUG_STR |
| 671 | BGP_STR) |
| 672 | { |
| 673 | vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE); |
| 674 | |
| 675 | if (BGP_DEBUG (normal, NORMAL)) |
| 676 | vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE); |
| 677 | if (BGP_DEBUG (events, EVENTS)) |
| 678 | vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE); |
| 679 | if (BGP_DEBUG (keepalive, KEEPALIVE)) |
| 680 | vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 681 | if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT)) |
| 682 | vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE); |
| 683 | else if (BGP_DEBUG (update, UPDATE_IN)) |
| 684 | vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 685 | else if (BGP_DEBUG (update, UPDATE_OUT)) |
| 686 | vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 687 | if (BGP_DEBUG (fsm, FSM)) |
| 688 | vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE); |
| 689 | if (BGP_DEBUG (filter, FILTER)) |
| 690 | vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 691 | if (BGP_DEBUG (zebra, ZEBRA)) |
| 692 | vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 693 | vty_out (vty, "%s", VTY_NEWLINE); |
| 694 | return CMD_SUCCESS; |
| 695 | } |
| 696 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 697 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 698 | bgp_config_write_debug (struct vty *vty) |
| 699 | { |
| 700 | int write = 0; |
| 701 | |
| 702 | if (CONF_BGP_DEBUG (normal, NORMAL)) |
| 703 | { |
| 704 | vty_out (vty, "debug bgp%s", VTY_NEWLINE); |
| 705 | write++; |
| 706 | } |
| 707 | |
| 708 | if (CONF_BGP_DEBUG (events, EVENTS)) |
| 709 | { |
| 710 | vty_out (vty, "debug bgp events%s", VTY_NEWLINE); |
| 711 | write++; |
| 712 | } |
| 713 | |
| 714 | if (CONF_BGP_DEBUG (keepalive, KEEPALIVE)) |
| 715 | { |
| 716 | vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE); |
| 717 | write++; |
| 718 | } |
| 719 | |
| 720 | if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 721 | { |
| 722 | vty_out (vty, "debug bgp updates%s", VTY_NEWLINE); |
| 723 | write++; |
| 724 | } |
| 725 | else if (CONF_BGP_DEBUG (update, UPDATE_IN)) |
| 726 | { |
| 727 | vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE); |
| 728 | write++; |
| 729 | } |
| 730 | else if (CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 731 | { |
| 732 | vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE); |
| 733 | write++; |
| 734 | } |
| 735 | |
| 736 | if (CONF_BGP_DEBUG (fsm, FSM)) |
| 737 | { |
| 738 | vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE); |
| 739 | write++; |
| 740 | } |
| 741 | |
| 742 | if (CONF_BGP_DEBUG (filter, FILTER)) |
| 743 | { |
| 744 | vty_out (vty, "debug bgp filters%s", VTY_NEWLINE); |
| 745 | write++; |
| 746 | } |
| 747 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 748 | if (CONF_BGP_DEBUG (zebra, ZEBRA)) |
| 749 | { |
| 750 | vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE); |
| 751 | write++; |
| 752 | } |
| 753 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 754 | return write; |
| 755 | } |
| 756 | |
| 757 | struct cmd_node debug_node = |
| 758 | { |
| 759 | DEBUG_NODE, |
| 760 | "", |
| 761 | 1 |
| 762 | }; |
| 763 | |
| 764 | void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 765 | bgp_debug_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 766 | { |
| 767 | install_node (&debug_node, bgp_config_write_debug); |
| 768 | |
| 769 | install_element (ENABLE_NODE, &show_debugging_bgp_cmd); |
| 770 | |
| 771 | install_element (ENABLE_NODE, &debug_bgp_fsm_cmd); |
| 772 | install_element (CONFIG_NODE, &debug_bgp_fsm_cmd); |
| 773 | install_element (ENABLE_NODE, &debug_bgp_events_cmd); |
| 774 | install_element (CONFIG_NODE, &debug_bgp_events_cmd); |
| 775 | install_element (ENABLE_NODE, &debug_bgp_filter_cmd); |
| 776 | install_element (CONFIG_NODE, &debug_bgp_filter_cmd); |
| 777 | install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd); |
| 778 | install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd); |
| 779 | install_element (ENABLE_NODE, &debug_bgp_update_cmd); |
| 780 | install_element (CONFIG_NODE, &debug_bgp_update_cmd); |
| 781 | install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd); |
| 782 | install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd); |
| 783 | install_element (ENABLE_NODE, &debug_bgp_normal_cmd); |
| 784 | install_element (CONFIG_NODE, &debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 785 | install_element (ENABLE_NODE, &debug_bgp_zebra_cmd); |
| 786 | install_element (CONFIG_NODE, &debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | |
| 788 | install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd); |
| 789 | install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd); |
| 790 | install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd); |
| 791 | install_element (ENABLE_NODE, &no_debug_bgp_events_cmd); |
| 792 | install_element (ENABLE_NODE, &undebug_bgp_events_cmd); |
| 793 | install_element (CONFIG_NODE, &no_debug_bgp_events_cmd); |
| 794 | install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd); |
| 795 | install_element (ENABLE_NODE, &undebug_bgp_filter_cmd); |
| 796 | install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd); |
| 797 | install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd); |
| 798 | install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd); |
| 799 | install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd); |
| 800 | install_element (ENABLE_NODE, &no_debug_bgp_update_cmd); |
| 801 | install_element (ENABLE_NODE, &undebug_bgp_update_cmd); |
| 802 | install_element (CONFIG_NODE, &no_debug_bgp_update_cmd); |
| 803 | install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd); |
| 804 | install_element (ENABLE_NODE, &undebug_bgp_normal_cmd); |
| 805 | install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 806 | install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd); |
| 807 | install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd); |
| 808 | install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | install_element (ENABLE_NODE, &no_debug_bgp_all_cmd); |
| 810 | install_element (ENABLE_NODE, &undebug_bgp_all_cmd); |
| 811 | } |