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 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 108 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 109 | { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" }, |
| 110 | { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"}, |
| 111 | { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"}, |
| 112 | { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"}, |
| 113 | { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"}, |
| 114 | { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, |
| 115 | { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 116 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 117 | static const int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 118 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 119 | static const struct message bgp_notify_update_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 120 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 121 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 122 | { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"}, |
| 123 | { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"}, |
| 124 | { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"}, |
| 125 | { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"}, |
| 126 | { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"}, |
| 127 | { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"}, |
| 128 | { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"}, |
| 129 | { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"}, |
| 130 | { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"}, |
| 131 | { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"}, |
| 132 | { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"}, |
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 int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 135 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 136 | static const struct message bgp_notify_cease_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 138 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 139 | { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"}, |
| 140 | { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"}, |
| 141 | { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"}, |
| 142 | { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"}, |
| 143 | { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"}, |
| 144 | { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"}, |
| 145 | { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"}, |
| 146 | { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 147 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 148 | static const int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 149 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 150 | static const struct message bgp_notify_capability_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 151 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 152 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 153 | { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" }, |
| 154 | { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"}, |
| 155 | { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 157 | static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
| 159 | /* Origin strings. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 160 | const char *bgp_origin_str[] = {"i","e","?"}; |
| 161 | const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"}; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 162 | |
| 163 | /* Dump attribute. */ |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 164 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) |
| 166 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | if (! attr) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 168 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 170 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP))) |
| 171 | snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); |
| 172 | |
| 173 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN))) |
| 174 | snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", |
| 175 | bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 176 | |
| 177 | #ifdef HAVE_IPV6 |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 178 | if (attr->extra) |
| 179 | { |
| 180 | char addrbuf[BUFSIZ]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 181 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 182 | /* Add MP case. */ |
| 183 | if (attr->extra->mp_nexthop_len == 16 |
| 184 | || attr->extra->mp_nexthop_len == 32) |
| 185 | snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", |
| 186 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 187 | addrbuf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 189 | if (attr->extra->mp_nexthop_len == 32) |
| 190 | snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", |
| 191 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 192 | addrbuf, BUFSIZ)); |
| 193 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 194 | #endif /* HAVE_IPV6 */ |
| 195 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 196 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 197 | snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 198 | attr->local_pref); |
| 199 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 200 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 201 | snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | attr->med); |
| 203 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 204 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | snprintf (buf + strlen (buf), size - strlen (buf), ", community %s", |
| 206 | community_str (attr->community)); |
| 207 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 208 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 209 | snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate"); |
| 210 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 211 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) |
Denis Ovsienko | aea339f | 2009-04-30 17:16:22 +0400 | [diff] [blame] | 212 | snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 213 | attr->extra->aggregator_as, |
| 214 | inet_ntoa (attr->extra->aggregator_addr)); |
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_ORIGINATOR_ID))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 218 | inet_ntoa (attr->extra->originator_id)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 219 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 220 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | { |
| 222 | int i; |
| 223 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 224 | snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist"); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 225 | for (i = 0; i < attr->extra->cluster->length / 4; i++) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 226 | snprintf (buf + strlen (buf), size - strlen (buf), " %s", |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 227 | inet_ntoa (attr->extra->cluster->list[i])); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | } |
| 229 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 230 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 231 | snprintf (buf + strlen (buf), size - strlen (buf), ", path %s", |
| 232 | aspath_print (attr->aspath)); |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 233 | |
| 234 | if (strlen (buf) > 1) |
| 235 | return 1; |
| 236 | else |
| 237 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* dump notify packet */ |
| 241 | void |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 242 | bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, |
| 243 | const char *direct) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | { |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 245 | const char *subcode_str; |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 246 | const char *code_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 247 | |
| 248 | subcode_str = ""; |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 249 | code_str = LOOKUP_DEF (bgp_notify_msg, bgp_notify->code, |
| 250 | "Unrecognized Error Code"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 251 | |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 252 | switch (bgp_notify->code) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 253 | { |
| 254 | case BGP_NOTIFY_HEADER_ERR: |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 255 | subcode_str = LOOKUP_DEF (bgp_notify_head_msg, bgp_notify->subcode, |
| 256 | "Unrecognized Error Subcode"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 257 | break; |
| 258 | case BGP_NOTIFY_OPEN_ERR: |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 259 | subcode_str = LOOKUP_DEF (bgp_notify_open_msg, bgp_notify->subcode, |
| 260 | "Unrecognized Error Subcode"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 261 | break; |
| 262 | case BGP_NOTIFY_UPDATE_ERR: |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 263 | subcode_str = LOOKUP_DEF (bgp_notify_update_msg, bgp_notify->subcode, |
| 264 | "Unrecognized Error Subcode"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 265 | break; |
| 266 | case BGP_NOTIFY_HOLD_ERR: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 267 | break; |
| 268 | case BGP_NOTIFY_FSM_ERR: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 269 | break; |
| 270 | case BGP_NOTIFY_CEASE: |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 271 | subcode_str = LOOKUP_DEF (bgp_notify_cease_msg, bgp_notify->subcode, |
| 272 | "Unrecognized Error Subcode"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 273 | break; |
| 274 | case BGP_NOTIFY_CAPABILITY_ERR: |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 275 | subcode_str = LOOKUP_DEF (bgp_notify_capability_msg, bgp_notify->subcode, |
| 276 | "Unrecognized Error Subcode"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 277 | break; |
| 278 | } |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 279 | |
| 280 | if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) |
| 281 | zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s", |
| 282 | strcmp (direct, "received") == 0 ? "received from" : "sent to", |
| 283 | peer->host, bgp_notify->code, bgp_notify->subcode, |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 284 | code_str, subcode_str, bgp_notify->length, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 285 | bgp_notify->data ? bgp_notify->data : ""); |
| 286 | else if (BGP_DEBUG (normal, NORMAL)) |
ajs | 557865c | 2004-12-08 19:59:11 +0000 | [diff] [blame] | 287 | 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] | 288 | peer ? peer->host : "", |
| 289 | direct, bgp_notify->code, bgp_notify->subcode, |
Leonid Rosenboim | 1e0ce7c | 2012-12-07 21:31:07 +0000 | [diff] [blame] | 290 | code_str, subcode_str, bgp_notify->length, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 291 | bgp_notify->data ? bgp_notify->data : ""); |
| 292 | } |
| 293 | |
| 294 | /* Debug option setting interface. */ |
| 295 | unsigned long bgp_debug_option = 0; |
| 296 | |
| 297 | int |
| 298 | debug (unsigned int option) |
| 299 | { |
| 300 | return bgp_debug_option & option; |
| 301 | } |
| 302 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 303 | DEFUN (debug_bgp_as4, |
| 304 | debug_bgp_as4_cmd, |
| 305 | "debug bgp as4", |
| 306 | DEBUG_STR |
| 307 | BGP_STR |
| 308 | "BGP AS4 actions\n") |
| 309 | { |
| 310 | if (vty->node == CONFIG_NODE) |
| 311 | DEBUG_ON (as4, AS4); |
| 312 | else |
| 313 | { |
| 314 | TERM_DEBUG_ON (as4, AS4); |
| 315 | vty_out (vty, "BGP as4 debugging is on%s", VTY_NEWLINE); |
| 316 | } |
| 317 | return CMD_SUCCESS; |
| 318 | } |
| 319 | |
| 320 | DEFUN (no_debug_bgp_as4, |
| 321 | no_debug_bgp_as4_cmd, |
| 322 | "no debug bgp as4", |
| 323 | NO_STR |
| 324 | DEBUG_STR |
| 325 | BGP_STR |
| 326 | "BGP AS4 actions\n") |
| 327 | { |
| 328 | if (vty->node == CONFIG_NODE) |
| 329 | DEBUG_OFF (as4, AS4); |
| 330 | else |
| 331 | { |
| 332 | TERM_DEBUG_OFF (as4, AS4); |
| 333 | vty_out (vty, "BGP as4 debugging is off%s", VTY_NEWLINE); |
| 334 | } |
| 335 | return CMD_SUCCESS; |
| 336 | } |
| 337 | |
| 338 | ALIAS (no_debug_bgp_as4, |
| 339 | undebug_bgp_as4_cmd, |
| 340 | "undebug bgp as4", |
| 341 | UNDEBUG_STR |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 342 | BGP_STR |
| 343 | "BGP AS4 actions\n") |
| 344 | |
| 345 | DEFUN (debug_bgp_as4_segment, |
| 346 | debug_bgp_as4_segment_cmd, |
| 347 | "debug bgp as4 segment", |
| 348 | DEBUG_STR |
| 349 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame] | 350 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 351 | "BGP AS4 aspath segment handling\n") |
| 352 | { |
| 353 | if (vty->node == CONFIG_NODE) |
| 354 | DEBUG_ON (as4, AS4_SEGMENT); |
| 355 | else |
| 356 | { |
| 357 | TERM_DEBUG_ON (as4, AS4_SEGMENT); |
| 358 | vty_out (vty, "BGP as4 segment debugging is on%s", VTY_NEWLINE); |
| 359 | } |
| 360 | return CMD_SUCCESS; |
| 361 | } |
| 362 | |
| 363 | DEFUN (no_debug_bgp_as4_segment, |
| 364 | no_debug_bgp_as4_segment_cmd, |
| 365 | "no debug bgp as4 segment", |
| 366 | NO_STR |
| 367 | DEBUG_STR |
| 368 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame] | 369 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 370 | "BGP AS4 aspath segment handling\n") |
| 371 | { |
| 372 | if (vty->node == CONFIG_NODE) |
| 373 | DEBUG_OFF (as4, AS4_SEGMENT); |
| 374 | else |
| 375 | { |
| 376 | TERM_DEBUG_OFF (as4, AS4_SEGMENT); |
| 377 | vty_out (vty, "BGP as4 segment debugging is off%s", VTY_NEWLINE); |
| 378 | } |
| 379 | return CMD_SUCCESS; |
| 380 | } |
| 381 | |
| 382 | ALIAS (no_debug_bgp_as4_segment, |
| 383 | undebug_bgp_as4_segment_cmd, |
| 384 | "undebug bgp as4 segment", |
| 385 | UNDEBUG_STR |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 386 | BGP_STR |
David Ward | 6e22b90 | 2011-01-17 10:58:52 +0300 | [diff] [blame] | 387 | "BGP AS4 actions\n" |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 388 | "BGP AS4 aspath segment handling\n") |
| 389 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | DEFUN (debug_bgp_fsm, |
| 391 | debug_bgp_fsm_cmd, |
| 392 | "debug bgp fsm", |
| 393 | DEBUG_STR |
| 394 | BGP_STR |
| 395 | "BGP Finite State Machine\n") |
| 396 | { |
| 397 | if (vty->node == CONFIG_NODE) |
| 398 | DEBUG_ON (fsm, FSM); |
| 399 | else |
| 400 | { |
| 401 | TERM_DEBUG_ON (fsm, FSM); |
| 402 | vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE); |
| 403 | } |
| 404 | return CMD_SUCCESS; |
| 405 | } |
| 406 | |
| 407 | DEFUN (no_debug_bgp_fsm, |
| 408 | no_debug_bgp_fsm_cmd, |
| 409 | "no debug bgp fsm", |
| 410 | NO_STR |
| 411 | DEBUG_STR |
| 412 | BGP_STR |
| 413 | "Finite State Machine\n") |
| 414 | { |
| 415 | if (vty->node == CONFIG_NODE) |
| 416 | DEBUG_OFF (fsm, FSM); |
| 417 | else |
| 418 | { |
| 419 | TERM_DEBUG_OFF (fsm, FSM); |
| 420 | vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE); |
| 421 | } |
| 422 | return CMD_SUCCESS; |
| 423 | } |
| 424 | |
| 425 | ALIAS (no_debug_bgp_fsm, |
| 426 | undebug_bgp_fsm_cmd, |
| 427 | "undebug bgp fsm", |
| 428 | UNDEBUG_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | BGP_STR |
| 430 | "Finite State Machine\n") |
| 431 | |
| 432 | DEFUN (debug_bgp_events, |
| 433 | debug_bgp_events_cmd, |
| 434 | "debug bgp events", |
| 435 | DEBUG_STR |
| 436 | BGP_STR |
| 437 | "BGP events\n") |
| 438 | { |
| 439 | if (vty->node == CONFIG_NODE) |
| 440 | DEBUG_ON (events, EVENTS); |
| 441 | else |
| 442 | { |
| 443 | TERM_DEBUG_ON (events, EVENTS); |
| 444 | vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE); |
| 445 | } |
| 446 | return CMD_SUCCESS; |
| 447 | } |
| 448 | |
| 449 | DEFUN (no_debug_bgp_events, |
| 450 | no_debug_bgp_events_cmd, |
| 451 | "no debug bgp events", |
| 452 | NO_STR |
| 453 | DEBUG_STR |
| 454 | BGP_STR |
| 455 | "BGP events\n") |
| 456 | { |
| 457 | if (vty->node == CONFIG_NODE) |
| 458 | DEBUG_OFF (events, EVENTS); |
| 459 | else |
| 460 | { |
| 461 | TERM_DEBUG_OFF (events, EVENTS); |
| 462 | vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE); |
| 463 | } |
| 464 | return CMD_SUCCESS; |
| 465 | } |
| 466 | |
| 467 | ALIAS (no_debug_bgp_events, |
| 468 | undebug_bgp_events_cmd, |
| 469 | "undebug bgp events", |
| 470 | UNDEBUG_STR |
| 471 | BGP_STR |
| 472 | "BGP events\n") |
| 473 | |
| 474 | DEFUN (debug_bgp_filter, |
| 475 | debug_bgp_filter_cmd, |
| 476 | "debug bgp filters", |
| 477 | DEBUG_STR |
| 478 | BGP_STR |
| 479 | "BGP filters\n") |
| 480 | { |
| 481 | if (vty->node == CONFIG_NODE) |
| 482 | DEBUG_ON (filter, FILTER); |
| 483 | else |
| 484 | { |
| 485 | TERM_DEBUG_ON (filter, FILTER); |
| 486 | vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE); |
| 487 | } |
| 488 | return CMD_SUCCESS; |
| 489 | } |
| 490 | |
| 491 | DEFUN (no_debug_bgp_filter, |
| 492 | no_debug_bgp_filter_cmd, |
| 493 | "no debug bgp filters", |
| 494 | NO_STR |
| 495 | DEBUG_STR |
| 496 | BGP_STR |
| 497 | "BGP filters\n") |
| 498 | { |
| 499 | if (vty->node == CONFIG_NODE) |
| 500 | DEBUG_OFF (filter, FILTER); |
| 501 | else |
| 502 | { |
| 503 | TERM_DEBUG_OFF (filter, FILTER); |
| 504 | vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE); |
| 505 | } |
| 506 | return CMD_SUCCESS; |
| 507 | } |
| 508 | |
| 509 | ALIAS (no_debug_bgp_filter, |
| 510 | undebug_bgp_filter_cmd, |
| 511 | "undebug bgp filters", |
| 512 | UNDEBUG_STR |
| 513 | BGP_STR |
| 514 | "BGP filters\n") |
| 515 | |
| 516 | DEFUN (debug_bgp_keepalive, |
| 517 | debug_bgp_keepalive_cmd, |
| 518 | "debug bgp keepalives", |
| 519 | DEBUG_STR |
| 520 | BGP_STR |
| 521 | "BGP keepalives\n") |
| 522 | { |
| 523 | if (vty->node == CONFIG_NODE) |
| 524 | DEBUG_ON (keepalive, KEEPALIVE); |
| 525 | else |
| 526 | { |
| 527 | TERM_DEBUG_ON (keepalive, KEEPALIVE); |
| 528 | vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 529 | } |
| 530 | return CMD_SUCCESS; |
| 531 | } |
| 532 | |
| 533 | DEFUN (no_debug_bgp_keepalive, |
| 534 | no_debug_bgp_keepalive_cmd, |
| 535 | "no debug bgp keepalives", |
| 536 | NO_STR |
| 537 | DEBUG_STR |
| 538 | BGP_STR |
| 539 | "BGP keepalives\n") |
| 540 | { |
| 541 | if (vty->node == CONFIG_NODE) |
| 542 | DEBUG_OFF (keepalive, KEEPALIVE); |
| 543 | else |
| 544 | { |
| 545 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 546 | vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE); |
| 547 | } |
| 548 | return CMD_SUCCESS; |
| 549 | } |
| 550 | |
| 551 | ALIAS (no_debug_bgp_keepalive, |
| 552 | undebug_bgp_keepalive_cmd, |
| 553 | "undebug bgp keepalives", |
| 554 | UNDEBUG_STR |
| 555 | BGP_STR |
| 556 | "BGP keepalives\n") |
| 557 | |
| 558 | DEFUN (debug_bgp_update, |
| 559 | debug_bgp_update_cmd, |
| 560 | "debug bgp updates", |
| 561 | DEBUG_STR |
| 562 | BGP_STR |
| 563 | "BGP updates\n") |
| 564 | { |
| 565 | if (vty->node == CONFIG_NODE) |
| 566 | { |
| 567 | DEBUG_ON (update, UPDATE_IN); |
| 568 | DEBUG_ON (update, UPDATE_OUT); |
| 569 | } |
| 570 | else |
| 571 | { |
| 572 | TERM_DEBUG_ON (update, UPDATE_IN); |
| 573 | TERM_DEBUG_ON (update, UPDATE_OUT); |
| 574 | vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE); |
| 575 | } |
| 576 | return CMD_SUCCESS; |
| 577 | } |
| 578 | |
| 579 | DEFUN (debug_bgp_update_direct, |
| 580 | debug_bgp_update_direct_cmd, |
| 581 | "debug bgp updates (in|out)", |
| 582 | DEBUG_STR |
| 583 | BGP_STR |
| 584 | "BGP updates\n" |
| 585 | "Inbound updates\n" |
| 586 | "Outbound updates\n") |
| 587 | { |
| 588 | if (vty->node == CONFIG_NODE) |
| 589 | { |
| 590 | if (strncmp ("i", argv[0], 1) == 0) |
| 591 | { |
| 592 | DEBUG_OFF (update, UPDATE_OUT); |
| 593 | DEBUG_ON (update, UPDATE_IN); |
| 594 | } |
| 595 | else |
| 596 | { |
| 597 | DEBUG_OFF (update, UPDATE_IN); |
| 598 | DEBUG_ON (update, UPDATE_OUT); |
| 599 | } |
| 600 | } |
| 601 | else |
| 602 | { |
| 603 | if (strncmp ("i", argv[0], 1) == 0) |
| 604 | { |
| 605 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
| 606 | TERM_DEBUG_ON (update, UPDATE_IN); |
| 607 | vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 608 | } |
| 609 | else |
| 610 | { |
| 611 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 612 | TERM_DEBUG_ON (update, UPDATE_OUT); |
| 613 | vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 614 | } |
| 615 | } |
| 616 | return CMD_SUCCESS; |
| 617 | } |
| 618 | |
| 619 | DEFUN (no_debug_bgp_update, |
| 620 | no_debug_bgp_update_cmd, |
| 621 | "no debug bgp updates", |
| 622 | NO_STR |
| 623 | DEBUG_STR |
| 624 | BGP_STR |
| 625 | "BGP updates\n") |
| 626 | { |
| 627 | if (vty->node == CONFIG_NODE) |
| 628 | { |
| 629 | DEBUG_OFF (update, UPDATE_IN); |
| 630 | DEBUG_OFF (update, UPDATE_OUT); |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 635 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
| 636 | vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE); |
| 637 | } |
| 638 | return CMD_SUCCESS; |
| 639 | } |
| 640 | |
| 641 | ALIAS (no_debug_bgp_update, |
| 642 | undebug_bgp_update_cmd, |
| 643 | "undebug bgp updates", |
| 644 | UNDEBUG_STR |
| 645 | BGP_STR |
| 646 | "BGP updates\n") |
| 647 | |
| 648 | DEFUN (debug_bgp_normal, |
| 649 | debug_bgp_normal_cmd, |
| 650 | "debug bgp", |
| 651 | DEBUG_STR |
| 652 | BGP_STR) |
| 653 | { |
| 654 | if (vty->node == CONFIG_NODE) |
| 655 | DEBUG_ON (normal, NORMAL); |
| 656 | else |
| 657 | { |
| 658 | TERM_DEBUG_ON (normal, NORMAL); |
| 659 | vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE); |
| 660 | } |
| 661 | return CMD_SUCCESS; |
| 662 | } |
| 663 | |
| 664 | DEFUN (no_debug_bgp_normal, |
| 665 | no_debug_bgp_normal_cmd, |
| 666 | "no debug bgp", |
| 667 | NO_STR |
| 668 | DEBUG_STR |
| 669 | BGP_STR) |
| 670 | { |
| 671 | if (vty->node == CONFIG_NODE) |
| 672 | DEBUG_OFF (normal, NORMAL); |
| 673 | else |
| 674 | { |
| 675 | TERM_DEBUG_OFF (normal, NORMAL); |
| 676 | vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE); |
| 677 | } |
| 678 | return CMD_SUCCESS; |
| 679 | } |
| 680 | |
| 681 | ALIAS (no_debug_bgp_normal, |
| 682 | undebug_bgp_normal_cmd, |
| 683 | "undebug bgp", |
| 684 | UNDEBUG_STR |
| 685 | BGP_STR) |
| 686 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 687 | DEFUN (debug_bgp_zebra, |
| 688 | debug_bgp_zebra_cmd, |
| 689 | "debug bgp zebra", |
| 690 | DEBUG_STR |
| 691 | BGP_STR |
| 692 | "BGP Zebra messages\n") |
| 693 | { |
| 694 | if (vty->node == CONFIG_NODE) |
| 695 | DEBUG_ON (zebra, ZEBRA); |
| 696 | else |
| 697 | { |
| 698 | TERM_DEBUG_ON (zebra, ZEBRA); |
| 699 | vty_out (vty, "BGP zebra debugging is on%s", VTY_NEWLINE); |
| 700 | } |
| 701 | return CMD_SUCCESS; |
| 702 | } |
| 703 | |
| 704 | DEFUN (no_debug_bgp_zebra, |
| 705 | no_debug_bgp_zebra_cmd, |
| 706 | "no debug bgp zebra", |
| 707 | NO_STR |
| 708 | DEBUG_STR |
| 709 | BGP_STR |
| 710 | "BGP Zebra messages\n") |
| 711 | { |
| 712 | if (vty->node == CONFIG_NODE) |
| 713 | DEBUG_OFF (zebra, ZEBRA); |
| 714 | else |
| 715 | { |
| 716 | TERM_DEBUG_OFF (zebra, ZEBRA); |
| 717 | vty_out (vty, "BGP zebra debugging is off%s", VTY_NEWLINE); |
| 718 | } |
| 719 | return CMD_SUCCESS; |
| 720 | } |
| 721 | |
| 722 | ALIAS (no_debug_bgp_zebra, |
| 723 | undebug_bgp_zebra_cmd, |
| 724 | "undebug bgp zebra", |
| 725 | UNDEBUG_STR |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 726 | BGP_STR |
| 727 | "BGP Zebra messages\n") |
| 728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 729 | DEFUN (no_debug_bgp_all, |
| 730 | no_debug_bgp_all_cmd, |
| 731 | "no debug all bgp", |
| 732 | NO_STR |
| 733 | DEBUG_STR |
| 734 | "Enable all debugging\n" |
| 735 | BGP_STR) |
| 736 | { |
| 737 | TERM_DEBUG_OFF (normal, NORMAL); |
| 738 | TERM_DEBUG_OFF (events, EVENTS); |
| 739 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 740 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 741 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 742 | TERM_DEBUG_OFF (as4, AS4); |
| 743 | TERM_DEBUG_OFF (as4, AS4_SEGMENT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 744 | TERM_DEBUG_OFF (fsm, FSM); |
| 745 | TERM_DEBUG_OFF (filter, FILTER); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 746 | TERM_DEBUG_OFF (zebra, ZEBRA); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 747 | vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE); |
| 748 | |
| 749 | return CMD_SUCCESS; |
| 750 | } |
| 751 | |
| 752 | ALIAS (no_debug_bgp_all, |
| 753 | undebug_bgp_all_cmd, |
| 754 | "undebug all bgp", |
| 755 | UNDEBUG_STR |
| 756 | "Enable all debugging\n" |
| 757 | BGP_STR) |
| 758 | |
| 759 | DEFUN (show_debugging_bgp, |
| 760 | show_debugging_bgp_cmd, |
| 761 | "show debugging bgp", |
| 762 | SHOW_STR |
| 763 | DEBUG_STR |
| 764 | BGP_STR) |
| 765 | { |
| 766 | vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE); |
| 767 | |
| 768 | if (BGP_DEBUG (normal, NORMAL)) |
| 769 | vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE); |
| 770 | if (BGP_DEBUG (events, EVENTS)) |
| 771 | vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE); |
| 772 | if (BGP_DEBUG (keepalive, KEEPALIVE)) |
| 773 | vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 774 | if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT)) |
| 775 | vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE); |
| 776 | else if (BGP_DEBUG (update, UPDATE_IN)) |
| 777 | vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 778 | else if (BGP_DEBUG (update, UPDATE_OUT)) |
| 779 | vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 780 | if (BGP_DEBUG (fsm, FSM)) |
| 781 | vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE); |
| 782 | if (BGP_DEBUG (filter, FILTER)) |
| 783 | vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 784 | if (BGP_DEBUG (zebra, ZEBRA)) |
| 785 | vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 786 | if (BGP_DEBUG (as4, AS4)) |
| 787 | vty_out (vty, " BGP as4 debugging is on%s", VTY_NEWLINE); |
| 788 | if (BGP_DEBUG (as4, AS4_SEGMENT)) |
| 789 | vty_out (vty, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 790 | vty_out (vty, "%s", VTY_NEWLINE); |
| 791 | return CMD_SUCCESS; |
| 792 | } |
| 793 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 794 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 795 | bgp_config_write_debug (struct vty *vty) |
| 796 | { |
| 797 | int write = 0; |
| 798 | |
| 799 | if (CONF_BGP_DEBUG (normal, NORMAL)) |
| 800 | { |
| 801 | vty_out (vty, "debug bgp%s", VTY_NEWLINE); |
| 802 | write++; |
| 803 | } |
| 804 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 805 | if (CONF_BGP_DEBUG (as4, AS4)) |
| 806 | { |
| 807 | vty_out (vty, "debug bgp as4%s", VTY_NEWLINE); |
| 808 | write++; |
| 809 | } |
| 810 | |
| 811 | if (CONF_BGP_DEBUG (as4, AS4_SEGMENT)) |
| 812 | { |
| 813 | vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE); |
| 814 | write++; |
| 815 | } |
| 816 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 817 | if (CONF_BGP_DEBUG (events, EVENTS)) |
| 818 | { |
| 819 | vty_out (vty, "debug bgp events%s", VTY_NEWLINE); |
| 820 | write++; |
| 821 | } |
| 822 | |
| 823 | if (CONF_BGP_DEBUG (keepalive, KEEPALIVE)) |
| 824 | { |
| 825 | vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE); |
| 826 | write++; |
| 827 | } |
| 828 | |
| 829 | if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 830 | { |
| 831 | vty_out (vty, "debug bgp updates%s", VTY_NEWLINE); |
| 832 | write++; |
| 833 | } |
| 834 | else if (CONF_BGP_DEBUG (update, UPDATE_IN)) |
| 835 | { |
| 836 | vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE); |
| 837 | write++; |
| 838 | } |
| 839 | else if (CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 840 | { |
| 841 | vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE); |
| 842 | write++; |
| 843 | } |
| 844 | |
| 845 | if (CONF_BGP_DEBUG (fsm, FSM)) |
| 846 | { |
| 847 | vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE); |
| 848 | write++; |
| 849 | } |
| 850 | |
| 851 | if (CONF_BGP_DEBUG (filter, FILTER)) |
| 852 | { |
| 853 | vty_out (vty, "debug bgp filters%s", VTY_NEWLINE); |
| 854 | write++; |
| 855 | } |
| 856 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 857 | if (CONF_BGP_DEBUG (zebra, ZEBRA)) |
| 858 | { |
| 859 | vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE); |
| 860 | write++; |
| 861 | } |
| 862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | return write; |
| 864 | } |
| 865 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 866 | static struct cmd_node debug_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 867 | { |
| 868 | DEBUG_NODE, |
| 869 | "", |
| 870 | 1 |
| 871 | }; |
| 872 | |
| 873 | void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 874 | bgp_debug_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 875 | { |
| 876 | install_node (&debug_node, bgp_config_write_debug); |
| 877 | |
| 878 | install_element (ENABLE_NODE, &show_debugging_bgp_cmd); |
| 879 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 880 | install_element (ENABLE_NODE, &debug_bgp_as4_cmd); |
| 881 | install_element (CONFIG_NODE, &debug_bgp_as4_cmd); |
| 882 | install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd); |
| 883 | install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd); |
| 884 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 885 | install_element (ENABLE_NODE, &debug_bgp_fsm_cmd); |
| 886 | install_element (CONFIG_NODE, &debug_bgp_fsm_cmd); |
| 887 | install_element (ENABLE_NODE, &debug_bgp_events_cmd); |
| 888 | install_element (CONFIG_NODE, &debug_bgp_events_cmd); |
| 889 | install_element (ENABLE_NODE, &debug_bgp_filter_cmd); |
| 890 | install_element (CONFIG_NODE, &debug_bgp_filter_cmd); |
| 891 | install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd); |
| 892 | install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd); |
| 893 | install_element (ENABLE_NODE, &debug_bgp_update_cmd); |
| 894 | install_element (CONFIG_NODE, &debug_bgp_update_cmd); |
| 895 | install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd); |
| 896 | install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd); |
| 897 | install_element (ENABLE_NODE, &debug_bgp_normal_cmd); |
| 898 | install_element (CONFIG_NODE, &debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 899 | install_element (ENABLE_NODE, &debug_bgp_zebra_cmd); |
| 900 | install_element (CONFIG_NODE, &debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 901 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 902 | install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd); |
| 903 | install_element (ENABLE_NODE, &undebug_bgp_as4_cmd); |
| 904 | install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd); |
| 905 | install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd); |
| 906 | install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd); |
| 907 | install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd); |
| 908 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd); |
| 910 | install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd); |
| 911 | install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd); |
| 912 | install_element (ENABLE_NODE, &no_debug_bgp_events_cmd); |
| 913 | install_element (ENABLE_NODE, &undebug_bgp_events_cmd); |
| 914 | install_element (CONFIG_NODE, &no_debug_bgp_events_cmd); |
| 915 | install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd); |
| 916 | install_element (ENABLE_NODE, &undebug_bgp_filter_cmd); |
| 917 | install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd); |
| 918 | install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd); |
| 919 | install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd); |
| 920 | install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd); |
| 921 | install_element (ENABLE_NODE, &no_debug_bgp_update_cmd); |
| 922 | install_element (ENABLE_NODE, &undebug_bgp_update_cmd); |
| 923 | install_element (CONFIG_NODE, &no_debug_bgp_update_cmd); |
| 924 | install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd); |
| 925 | install_element (ENABLE_NODE, &undebug_bgp_normal_cmd); |
| 926 | install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 927 | install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd); |
| 928 | install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd); |
| 929 | install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 930 | install_element (ENABLE_NODE, &no_debug_bgp_all_cmd); |
| 931 | install_element (ENABLE_NODE, &undebug_bgp_all_cmd); |
| 932 | } |