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