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; |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 49 | unsigned long conf_bgp_debug_allow_martians; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 50 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 51 | unsigned long term_bgp_debug_as4; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 52 | unsigned long term_bgp_debug_fsm; |
| 53 | unsigned long term_bgp_debug_events; |
| 54 | unsigned long term_bgp_debug_packet; |
| 55 | unsigned long term_bgp_debug_filter; |
| 56 | unsigned long term_bgp_debug_keepalive; |
| 57 | unsigned long term_bgp_debug_update; |
| 58 | unsigned long term_bgp_debug_normal; |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 59 | unsigned long term_bgp_debug_zebra; |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 60 | unsigned long term_bgp_debug_allow_martians; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | |
| 62 | /* messages for BGP-4 status */ |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 63 | const struct message bgp_status_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 65 | { Idle, "Idle" }, |
| 66 | { Connect, "Connect" }, |
| 67 | { Active, "Active" }, |
| 68 | { OpenSent, "OpenSent" }, |
| 69 | { OpenConfirm, "OpenConfirm" }, |
| 70 | { Established, "Established" }, |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 71 | { Clearing, "Clearing" }, |
| 72 | { Deleted, "Deleted" }, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 74 | const int bgp_status_msg_max = BGP_STATUS_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | |
| 76 | /* BGP message type string. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 77 | const char *bgp_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | { |
| 79 | NULL, |
| 80 | "OPEN", |
| 81 | "UPDATE", |
| 82 | "NOTIFICATION", |
| 83 | "KEEPALIVE", |
| 84 | "ROUTE-REFRESH", |
| 85 | "CAPABILITY" |
| 86 | }; |
| 87 | |
| 88 | /* message for BGP-4 Notify */ |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 89 | static const struct message bgp_notify_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | { BGP_NOTIFY_HEADER_ERR, "Message Header Error"}, |
| 92 | { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"}, |
| 93 | { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"}, |
| 94 | { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"}, |
| 95 | { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"}, |
| 96 | { BGP_NOTIFY_CEASE, "Cease"}, |
| 97 | { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"}, |
| 98 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 99 | static const int bgp_notify_msg_max = BGP_NOTIFY_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 101 | static const struct message bgp_notify_head_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | { |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 103 | { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"}, |
| 104 | { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"}, |
| 105 | { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"} |
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 int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 109 | static const struct message bgp_notify_open_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 111 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 112 | { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" }, |
| 113 | { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"}, |
| 114 | { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"}, |
| 115 | { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"}, |
| 116 | { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"}, |
| 117 | { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, |
| 118 | { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"}, |
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 int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 121 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 122 | static const struct message bgp_notify_update_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 123 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 124 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 125 | { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"}, |
| 126 | { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"}, |
| 127 | { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"}, |
| 128 | { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"}, |
| 129 | { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"}, |
| 130 | { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"}, |
| 131 | { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"}, |
| 132 | { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"}, |
| 133 | { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"}, |
| 134 | { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"}, |
| 135 | { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"}, |
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 int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 139 | static const struct message bgp_notify_cease_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 141 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 142 | { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"}, |
| 143 | { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"}, |
| 144 | { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"}, |
| 145 | { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"}, |
| 146 | { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"}, |
| 147 | { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"}, |
| 148 | { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, "/Connection collision resolution"}, |
| 149 | { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"}, |
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 int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 152 | |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 153 | static const struct message bgp_notify_capability_msg[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 154 | { |
Dmitrij Tejblum | 4b4e07d | 2011-09-21 23:13:22 +0400 | [diff] [blame] | 155 | { BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
hasso | 3950fda | 2004-05-20 10:22:49 +0000 | [diff] [blame] | 156 | { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value" }, |
| 157 | { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"}, |
| 158 | { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | }; |
Stephen Hemminger | b2d933f | 2009-05-15 10:48:03 -0700 | [diff] [blame] | 160 | static const int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
| 162 | /* Origin strings. */ |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 163 | const char *bgp_origin_str[] = {"i","e","?"}; |
| 164 | const char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"}; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | |
| 166 | /* Dump attribute. */ |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 167 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 168 | bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) |
| 169 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 170 | if (! attr) |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 171 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 172 | |
paul | e01f9cb | 2004-07-09 17:48:53 +0000 | [diff] [blame] | 173 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP))) |
| 174 | snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); |
| 175 | |
| 176 | if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN))) |
| 177 | snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", |
| 178 | bgp_origin_str[attr->origin]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 180 | if (attr->extra) |
| 181 | { |
| 182 | char addrbuf[BUFSIZ]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 183 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 184 | /* Add MP case. */ |
| 185 | if (attr->extra->mp_nexthop_len == 16 |
| 186 | || attr->extra->mp_nexthop_len == 32) |
| 187 | snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", |
| 188 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, |
| 189 | addrbuf, BUFSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 190 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 191 | if (attr->extra->mp_nexthop_len == 32) |
| 192 | snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", |
| 193 | inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, |
| 194 | addrbuf, BUFSIZ)); |
| 195 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 730 | DEFUN (debug_bgp_allow_martians, |
| 731 | debug_bgp_allow_martians_cmd, |
| 732 | "debug bgp allow-martians", |
| 733 | DEBUG_STR |
| 734 | BGP_STR |
| 735 | "BGP allow martian next hops\n") |
| 736 | { |
| 737 | if (vty->node == CONFIG_NODE) |
| 738 | DEBUG_ON (allow_martians, ALLOW_MARTIANS); |
| 739 | else |
| 740 | { |
| 741 | TERM_DEBUG_ON (allow_martians, ALLOW_MARTIANS); |
| 742 | vty_out (vty, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE); |
| 743 | } |
| 744 | return CMD_SUCCESS; |
| 745 | } |
| 746 | |
| 747 | DEFUN (no_debug_bgp_allow_martians, |
| 748 | no_debug_bgp_allow_martians_cmd, |
| 749 | "no debug bgp allow-martians", |
| 750 | NO_STR |
| 751 | DEBUG_STR |
| 752 | BGP_STR |
| 753 | "BGP allow martian next hops\n") |
| 754 | { |
| 755 | if (vty->node == CONFIG_NODE) |
| 756 | DEBUG_OFF (allow_martians, ALLOW_MARTIANS); |
| 757 | else |
| 758 | { |
| 759 | TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS); |
| 760 | vty_out (vty, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE); |
| 761 | } |
| 762 | return CMD_SUCCESS; |
| 763 | } |
| 764 | |
| 765 | ALIAS (no_debug_bgp_allow_martians, |
| 766 | undebug_bgp_allow_martians_cmd, |
| 767 | "undebug bgp allow-martians", |
| 768 | UNDEBUG_STR |
| 769 | BGP_STR |
| 770 | "BGP allow martian next hops\n") |
| 771 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 772 | DEFUN (no_debug_bgp_all, |
| 773 | no_debug_bgp_all_cmd, |
| 774 | "no debug all bgp", |
| 775 | NO_STR |
| 776 | DEBUG_STR |
| 777 | "Enable all debugging\n" |
| 778 | BGP_STR) |
| 779 | { |
| 780 | TERM_DEBUG_OFF (normal, NORMAL); |
| 781 | TERM_DEBUG_OFF (events, EVENTS); |
| 782 | TERM_DEBUG_OFF (keepalive, KEEPALIVE); |
| 783 | TERM_DEBUG_OFF (update, UPDATE_IN); |
| 784 | TERM_DEBUG_OFF (update, UPDATE_OUT); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 785 | TERM_DEBUG_OFF (as4, AS4); |
| 786 | TERM_DEBUG_OFF (as4, AS4_SEGMENT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | TERM_DEBUG_OFF (fsm, FSM); |
| 788 | TERM_DEBUG_OFF (filter, FILTER); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 789 | TERM_DEBUG_OFF (zebra, ZEBRA); |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 790 | TERM_DEBUG_OFF (allow_martians, ALLOW_MARTIANS); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 791 | vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE); |
| 792 | |
| 793 | return CMD_SUCCESS; |
| 794 | } |
| 795 | |
| 796 | ALIAS (no_debug_bgp_all, |
| 797 | undebug_bgp_all_cmd, |
| 798 | "undebug all bgp", |
| 799 | UNDEBUG_STR |
| 800 | "Enable all debugging\n" |
| 801 | BGP_STR) |
| 802 | |
| 803 | DEFUN (show_debugging_bgp, |
| 804 | show_debugging_bgp_cmd, |
| 805 | "show debugging bgp", |
| 806 | SHOW_STR |
| 807 | DEBUG_STR |
| 808 | BGP_STR) |
| 809 | { |
| 810 | vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE); |
| 811 | |
| 812 | if (BGP_DEBUG (normal, NORMAL)) |
| 813 | vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE); |
| 814 | if (BGP_DEBUG (events, EVENTS)) |
| 815 | vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE); |
| 816 | if (BGP_DEBUG (keepalive, KEEPALIVE)) |
| 817 | vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE); |
| 818 | if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT)) |
| 819 | vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE); |
| 820 | else if (BGP_DEBUG (update, UPDATE_IN)) |
| 821 | vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE); |
| 822 | else if (BGP_DEBUG (update, UPDATE_OUT)) |
| 823 | vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE); |
| 824 | if (BGP_DEBUG (fsm, FSM)) |
| 825 | vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE); |
| 826 | if (BGP_DEBUG (filter, FILTER)) |
| 827 | vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 828 | if (BGP_DEBUG (zebra, ZEBRA)) |
| 829 | vty_out (vty, " BGP zebra debugging is on%s", VTY_NEWLINE); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 830 | if (BGP_DEBUG (as4, AS4)) |
| 831 | vty_out (vty, " BGP as4 debugging is on%s", VTY_NEWLINE); |
| 832 | if (BGP_DEBUG (as4, AS4_SEGMENT)) |
| 833 | vty_out (vty, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE); |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 834 | if (BGP_DEBUG (allow_martians, ALLOW_MARTIANS)) |
| 835 | vty_out (vty, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | vty_out (vty, "%s", VTY_NEWLINE); |
| 837 | return CMD_SUCCESS; |
| 838 | } |
| 839 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 840 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 841 | bgp_config_write_debug (struct vty *vty) |
| 842 | { |
| 843 | int write = 0; |
| 844 | |
| 845 | if (CONF_BGP_DEBUG (normal, NORMAL)) |
| 846 | { |
| 847 | vty_out (vty, "debug bgp%s", VTY_NEWLINE); |
| 848 | write++; |
| 849 | } |
| 850 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 851 | if (CONF_BGP_DEBUG (as4, AS4)) |
| 852 | { |
| 853 | vty_out (vty, "debug bgp as4%s", VTY_NEWLINE); |
| 854 | write++; |
| 855 | } |
| 856 | |
| 857 | if (CONF_BGP_DEBUG (as4, AS4_SEGMENT)) |
| 858 | { |
| 859 | vty_out (vty, "debug bgp as4 segment%s", VTY_NEWLINE); |
| 860 | write++; |
| 861 | } |
| 862 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | if (CONF_BGP_DEBUG (events, EVENTS)) |
| 864 | { |
| 865 | vty_out (vty, "debug bgp events%s", VTY_NEWLINE); |
| 866 | write++; |
| 867 | } |
| 868 | |
| 869 | if (CONF_BGP_DEBUG (keepalive, KEEPALIVE)) |
| 870 | { |
| 871 | vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE); |
| 872 | write++; |
| 873 | } |
| 874 | |
| 875 | if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 876 | { |
| 877 | vty_out (vty, "debug bgp updates%s", VTY_NEWLINE); |
| 878 | write++; |
| 879 | } |
| 880 | else if (CONF_BGP_DEBUG (update, UPDATE_IN)) |
| 881 | { |
| 882 | vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE); |
| 883 | write++; |
| 884 | } |
| 885 | else if (CONF_BGP_DEBUG (update, UPDATE_OUT)) |
| 886 | { |
| 887 | vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE); |
| 888 | write++; |
| 889 | } |
| 890 | |
| 891 | if (CONF_BGP_DEBUG (fsm, FSM)) |
| 892 | { |
| 893 | vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE); |
| 894 | write++; |
| 895 | } |
| 896 | |
| 897 | if (CONF_BGP_DEBUG (filter, FILTER)) |
| 898 | { |
| 899 | vty_out (vty, "debug bgp filters%s", VTY_NEWLINE); |
| 900 | write++; |
| 901 | } |
| 902 | |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 903 | if (CONF_BGP_DEBUG (zebra, ZEBRA)) |
| 904 | { |
| 905 | vty_out (vty, "debug bgp zebra%s", VTY_NEWLINE); |
| 906 | write++; |
| 907 | } |
| 908 | |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 909 | if (CONF_BGP_DEBUG (allow_martians, ALLOW_MARTIANS)) |
| 910 | { |
| 911 | vty_out (vty, "debug bgp allow-martians%s", VTY_NEWLINE); |
| 912 | write++; |
| 913 | } |
| 914 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 915 | return write; |
| 916 | } |
| 917 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 918 | static struct cmd_node debug_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 919 | { |
| 920 | DEBUG_NODE, |
| 921 | "", |
| 922 | 1 |
| 923 | }; |
| 924 | |
| 925 | void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 926 | bgp_debug_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 927 | { |
| 928 | install_node (&debug_node, bgp_config_write_debug); |
| 929 | |
| 930 | install_element (ENABLE_NODE, &show_debugging_bgp_cmd); |
| 931 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 932 | install_element (ENABLE_NODE, &debug_bgp_as4_cmd); |
| 933 | install_element (CONFIG_NODE, &debug_bgp_as4_cmd); |
| 934 | install_element (ENABLE_NODE, &debug_bgp_as4_segment_cmd); |
| 935 | install_element (CONFIG_NODE, &debug_bgp_as4_segment_cmd); |
| 936 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 937 | install_element (ENABLE_NODE, &debug_bgp_fsm_cmd); |
| 938 | install_element (CONFIG_NODE, &debug_bgp_fsm_cmd); |
| 939 | install_element (ENABLE_NODE, &debug_bgp_events_cmd); |
| 940 | install_element (CONFIG_NODE, &debug_bgp_events_cmd); |
| 941 | install_element (ENABLE_NODE, &debug_bgp_filter_cmd); |
| 942 | install_element (CONFIG_NODE, &debug_bgp_filter_cmd); |
| 943 | install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd); |
| 944 | install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd); |
| 945 | install_element (ENABLE_NODE, &debug_bgp_update_cmd); |
| 946 | install_element (CONFIG_NODE, &debug_bgp_update_cmd); |
| 947 | install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd); |
| 948 | install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd); |
| 949 | install_element (ENABLE_NODE, &debug_bgp_normal_cmd); |
| 950 | install_element (CONFIG_NODE, &debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 951 | install_element (ENABLE_NODE, &debug_bgp_zebra_cmd); |
| 952 | install_element (CONFIG_NODE, &debug_bgp_zebra_cmd); |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 953 | install_element (ENABLE_NODE, &debug_bgp_allow_martians_cmd); |
| 954 | install_element (CONFIG_NODE, &debug_bgp_allow_martians_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 955 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 956 | install_element (ENABLE_NODE, &no_debug_bgp_as4_cmd); |
| 957 | install_element (ENABLE_NODE, &undebug_bgp_as4_cmd); |
| 958 | install_element (CONFIG_NODE, &no_debug_bgp_as4_cmd); |
| 959 | install_element (ENABLE_NODE, &no_debug_bgp_as4_segment_cmd); |
| 960 | install_element (ENABLE_NODE, &undebug_bgp_as4_segment_cmd); |
| 961 | install_element (CONFIG_NODE, &no_debug_bgp_as4_segment_cmd); |
| 962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 963 | install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd); |
| 964 | install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd); |
| 965 | install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd); |
| 966 | install_element (ENABLE_NODE, &no_debug_bgp_events_cmd); |
| 967 | install_element (ENABLE_NODE, &undebug_bgp_events_cmd); |
| 968 | install_element (CONFIG_NODE, &no_debug_bgp_events_cmd); |
| 969 | install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd); |
| 970 | install_element (ENABLE_NODE, &undebug_bgp_filter_cmd); |
| 971 | install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd); |
| 972 | install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd); |
| 973 | install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd); |
| 974 | install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd); |
| 975 | install_element (ENABLE_NODE, &no_debug_bgp_update_cmd); |
| 976 | install_element (ENABLE_NODE, &undebug_bgp_update_cmd); |
| 977 | install_element (CONFIG_NODE, &no_debug_bgp_update_cmd); |
| 978 | install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd); |
| 979 | install_element (ENABLE_NODE, &undebug_bgp_normal_cmd); |
| 980 | install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd); |
Andrew J. Schorr | a39275d | 2006-11-30 16:36:57 +0000 | [diff] [blame] | 981 | install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd); |
| 982 | install_element (ENABLE_NODE, &undebug_bgp_zebra_cmd); |
| 983 | install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd); |
Lou Berger | f53585d | 2016-05-17 07:10:36 -0400 | [diff] [blame^] | 984 | install_element (ENABLE_NODE, &no_debug_bgp_allow_martians_cmd); |
| 985 | install_element (ENABLE_NODE, &undebug_bgp_allow_martians_cmd); |
| 986 | install_element (CONFIG_NODE, &no_debug_bgp_allow_martians_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | install_element (ENABLE_NODE, &no_debug_bgp_all_cmd); |
| 988 | install_element (ENABLE_NODE, &undebug_bgp_all_cmd); |
| 989 | } |