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