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