]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP-4, BGP-4+ packet debug routine |
896014f4 DL |
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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
5e4fa164 | 23 | #include <lib/version.h> |
259f4236 | 24 | #include "lib/bfd.h" |
23d0a753 | 25 | #include "lib/printfrr.h" |
718e3744 | 26 | #include "prefix.h" |
27 | #include "linklist.h" | |
28 | #include "stream.h" | |
29 | #include "command.h" | |
718e3744 | 30 | #include "log.h" |
31 | #include "sockunion.h" | |
16286195 | 32 | #include "memory.h" |
3f9c7369 | 33 | #include "queue.h" |
039f3a34 | 34 | #include "filter.h" |
718e3744 | 35 | |
36 | #include "bgpd/bgpd.h" | |
37 | #include "bgpd/bgp_aspath.h" | |
38 | #include "bgpd/bgp_route.h" | |
39 | #include "bgpd/bgp_attr.h" | |
40 | #include "bgpd/bgp_debug.h" | |
41 | #include "bgpd/bgp_community.h" | |
07b24afe | 42 | #include "bgpd/bgp_lcommunity.h" |
3f9c7369 | 43 | #include "bgpd/bgp_updgrp.h" |
906ad49b | 44 | #include "bgpd/bgp_mplsvpn.h" |
a4638609 | 45 | #include "bgpd/bgp_ecommunity.h" |
b16031a2 | 46 | #include "bgpd/bgp_label.h" |
47 | #include "bgpd/bgp_evpn.h" | |
81cf0de5 | 48 | #include "bgpd/bgp_evpn_private.h" |
377e3565 | 49 | #include "bgpd/bgp_evpn_vty.h" |
81cf0de5 | 50 | #include "bgpd/bgp_vty.h" |
268e1b9b | 51 | #include "bgpd/bgp_flowspec.h" |
eea685b6 | 52 | #include "bgpd/bgp_packet.h" |
718e3744 | 53 | |
0b2aa3a0 | 54 | unsigned long conf_bgp_debug_as4; |
16286195 | 55 | unsigned long conf_bgp_debug_neighbor_events; |
718e3744 | 56 | unsigned long conf_bgp_debug_events; |
57 | unsigned long conf_bgp_debug_packet; | |
58 | unsigned long conf_bgp_debug_filter; | |
59 | unsigned long conf_bgp_debug_keepalive; | |
60 | unsigned long conf_bgp_debug_update; | |
9fbdd100 | 61 | unsigned long conf_bgp_debug_bestpath; |
a39275d7 | 62 | unsigned long conf_bgp_debug_zebra; |
cebb7440 | 63 | unsigned long conf_bgp_debug_allow_martians; |
fb018d25 | 64 | unsigned long conf_bgp_debug_nht; |
3f9c7369 | 65 | unsigned long conf_bgp_debug_update_groups; |
ddb5b488 | 66 | unsigned long conf_bgp_debug_vpn; |
268e1b9b | 67 | unsigned long conf_bgp_debug_flowspec; |
955bfd98 | 68 | unsigned long conf_bgp_debug_labelpool; |
1a80fc0f | 69 | unsigned long conf_bgp_debug_pbr; |
794b37d5 | 70 | unsigned long conf_bgp_debug_graceful_restart; |
52653398 | 71 | unsigned long conf_bgp_debug_evpn_mh; |
259f4236 | 72 | unsigned long conf_bgp_debug_bfd; |
8093d799 | 73 | unsigned long conf_bgp_debug_cond_adv; |
70cd87ca | 74 | unsigned long conf_bgp_debug_optimal_route_reflection; |
718e3744 | 75 | |
0b2aa3a0 | 76 | unsigned long term_bgp_debug_as4; |
16286195 | 77 | unsigned long term_bgp_debug_neighbor_events; |
718e3744 | 78 | unsigned long term_bgp_debug_events; |
79 | unsigned long term_bgp_debug_packet; | |
80 | unsigned long term_bgp_debug_filter; | |
81 | unsigned long term_bgp_debug_keepalive; | |
82 | unsigned long term_bgp_debug_update; | |
9fbdd100 | 83 | unsigned long term_bgp_debug_bestpath; |
a39275d7 | 84 | unsigned long term_bgp_debug_zebra; |
cebb7440 | 85 | unsigned long term_bgp_debug_allow_martians; |
fb018d25 | 86 | unsigned long term_bgp_debug_nht; |
3f9c7369 | 87 | unsigned long term_bgp_debug_update_groups; |
ddb5b488 | 88 | unsigned long term_bgp_debug_vpn; |
268e1b9b | 89 | unsigned long term_bgp_debug_flowspec; |
955bfd98 | 90 | unsigned long term_bgp_debug_labelpool; |
1a80fc0f | 91 | unsigned long term_bgp_debug_pbr; |
794b37d5 | 92 | unsigned long term_bgp_debug_graceful_restart; |
52653398 | 93 | unsigned long term_bgp_debug_evpn_mh; |
259f4236 | 94 | unsigned long term_bgp_debug_bfd; |
8093d799 | 95 | unsigned long term_bgp_debug_cond_adv; |
70cd87ca | 96 | unsigned long term_bgp_debug_optimal_route_reflection; |
718e3744 | 97 | |
16286195 DS |
98 | struct list *bgp_debug_neighbor_events_peers = NULL; |
99 | struct list *bgp_debug_keepalive_peers = NULL; | |
100 | struct list *bgp_debug_update_out_peers = NULL; | |
101 | struct list *bgp_debug_update_in_peers = NULL; | |
102 | struct list *bgp_debug_update_prefixes = NULL; | |
9fbdd100 | 103 | struct list *bgp_debug_bestpath_prefixes = NULL; |
16286195 DS |
104 | struct list *bgp_debug_zebra_prefixes = NULL; |
105 | ||
718e3744 | 106 | /* messages for BGP-4 status */ |
d62a17ae | 107 | const struct message bgp_status_msg[] = {{Idle, "Idle"}, |
108 | {Connect, "Connect"}, | |
109 | {Active, "Active"}, | |
110 | {OpenSent, "OpenSent"}, | |
111 | {OpenConfirm, "OpenConfirm"}, | |
112 | {Established, "Established"}, | |
113 | {Clearing, "Clearing"}, | |
114 | {Deleted, "Deleted"}, | |
115 | {0}}; | |
718e3744 | 116 | |
117 | /* BGP message type string. */ | |
2b64873d | 118 | const char *const bgp_type_str[] = {NULL, "OPEN", "UPDATE", |
d62a17ae | 119 | "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH", |
120 | "CAPABILITY"}; | |
718e3744 | 121 | |
122 | /* message for BGP-4 Notify */ | |
d62a17ae | 123 | static const struct message bgp_notify_msg[] = { |
124 | {BGP_NOTIFY_HEADER_ERR, "Message Header Error"}, | |
125 | {BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"}, | |
126 | {BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"}, | |
127 | {BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"}, | |
128 | {BGP_NOTIFY_FSM_ERR, "Neighbor Events Error"}, | |
129 | {BGP_NOTIFY_CEASE, "Cease"}, | |
9af52ccf | 130 | {BGP_NOTIFY_ROUTE_REFRESH_ERR, "ROUTE-REFRESH Message Error"}, |
d62a17ae | 131 | {0}}; |
132 | ||
133 | static const struct message bgp_notify_head_msg[] = { | |
134 | {BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"}, | |
135 | {BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"}, | |
136 | {BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}, | |
137 | {0}}; | |
138 | ||
139 | static const struct message bgp_notify_open_msg[] = { | |
140 | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, | |
141 | {BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number"}, | |
142 | {BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"}, | |
143 | {BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"}, | |
144 | {BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"}, | |
145 | {BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"}, | |
146 | {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"}, | |
147 | {BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"}, | |
d864dd9e | 148 | {BGP_NOTIFY_OPEN_ROLE_MISMATCH, "/Role Mismatch"}, |
d62a17ae | 149 | {0}}; |
150 | ||
151 | static const struct message bgp_notify_update_msg[] = { | |
152 | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, | |
153 | {BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"}, | |
154 | {BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"}, | |
155 | {BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"}, | |
156 | {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"}, | |
157 | {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"}, | |
158 | {BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"}, | |
159 | {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"}, | |
160 | {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"}, | |
161 | {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"}, | |
162 | {BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"}, | |
163 | {BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"}, | |
164 | {0}}; | |
165 | ||
166 | static const struct message bgp_notify_cease_msg[] = { | |
167 | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, | |
168 | {BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"}, | |
0ac74523 DA |
169 | {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administrative Shutdown"}, |
170 | {BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer De-configured"}, | |
171 | {BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administrative Reset"}, | |
d62a17ae | 172 | {BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"}, |
173 | {BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"}, | |
174 | {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION, | |
0ac74523 DA |
175 | "/Connection Collision Resolution"}, |
176 | {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resources"}, | |
eea685b6 | 177 | {BGP_NOTIFY_CEASE_HARD_RESET, "/Hard Reset"}, |
aebe2e37 | 178 | {BGP_NOTIFY_CEASE_BFD_DOWN, "/BFD Down"}, |
d62a17ae | 179 | {0}}; |
180 | ||
9af52ccf | 181 | static const struct message bgp_notify_route_refresh_msg[] = { |
d62a17ae | 182 | {BGP_NOTIFY_SUBCODE_UNSPECIFIC, "/Unspecific"}, |
9af52ccf | 183 | {BGP_NOTIFY_ROUTE_REFRESH_INVALID_MSG_LEN, "/Invalid Message Length"}, |
d62a17ae | 184 | {0}}; |
718e3744 | 185 | |
3893aeee DA |
186 | static const struct message bgp_notify_fsm_msg[] = { |
187 | {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC, "/Unspecific"}, | |
188 | {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT, | |
189 | "/Receive Unexpected Message in OpenSent State"}, | |
190 | {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM, | |
191 | "/Receive Unexpected Message in OpenConfirm State"}, | |
192 | {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED, | |
193 | "/Receive Unexpected Message in Established State"}, | |
194 | {0}}; | |
195 | ||
718e3744 | 196 | /* Origin strings. */ |
2b64873d DL |
197 | const char *const bgp_origin_str[] = {"i", "e", "?"}; |
198 | const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; | |
718e3744 | 199 | |
3dc339cd DA |
200 | static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, |
201 | struct prefix *p); | |
16286195 | 202 | /* Given a string return a pointer the corresponding peer structure */ |
d62a17ae | 203 | static struct peer *bgp_find_peer(struct vty *vty, const char *peer_str) |
16286195 | 204 | { |
d62a17ae | 205 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
206 | int ret; | |
207 | union sockunion su; | |
208 | struct peer *peer; | |
209 | ||
210 | if (!bgp) { | |
211 | return NULL; | |
212 | } | |
213 | ret = str2sockunion(peer_str, &su); | |
214 | ||
215 | /* 'swpX' string */ | |
216 | if (ret < 0) { | |
217 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
218 | ||
219 | if (!peer) | |
220 | peer = peer_lookup_by_hostname(bgp, peer_str); | |
221 | ||
222 | return peer; | |
223 | } else | |
224 | return peer_lookup(bgp, &su); | |
16286195 DS |
225 | } |
226 | ||
d62a17ae | 227 | static void bgp_debug_list_free(struct list *list) |
16286195 | 228 | { |
d62a17ae | 229 | struct bgp_debug_filter *filter; |
230 | struct listnode *node, *nnode; | |
16286195 | 231 | |
d62a17ae | 232 | if (list) |
233 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { | |
234 | listnode_delete(list, filter); | |
8fa77bc6 DA |
235 | prefix_free(&filter->p); |
236 | XFREE(MTYPE_BGP_DEBUG_STR, filter->host); | |
d62a17ae | 237 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); |
238 | } | |
16286195 DS |
239 | } |
240 | ||
29a643ca QY |
241 | /* |
242 | * Print the desc along with a list of peers/prefixes this debug is | |
243 | * enabled for | |
244 | */ | |
d62a17ae | 245 | static void bgp_debug_list_print(struct vty *vty, const char *desc, |
29a643ca | 246 | struct list *list) |
d62a17ae | 247 | { |
248 | struct bgp_debug_filter *filter; | |
249 | struct listnode *node, *nnode; | |
d62a17ae | 250 | |
251 | vty_out(vty, "%s", desc); | |
252 | ||
253 | if (list && !list_isempty(list)) { | |
254 | vty_out(vty, " for"); | |
255 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { | |
256 | if (filter->host) | |
257 | vty_out(vty, " %s", filter->host); | |
258 | ||
29a643ca QY |
259 | if (filter->p && filter->p->family == AF_EVPN) |
260 | bgp_debug_print_evpn_prefix(vty, "", filter->p); | |
2dbe669b DA |
261 | else if (filter->p) |
262 | vty_out(vty, " %pFX", filter->p); | |
d62a17ae | 263 | } |
264 | } | |
265 | ||
266 | vty_out(vty, "\n"); | |
16286195 DS |
267 | } |
268 | ||
29a643ca QY |
269 | /* |
270 | * Print the command to enable the debug for each peer/prefix this debug is | |
91ba2c8b DS |
271 | * enabled for |
272 | */ | |
d62a17ae | 273 | static int bgp_debug_list_conf_print(struct vty *vty, const char *desc, |
29a643ca | 274 | struct list *list) |
d62a17ae | 275 | { |
276 | struct bgp_debug_filter *filter; | |
277 | struct listnode *node, *nnode; | |
d62a17ae | 278 | int write = 0; |
279 | ||
280 | if (list && !list_isempty(list)) { | |
281 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { | |
282 | if (filter->host) { | |
283 | vty_out(vty, "%s %s\n", desc, filter->host); | |
284 | write++; | |
285 | } | |
286 | ||
29a643ca QY |
287 | if (filter->p && filter->p->family == AF_EVPN) { |
288 | bgp_debug_print_evpn_prefix(vty, desc, | |
289 | filter->p); | |
290 | write++; | |
291 | } else if (filter->p) { | |
2dbe669b | 292 | vty_out(vty, "%s %pFX\n", desc, filter->p); |
29a643ca | 293 | write++; |
d62a17ae | 294 | } |
295 | } | |
296 | } | |
297 | ||
298 | if (!write) { | |
299 | vty_out(vty, "%s\n", desc); | |
300 | write++; | |
301 | } | |
302 | ||
303 | return write; | |
91ba2c8b DS |
304 | } |
305 | ||
d62a17ae | 306 | static void bgp_debug_list_add_entry(struct list *list, const char *host, |
307 | const struct prefix *p) | |
16286195 | 308 | { |
d62a17ae | 309 | struct bgp_debug_filter *filter; |
310 | ||
311 | filter = XCALLOC(MTYPE_BGP_DEBUG_FILTER, | |
312 | sizeof(struct bgp_debug_filter)); | |
313 | ||
314 | if (host) { | |
315 | filter->host = XSTRDUP(MTYPE_BGP_DEBUG_STR, host); | |
316 | filter->p = NULL; | |
317 | } else if (p) { | |
318 | filter->host = NULL; | |
319 | filter->p = prefix_new(); | |
320 | prefix_copy(filter->p, p); | |
321 | } | |
322 | ||
323 | listnode_add(list, filter); | |
16286195 DS |
324 | } |
325 | ||
3dc339cd DA |
326 | static bool bgp_debug_list_remove_entry(struct list *list, const char *host, |
327 | struct prefix *p) | |
d62a17ae | 328 | { |
329 | struct bgp_debug_filter *filter; | |
330 | struct listnode *node, *nnode; | |
331 | ||
332 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { | |
333 | if (host && strcmp(filter->host, host) == 0) { | |
334 | listnode_delete(list, filter); | |
335 | XFREE(MTYPE_BGP_DEBUG_STR, filter->host); | |
336 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); | |
3dc339cd | 337 | return true; |
d62a17ae | 338 | } else if (p && filter->p->prefixlen == p->prefixlen |
339 | && prefix_match(filter->p, p)) { | |
340 | listnode_delete(list, filter); | |
63265b5c | 341 | prefix_free(&filter->p); |
d62a17ae | 342 | XFREE(MTYPE_BGP_DEBUG_FILTER, filter); |
3dc339cd | 343 | return true; |
d62a17ae | 344 | } |
345 | } | |
346 | ||
3dc339cd | 347 | return false; |
16286195 DS |
348 | } |
349 | ||
3dc339cd DA |
350 | static bool bgp_debug_list_has_entry(struct list *list, const char *host, |
351 | const struct prefix *p) | |
d62a17ae | 352 | { |
353 | struct bgp_debug_filter *filter; | |
354 | struct listnode *node, *nnode; | |
355 | ||
356 | for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { | |
357 | if (host) { | |
358 | if (strcmp(filter->host, host) == 0) { | |
3dc339cd | 359 | return true; |
d62a17ae | 360 | } |
361 | } else if (p) { | |
362 | if (filter->p->prefixlen == p->prefixlen | |
363 | && prefix_match(filter->p, p)) { | |
3dc339cd | 364 | return true; |
d62a17ae | 365 | } |
366 | } | |
367 | } | |
368 | ||
3dc339cd | 369 | return false; |
16286195 DS |
370 | } |
371 | ||
3dc339cd | 372 | bool bgp_debug_peer_updout_enabled(char *host) |
3f9c7369 | 373 | { |
d62a17ae | 374 | return (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, |
375 | NULL)); | |
3f9c7369 DS |
376 | } |
377 | ||
718e3744 | 378 | /* Dump attribute. */ |
3dc339cd | 379 | bool bgp_dump_attr(struct attr *attr, char *buf, size_t size) |
718e3744 | 380 | { |
d62a17ae | 381 | char addrbuf[BUFSIZ]; |
718e3744 | 382 | |
d62a17ae | 383 | if (!attr) |
3dc339cd | 384 | return false; |
d62a17ae | 385 | |
8ba71050 NS |
386 | buf[0] = '\0'; |
387 | ||
d62a17ae | 388 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) |
23d0a753 | 389 | snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop); |
d62a17ae | 390 | |
391 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN))) | |
392 | snprintf(buf + strlen(buf), size - strlen(buf), ", origin %s", | |
393 | bgp_origin_str[attr->origin]); | |
394 | ||
395 | /* Add MP case. */ | |
396 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL | |
397 | || attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) | |
398 | snprintf(buf + strlen(buf), size - strlen(buf), | |
399 | ", mp_nexthop %s", | |
400 | inet_ntop(AF_INET6, &attr->mp_nexthop_global, addrbuf, | |
401 | BUFSIZ)); | |
402 | ||
403 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) | |
404 | snprintf(buf + strlen(buf), size - strlen(buf), "(%s)", | |
405 | inet_ntop(AF_INET6, &attr->mp_nexthop_local, addrbuf, | |
406 | BUFSIZ)); | |
407 | ||
408 | if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) | |
23d0a753 | 409 | snprintfrr(buf, size, "nexthop %pI4", &attr->nexthop); |
d62a17ae | 410 | |
411 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) | |
412 | snprintf(buf + strlen(buf), size - strlen(buf), | |
413 | ", localpref %u", attr->local_pref); | |
414 | ||
97a52c82 DA |
415 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AIGP))) |
416 | snprintf(buf + strlen(buf), size - strlen(buf), | |
417 | ", aigp-metric %" PRIu64, | |
418 | (unsigned long long)bgp_attr_get_aigp_metric(attr)); | |
419 | ||
d62a17ae | 420 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) |
421 | snprintf(buf + strlen(buf), size - strlen(buf), ", metric %u", | |
422 | attr->med); | |
423 | ||
424 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) | |
425 | snprintf(buf + strlen(buf), size - strlen(buf), | |
a4d82a8a | 426 | ", community %s", |
c0945b78 DA |
427 | community_str(bgp_attr_get_community(attr), false, |
428 | true)); | |
d62a17ae | 429 | |
07b24afe DA |
430 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) |
431 | snprintf(buf + strlen(buf), size - strlen(buf), | |
432 | ", large-community %s", | |
c0945b78 DA |
433 | lcommunity_str(bgp_attr_get_lcommunity(attr), false, |
434 | true)); | |
07b24afe | 435 | |
d62a17ae | 436 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) |
437 | snprintf(buf + strlen(buf), size - strlen(buf), | |
b53e67a3 DA |
438 | ", extcommunity %s", |
439 | ecommunity_str(bgp_attr_get_ecommunity(attr))); | |
d62a17ae | 440 | |
441 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))) | |
442 | snprintf(buf + strlen(buf), size - strlen(buf), | |
443 | ", atomic-aggregate"); | |
444 | ||
445 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))) | |
23d0a753 DA |
446 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
447 | ", aggregated by %u %pI4", attr->aggregator_as, | |
448 | &attr->aggregator_addr); | |
d62a17ae | 449 | |
450 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) | |
23d0a753 DA |
451 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
452 | ", originator %pI4", &attr->originator_id); | |
d62a17ae | 453 | |
454 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) { | |
779fee93 | 455 | struct cluster_list *cluster; |
d62a17ae | 456 | int i; |
457 | ||
458 | snprintf(buf + strlen(buf), size - strlen(buf), | |
459 | ", clusterlist"); | |
779fee93 DS |
460 | |
461 | cluster = bgp_attr_get_cluster(attr); | |
462 | for (i = 0; i < cluster->length / 4; i++) | |
23d0a753 | 463 | snprintfrr(buf + strlen(buf), size - strlen(buf), |
779fee93 | 464 | " %pI4", &cluster->list[i]); |
d62a17ae | 465 | } |
466 | ||
7fd077aa | 467 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) |
052ea98b | 468 | snprintf(buf + strlen(buf), size - strlen(buf), |
2a3f51cf | 469 | ", pmsi tnltype %u", bgp_attr_get_pmsi_tnl_type(attr)); |
7fd077aa | 470 | |
d62a17ae | 471 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH))) |
472 | snprintf(buf + strlen(buf), size - strlen(buf), ", path %s", | |
473 | aspath_print(attr->aspath)); | |
474 | ||
475 | if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID))) { | |
476 | if (attr->label_index != BGP_INVALID_LABEL_INDEX) | |
477 | snprintf(buf + strlen(buf), size - strlen(buf), | |
478 | ", label-index %u", attr->label_index); | |
479 | } | |
480 | ||
481 | if (strlen(buf) > 1) | |
3dc339cd | 482 | return true; |
d62a17ae | 483 | else |
3dc339cd | 484 | return false; |
3a8c7ba1 | 485 | } |
718e3744 | 486 | |
d62a17ae | 487 | const char *bgp_notify_code_str(char code) |
3a8c7ba1 | 488 | { |
d62a17ae | 489 | return lookup_msg(bgp_notify_msg, code, "Unrecognized Error Code"); |
490 | } | |
718e3744 | 491 | |
d62a17ae | 492 | const char *bgp_notify_subcode_str(char code, char subcode) |
493 | { | |
494 | ||
495 | switch (code) { | |
496 | case BGP_NOTIFY_HEADER_ERR: | |
497 | return lookup_msg(bgp_notify_head_msg, subcode, | |
498 | "Unrecognized Error Subcode"); | |
499 | case BGP_NOTIFY_OPEN_ERR: | |
500 | return lookup_msg(bgp_notify_open_msg, subcode, | |
501 | "Unrecognized Error Subcode"); | |
502 | case BGP_NOTIFY_UPDATE_ERR: | |
503 | return lookup_msg(bgp_notify_update_msg, subcode, | |
504 | "Unrecognized Error Subcode"); | |
505 | case BGP_NOTIFY_HOLD_ERR: | |
506 | break; | |
507 | case BGP_NOTIFY_FSM_ERR: | |
3893aeee DA |
508 | return lookup_msg(bgp_notify_fsm_msg, subcode, |
509 | "Unrecognized Error Subcode"); | |
d62a17ae | 510 | case BGP_NOTIFY_CEASE: |
511 | return lookup_msg(bgp_notify_cease_msg, subcode, | |
512 | "Unrecognized Error Subcode"); | |
9af52ccf DA |
513 | case BGP_NOTIFY_ROUTE_REFRESH_ERR: |
514 | return lookup_msg(bgp_notify_route_refresh_msg, subcode, | |
d62a17ae | 515 | "Unrecognized Error Subcode"); |
516 | } | |
517 | return ""; | |
3a8c7ba1 DW |
518 | } |
519 | ||
38de8d02 | 520 | /* extract notify admin reason if correctly present */ |
d7c0a89a | 521 | const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data, |
d62a17ae | 522 | size_t datalen) |
38de8d02 | 523 | { |
d62a17ae | 524 | if (!data || datalen < 1) |
525 | return NULL; | |
38de8d02 | 526 | |
d7c0a89a | 527 | uint8_t len = data[0]; |
9f33eea3 | 528 | if (!len || len > datalen - 1) |
d62a17ae | 529 | return NULL; |
38de8d02 | 530 | |
d62a17ae | 531 | return zlog_sanitize(buf, bufsz, data + 1, len); |
38de8d02 DL |
532 | } |
533 | ||
3a8c7ba1 | 534 | /* dump notify packet */ |
d62a17ae | 535 | void bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, |
eea685b6 | 536 | const char *direct, bool hard_reset) |
d62a17ae | 537 | { |
538 | const char *subcode_str; | |
539 | const char *code_str; | |
540 | const char *msg_str = NULL; | |
541 | char msg_buf[1024]; | |
542 | ||
543 | if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS) | |
892fedb6 | 544 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES)) { |
d62a17ae | 545 | code_str = bgp_notify_code_str(bgp_notify->code); |
546 | subcode_str = bgp_notify_subcode_str(bgp_notify->code, | |
547 | bgp_notify->subcode); | |
548 | ||
549 | if (bgp_notify->code == BGP_NOTIFY_CEASE | |
550 | && (bgp_notify->subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
551 | || bgp_notify->subcode | |
552 | == BGP_NOTIFY_CEASE_ADMIN_RESET)) { | |
553 | msg_str = bgp_notify_admin_message( | |
554 | msg_buf, sizeof(msg_buf), bgp_notify->raw_data, | |
555 | bgp_notify->length); | |
556 | } | |
557 | ||
558 | if (msg_str) { | |
559 | zlog_info( | |
eea685b6 DA |
560 | "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) \"%s\"", |
561 | hard_reset ? "(Hard Reset)" : "", | |
d62a17ae | 562 | strcmp(direct, "received") == 0 |
563 | ? "received from" | |
564 | : "sent to", | |
565 | peer->host, bgp_notify->code, | |
566 | bgp_notify->subcode, code_str, subcode_str, | |
567 | msg_str); | |
568 | } else { | |
569 | msg_str = bgp_notify->data ? bgp_notify->data : ""; | |
570 | zlog_info( | |
eea685b6 DA |
571 | "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) %d bytes %s", |
572 | hard_reset ? "(Hard Reset)" : "", | |
d62a17ae | 573 | strcmp(direct, "received") == 0 |
574 | ? "received from" | |
575 | : "sent to", | |
576 | peer->host, bgp_notify->code, | |
577 | bgp_notify->subcode, code_str, subcode_str, | |
578 | bgp_notify->length, msg_str); | |
579 | } | |
580 | } | |
718e3744 | 581 | } |
6b0655a2 | 582 | |
d62a17ae | 583 | static void bgp_debug_clear_updgrp_update_dbg(struct bgp *bgp) |
3f9c7369 | 584 | { |
d62a17ae | 585 | if (!bgp) |
586 | bgp = bgp_get_default(); | |
587 | update_group_walk(bgp, update_group_clear_update_dbg, NULL); | |
3f9c7369 DS |
588 | } |
589 | ||
3dc339cd DA |
590 | static void bgp_debug_print_evpn_prefix(struct vty *vty, const char *desc, |
591 | struct prefix *p) | |
81cf0de5 CS |
592 | { |
593 | char evpn_desc[PREFIX2STR_BUFFER + INET_ADDRSTRLEN]; | |
594 | char buf[PREFIX2STR_BUFFER]; | |
595 | char buf2[ETHER_ADDR_STRLEN]; | |
596 | ||
597 | if (p->u.prefix_evpn.route_type == BGP_EVPN_MAC_IP_ROUTE) { | |
598 | if (is_evpn_prefix_ipaddr_none((struct prefix_evpn *)p)) { | |
772270f3 QY |
599 | snprintf( |
600 | evpn_desc, sizeof(evpn_desc), | |
601 | "l2vpn evpn type macip mac %s", | |
602 | prefix_mac2str(&p->u.prefix_evpn.macip_addr.mac, | |
603 | buf2, sizeof(buf2))); | |
81cf0de5 CS |
604 | } else { |
605 | uint8_t family = is_evpn_prefix_ipaddr_v4( | |
606 | (struct prefix_evpn *)p) ? | |
607 | AF_INET : AF_INET6; | |
772270f3 QY |
608 | snprintf( |
609 | evpn_desc, sizeof(evpn_desc), | |
610 | "l2vpn evpn type macip mac %s ip %s", | |
611 | prefix_mac2str(&p->u.prefix_evpn.macip_addr.mac, | |
612 | buf2, sizeof(buf2)), | |
613 | inet_ntop( | |
614 | family, | |
81cf0de5 CS |
615 | &p->u.prefix_evpn.macip_addr.ip.ip.addr, |
616 | buf, PREFIX2STR_BUFFER)); | |
617 | } | |
618 | } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IMET_ROUTE) { | |
23d0a753 DA |
619 | snprintfrr(evpn_desc, sizeof(evpn_desc), |
620 | "l2vpn evpn type multicast ip %pI4", | |
621 | &p->u.prefix_evpn.imet_addr.ip.ipaddr_v4); | |
81cf0de5 CS |
622 | } else if (p->u.prefix_evpn.route_type == BGP_EVPN_IP_PREFIX_ROUTE) { |
623 | uint8_t family = is_evpn_prefix_ipaddr_v4( | |
624 | (struct prefix_evpn *)p) ? AF_INET | |
625 | : AF_INET6; | |
772270f3 QY |
626 | snprintf(evpn_desc, sizeof(evpn_desc), |
627 | "l2vpn evpn type prefix ip %s/%d", | |
628 | inet_ntop(family, | |
629 | &p->u.prefix_evpn.prefix_addr.ip.ip.addr, | |
630 | buf, PREFIX2STR_BUFFER), | |
631 | p->u.prefix_evpn.prefix_addr.ip_prefix_length); | |
81cf0de5 CS |
632 | } |
633 | ||
634 | vty_out(vty, "%s %s\n", desc, evpn_desc); | |
81cf0de5 CS |
635 | } |
636 | ||
637 | static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv, | |
638 | int argc, struct prefix **argv_pp) | |
639 | { | |
640 | struct prefix *argv_p; | |
9b01d289 DA |
641 | struct ethaddr mac = {}; |
642 | struct ipaddr ip = {}; | |
15dc08a6 | 643 | int evpn_type = 0; |
81cf0de5 CS |
644 | int mac_idx = 0; |
645 | int ip_idx = 0; | |
646 | ||
647 | argv_p = *argv_pp; | |
648 | ||
15dc08a6 SW |
649 | if (bgp_evpn_cli_parse_type(&evpn_type, argv, argc) < 0) |
650 | return CMD_WARNING; | |
81cf0de5 CS |
651 | |
652 | if (evpn_type == BGP_EVPN_MAC_IP_ROUTE) { | |
6006b807 | 653 | memset(&ip, 0, sizeof(ip)); |
377e3565 | 654 | |
9b01d289 | 655 | if (argv_find(argv, argc, "mac", &mac_idx)) |
7aad5e6a DA |
656 | if (!prefix_str2mac(argv[mac_idx + 1]->arg, &mac)) { |
657 | vty_out(vty, "%% Malformed MAC address\n"); | |
658 | return CMD_WARNING; | |
659 | } | |
377e3565 | 660 | |
9b01d289 | 661 | if (argv_find(argv, argc, "ip", &ip_idx)) |
7aad5e6a DA |
662 | if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { |
663 | vty_out(vty, "%% Malformed IP address\n"); | |
664 | return CMD_WARNING; | |
665 | } | |
81cf0de5 CS |
666 | |
667 | build_evpn_type2_prefix((struct prefix_evpn *)argv_p, | |
668 | &mac, &ip); | |
669 | } else if (evpn_type == BGP_EVPN_IMET_ROUTE) { | |
6006b807 | 670 | memset(&ip, 0, sizeof(ip)); |
377e3565 | 671 | |
9b01d289 | 672 | if (argv_find(argv, argc, "ip", &ip_idx)) |
7aad5e6a DA |
673 | if (str2ipaddr(argv[ip_idx + 1]->arg, &ip) != 0) { |
674 | vty_out(vty, "%% Malformed IP address\n"); | |
675 | return CMD_WARNING; | |
676 | } | |
377e3565 | 677 | |
81cf0de5 CS |
678 | build_evpn_type3_prefix((struct prefix_evpn *)argv_p, |
679 | ip.ipaddr_v4); | |
680 | } else if (evpn_type == BGP_EVPN_IP_PREFIX_ROUTE) { | |
681 | struct prefix ip_prefix; | |
682 | ||
6006b807 | 683 | memset(&ip_prefix, 0, sizeof(ip_prefix)); |
81cf0de5 CS |
684 | if (argv_find(argv, argc, "ip", &ip_idx)) { |
685 | (void)str2prefix(argv[ip_idx + 1]->arg, &ip_prefix); | |
686 | apply_mask(&ip_prefix); | |
687 | } | |
688 | build_type5_prefix_from_ip_prefix( | |
689 | (struct prefix_evpn *)argv_p, | |
690 | &ip_prefix); | |
691 | } | |
692 | ||
693 | return CMD_SUCCESS; | |
694 | } | |
3f9c7369 | 695 | |
718e3744 | 696 | /* Debug option setting interface. */ |
697 | unsigned long bgp_debug_option = 0; | |
698 | ||
d62a17ae | 699 | int debug(unsigned int option) |
718e3744 | 700 | { |
d62a17ae | 701 | return bgp_debug_option & option; |
718e3744 | 702 | } |
703 | ||
0b2aa3a0 PJ |
704 | DEFUN (debug_bgp_as4, |
705 | debug_bgp_as4_cmd, | |
706 | "debug bgp as4", | |
707 | DEBUG_STR | |
708 | BGP_STR | |
709 | "BGP AS4 actions\n") | |
710 | { | |
d62a17ae | 711 | if (vty->node == CONFIG_NODE) |
712 | DEBUG_ON(as4, AS4); | |
713 | else { | |
714 | TERM_DEBUG_ON(as4, AS4); | |
715 | vty_out(vty, "BGP as4 debugging is on\n"); | |
716 | } | |
717 | return CMD_SUCCESS; | |
0b2aa3a0 PJ |
718 | } |
719 | ||
720 | DEFUN (no_debug_bgp_as4, | |
721 | no_debug_bgp_as4_cmd, | |
722 | "no debug bgp as4", | |
723 | NO_STR | |
724 | DEBUG_STR | |
725 | BGP_STR | |
726 | "BGP AS4 actions\n") | |
727 | { | |
d62a17ae | 728 | if (vty->node == CONFIG_NODE) |
729 | DEBUG_OFF(as4, AS4); | |
730 | else { | |
731 | TERM_DEBUG_OFF(as4, AS4); | |
732 | vty_out(vty, "BGP as4 debugging is off\n"); | |
733 | } | |
734 | return CMD_SUCCESS; | |
0b2aa3a0 PJ |
735 | } |
736 | ||
0b2aa3a0 PJ |
737 | DEFUN (debug_bgp_as4_segment, |
738 | debug_bgp_as4_segment_cmd, | |
739 | "debug bgp as4 segment", | |
740 | DEBUG_STR | |
741 | BGP_STR | |
6e22b901 | 742 | "BGP AS4 actions\n" |
0b2aa3a0 PJ |
743 | "BGP AS4 aspath segment handling\n") |
744 | { | |
d62a17ae | 745 | if (vty->node == CONFIG_NODE) |
746 | DEBUG_ON(as4, AS4_SEGMENT); | |
747 | else { | |
748 | TERM_DEBUG_ON(as4, AS4_SEGMENT); | |
749 | vty_out(vty, "BGP as4 segment debugging is on\n"); | |
750 | } | |
751 | return CMD_SUCCESS; | |
0b2aa3a0 PJ |
752 | } |
753 | ||
754 | DEFUN (no_debug_bgp_as4_segment, | |
755 | no_debug_bgp_as4_segment_cmd, | |
756 | "no debug bgp as4 segment", | |
757 | NO_STR | |
758 | DEBUG_STR | |
759 | BGP_STR | |
6e22b901 | 760 | "BGP AS4 actions\n" |
0b2aa3a0 PJ |
761 | "BGP AS4 aspath segment handling\n") |
762 | { | |
d62a17ae | 763 | if (vty->node == CONFIG_NODE) |
764 | DEBUG_OFF(as4, AS4_SEGMENT); | |
765 | else { | |
766 | TERM_DEBUG_OFF(as4, AS4_SEGMENT); | |
767 | vty_out(vty, "BGP as4 segment debugging is off\n"); | |
768 | } | |
769 | return CMD_SUCCESS; | |
0b2aa3a0 PJ |
770 | } |
771 | ||
16286195 DS |
772 | /* debug bgp neighbor_events */ |
773 | DEFUN (debug_bgp_neighbor_events, | |
774 | debug_bgp_neighbor_events_cmd, | |
775 | "debug bgp neighbor-events", | |
718e3744 | 776 | DEBUG_STR |
777 | BGP_STR | |
16286195 | 778 | "BGP Neighbor Events\n") |
718e3744 | 779 | { |
d62a17ae | 780 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
781 | ||
782 | if (vty->node == CONFIG_NODE) | |
783 | DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); | |
784 | else { | |
785 | TERM_DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); | |
786 | vty_out(vty, "BGP neighbor-events debugging is on\n"); | |
787 | } | |
788 | return CMD_SUCCESS; | |
718e3744 | 789 | } |
790 | ||
16286195 DS |
791 | DEFUN (debug_bgp_neighbor_events_peer, |
792 | debug_bgp_neighbor_events_peer_cmd, | |
6147e2c6 | 793 | "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 794 | DEBUG_STR |
795 | BGP_STR | |
16286195 DS |
796 | "BGP Neighbor Events\n" |
797 | "BGP neighbor IP address to debug\n" | |
798 | "BGP IPv6 neighbor to debug\n" | |
799 | "BGP neighbor on interface to debug\n") | |
718e3744 | 800 | { |
d62a17ae | 801 | int idx_peer = 3; |
802 | const char *host = argv[idx_peer]->arg; | |
803 | ||
804 | if (!bgp_debug_neighbor_events_peers) | |
805 | bgp_debug_neighbor_events_peers = list_new(); | |
806 | ||
807 | if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers, host, | |
808 | NULL)) { | |
809 | vty_out(vty, | |
810 | "BGP neighbor-events debugging is already enabled for %s\n", | |
811 | host); | |
812 | return CMD_SUCCESS; | |
813 | } | |
814 | ||
815 | bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers, host, NULL); | |
816 | ||
817 | if (vty->node == CONFIG_NODE) | |
818 | DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); | |
819 | else { | |
820 | TERM_DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS); | |
821 | vty_out(vty, "BGP neighbor-events debugging is on for %s\n", | |
822 | host); | |
823 | } | |
824 | return CMD_SUCCESS; | |
718e3744 | 825 | } |
826 | ||
16286195 DS |
827 | DEFUN (no_debug_bgp_neighbor_events, |
828 | no_debug_bgp_neighbor_events_cmd, | |
829 | "no debug bgp neighbor-events", | |
830 | NO_STR | |
718e3744 | 831 | DEBUG_STR |
832 | BGP_STR | |
16286195 | 833 | "Neighbor Events\n") |
718e3744 | 834 | { |
d62a17ae | 835 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
836 | ||
837 | if (vty->node == CONFIG_NODE) | |
838 | DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); | |
839 | else { | |
840 | TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); | |
841 | vty_out(vty, "BGP neighbor-events debugging is off\n"); | |
842 | } | |
843 | return CMD_SUCCESS; | |
718e3744 | 844 | } |
845 | ||
16286195 DS |
846 | DEFUN (no_debug_bgp_neighbor_events_peer, |
847 | no_debug_bgp_neighbor_events_peer_cmd, | |
6147e2c6 | 848 | "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 849 | NO_STR |
850 | DEBUG_STR | |
851 | BGP_STR | |
16286195 DS |
852 | "Neighbor Events\n" |
853 | "BGP neighbor IP address to debug\n" | |
854 | "BGP IPv6 neighbor to debug\n" | |
855 | "BGP neighbor on interface to debug\n") | |
718e3744 | 856 | { |
d62a17ae | 857 | int idx_peer = 4; |
858 | int found_peer = 0; | |
859 | const char *host = argv[idx_peer]->arg; | |
860 | ||
861 | if (bgp_debug_neighbor_events_peers | |
862 | && !list_isempty(bgp_debug_neighbor_events_peers)) { | |
863 | found_peer = bgp_debug_list_remove_entry( | |
864 | bgp_debug_neighbor_events_peers, host, NULL); | |
865 | ||
866 | if (list_isempty(bgp_debug_neighbor_events_peers)) { | |
867 | if (vty->node == CONFIG_NODE) | |
868 | DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); | |
869 | else | |
870 | TERM_DEBUG_OFF(neighbor_events, | |
871 | NEIGHBOR_EVENTS); | |
872 | } | |
873 | } | |
874 | ||
875 | if (found_peer) | |
876 | vty_out(vty, "BGP neighbor-events debugging is off for %s\n", | |
877 | host); | |
878 | else | |
879 | vty_out(vty, | |
880 | "BGP neighbor-events debugging was not enabled for %s\n", | |
881 | host); | |
882 | ||
883 | return CMD_SUCCESS; | |
718e3744 | 884 | } |
885 | ||
16286195 | 886 | /* debug bgp nht */ |
fb018d25 DS |
887 | DEFUN (debug_bgp_nht, |
888 | debug_bgp_nht_cmd, | |
889 | "debug bgp nht", | |
890 | DEBUG_STR | |
891 | BGP_STR | |
892 | "BGP nexthop tracking events\n") | |
893 | { | |
d62a17ae | 894 | if (vty->node == CONFIG_NODE) |
895 | DEBUG_ON(nht, NHT); | |
896 | else { | |
897 | TERM_DEBUG_ON(nht, NHT); | |
898 | vty_out(vty, "BGP nexthop tracking debugging is on\n"); | |
899 | } | |
900 | return CMD_SUCCESS; | |
fb018d25 DS |
901 | } |
902 | ||
903 | DEFUN (no_debug_bgp_nht, | |
904 | no_debug_bgp_nht_cmd, | |
905 | "no debug bgp nht", | |
906 | NO_STR | |
907 | DEBUG_STR | |
908 | BGP_STR | |
909 | "BGP nexthop tracking events\n") | |
910 | { | |
d62a17ae | 911 | if (vty->node == CONFIG_NODE) |
912 | DEBUG_OFF(nht, NHT); | |
913 | else { | |
914 | TERM_DEBUG_OFF(nht, NHT); | |
915 | vty_out(vty, "BGP nexthop tracking debugging is off\n"); | |
916 | } | |
917 | return CMD_SUCCESS; | |
fb018d25 DS |
918 | } |
919 | ||
16286195 DS |
920 | /* debug bgp keepalives */ |
921 | DEFUN (debug_bgp_keepalive, | |
922 | debug_bgp_keepalive_cmd, | |
923 | "debug bgp keepalives", | |
718e3744 | 924 | DEBUG_STR |
925 | BGP_STR | |
16286195 | 926 | "BGP keepalives\n") |
718e3744 | 927 | { |
d62a17ae | 928 | bgp_debug_list_free(bgp_debug_keepalive_peers); |
929 | ||
930 | if (vty->node == CONFIG_NODE) | |
931 | DEBUG_ON(keepalive, KEEPALIVE); | |
932 | else { | |
933 | TERM_DEBUG_ON(keepalive, KEEPALIVE); | |
934 | vty_out(vty, "BGP keepalives debugging is on\n"); | |
935 | } | |
936 | return CMD_SUCCESS; | |
718e3744 | 937 | } |
938 | ||
16286195 DS |
939 | DEFUN (debug_bgp_keepalive_peer, |
940 | debug_bgp_keepalive_peer_cmd, | |
6147e2c6 | 941 | "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 942 | DEBUG_STR |
943 | BGP_STR | |
bc6bc7a8 DA |
944 | "BGP keepalives\n" |
945 | "BGP IPv4 neighbor to debug\n" | |
16286195 DS |
946 | "BGP IPv6 neighbor to debug\n" |
947 | "BGP neighbor on interface to debug\n") | |
718e3744 | 948 | { |
d62a17ae | 949 | int idx_peer = 3; |
950 | const char *host = argv[idx_peer]->arg; | |
951 | ||
952 | if (!bgp_debug_keepalive_peers) | |
953 | bgp_debug_keepalive_peers = list_new(); | |
954 | ||
955 | if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers, host, NULL)) { | |
956 | vty_out(vty, | |
957 | "BGP keepalive debugging is already enabled for %s\n", | |
958 | host); | |
959 | return CMD_SUCCESS; | |
960 | } | |
961 | ||
962 | bgp_debug_list_add_entry(bgp_debug_keepalive_peers, host, NULL); | |
963 | ||
964 | if (vty->node == CONFIG_NODE) | |
965 | DEBUG_ON(keepalive, KEEPALIVE); | |
966 | else { | |
967 | TERM_DEBUG_ON(keepalive, KEEPALIVE); | |
968 | vty_out(vty, "BGP keepalives debugging is on for %s\n", host); | |
969 | } | |
970 | return CMD_SUCCESS; | |
718e3744 | 971 | } |
972 | ||
973 | DEFUN (no_debug_bgp_keepalive, | |
974 | no_debug_bgp_keepalive_cmd, | |
975 | "no debug bgp keepalives", | |
976 | NO_STR | |
977 | DEBUG_STR | |
978 | BGP_STR | |
979 | "BGP keepalives\n") | |
980 | { | |
d62a17ae | 981 | bgp_debug_list_free(bgp_debug_keepalive_peers); |
982 | ||
983 | if (vty->node == CONFIG_NODE) | |
984 | DEBUG_OFF(keepalive, KEEPALIVE); | |
985 | else { | |
986 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); | |
987 | vty_out(vty, "BGP keepalives debugging is off\n"); | |
988 | } | |
989 | return CMD_SUCCESS; | |
718e3744 | 990 | } |
991 | ||
16286195 DS |
992 | DEFUN (no_debug_bgp_keepalive_peer, |
993 | no_debug_bgp_keepalive_peer_cmd, | |
6147e2c6 | 994 | "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>", |
16286195 DS |
995 | NO_STR |
996 | DEBUG_STR | |
718e3744 | 997 | BGP_STR |
16286195 DS |
998 | "BGP keepalives\n" |
999 | "BGP neighbor IP address to debug\n" | |
1000 | "BGP IPv6 neighbor to debug\n" | |
1001 | "BGP neighbor on interface to debug\n") | |
1002 | { | |
d62a17ae | 1003 | int idx_peer = 4; |
1004 | int found_peer = 0; | |
1005 | const char *host = argv[idx_peer]->arg; | |
1006 | ||
1007 | if (bgp_debug_keepalive_peers | |
1008 | && !list_isempty(bgp_debug_keepalive_peers)) { | |
1009 | found_peer = bgp_debug_list_remove_entry( | |
1010 | bgp_debug_keepalive_peers, host, NULL); | |
1011 | ||
1012 | if (list_isempty(bgp_debug_keepalive_peers)) { | |
1013 | if (vty->node == CONFIG_NODE) | |
1014 | DEBUG_OFF(keepalive, KEEPALIVE); | |
1015 | else | |
1016 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); | |
1017 | } | |
1018 | } | |
1019 | ||
1020 | if (found_peer) | |
1021 | vty_out(vty, "BGP keepalives debugging is off for %s\n", host); | |
1022 | else | |
1023 | vty_out(vty, | |
1024 | "BGP keepalives debugging was not enabled for %s\n", | |
1025 | host); | |
1026 | ||
1027 | return CMD_SUCCESS; | |
16286195 DS |
1028 | } |
1029 | ||
9fbdd100 | 1030 | /* debug bgp bestpath */ |
ffd71765 | 1031 | DEFUN (debug_bgp_bestpath_prefix, |
9fbdd100 | 1032 | debug_bgp_bestpath_prefix_cmd, |
ffd71765 | 1033 | "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>", |
9fbdd100 DS |
1034 | DEBUG_STR |
1035 | BGP_STR | |
1036 | "BGP bestpath\n" | |
0c7b1b01 QY |
1037 | "IPv4 prefix\n" |
1038 | "IPv6 prefix\n") | |
9fbdd100 | 1039 | { |
0be4b77c DW |
1040 | struct prefix *argv_p; |
1041 | int idx_ipv4_ipv6_prefixlen = 3; | |
1042 | ||
1043 | argv_p = prefix_new(); | |
ffd71765 | 1044 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c DW |
1045 | apply_mask(argv_p); |
1046 | ||
d62a17ae | 1047 | if (!bgp_debug_bestpath_prefixes) |
1048 | bgp_debug_bestpath_prefixes = list_new(); | |
1049 | ||
1050 | if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, | |
ffd71765 | 1051 | argv_p)) { |
d62a17ae | 1052 | vty_out(vty, |
1053 | "BGP bestpath debugging is already enabled for %s\n", | |
ffd71765 | 1054 | argv[idx_ipv4_ipv6_prefixlen]->arg); |
d62a17ae | 1055 | return CMD_SUCCESS; |
1056 | } | |
1057 | ||
ffd71765 | 1058 | bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes, NULL, argv_p); |
d62a17ae | 1059 | |
1060 | if (vty->node == CONFIG_NODE) { | |
1061 | DEBUG_ON(bestpath, BESTPATH); | |
1062 | } else { | |
1063 | TERM_DEBUG_ON(bestpath, BESTPATH); | |
1064 | vty_out(vty, "BGP bestpath debugging is on for %s\n", | |
ffd71765 | 1065 | argv[idx_ipv4_ipv6_prefixlen]->arg); |
d62a17ae | 1066 | } |
1067 | ||
1068 | return CMD_SUCCESS; | |
9fbdd100 DS |
1069 | } |
1070 | ||
1071 | DEFUN (no_debug_bgp_bestpath_prefix, | |
1072 | no_debug_bgp_bestpath_prefix_cmd, | |
6147e2c6 | 1073 | "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>", |
9fbdd100 DS |
1074 | NO_STR |
1075 | DEBUG_STR | |
1076 | BGP_STR | |
1077 | "BGP bestpath\n" | |
0c7b1b01 QY |
1078 | "IPv4 prefix\n" |
1079 | "IPv6 prefix\n") | |
9fbdd100 | 1080 | { |
d62a17ae | 1081 | int idx_ipv4_ipv6_prefixlen = 4; |
1082 | struct prefix *argv_p; | |
1083 | int found_prefix = 0; | |
d62a17ae | 1084 | |
1085 | argv_p = prefix_new(); | |
ffd71765 | 1086 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c | 1087 | apply_mask(argv_p); |
d62a17ae | 1088 | |
1089 | if (bgp_debug_bestpath_prefixes | |
1090 | && !list_isempty(bgp_debug_bestpath_prefixes)) { | |
1091 | found_prefix = bgp_debug_list_remove_entry( | |
1092 | bgp_debug_bestpath_prefixes, NULL, argv_p); | |
1093 | ||
1094 | if (list_isempty(bgp_debug_bestpath_prefixes)) { | |
1095 | if (vty->node == CONFIG_NODE) { | |
1096 | DEBUG_OFF(bestpath, BESTPATH); | |
1097 | } else { | |
1098 | TERM_DEBUG_OFF(bestpath, BESTPATH); | |
1099 | vty_out(vty, | |
1100 | "BGP bestpath debugging (per prefix) is off\n"); | |
1101 | } | |
1102 | } | |
1103 | } | |
1104 | ||
1105 | if (found_prefix) | |
1106 | vty_out(vty, "BGP bestpath debugging is off for %s\n", | |
1107 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1108 | else | |
1109 | vty_out(vty, "BGP bestpath debugging was not enabled for %s\n", | |
1110 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1111 | ||
1112 | return CMD_SUCCESS; | |
9fbdd100 DS |
1113 | } |
1114 | ||
1115 | DEFUN (no_debug_bgp_bestpath, | |
1116 | no_debug_bgp_bestpath_cmd, | |
1117 | "no debug bgp bestpath", | |
1118 | NO_STR | |
1119 | DEBUG_STR | |
1120 | BGP_STR | |
1121 | "BGP bestpath\n") | |
1122 | { | |
d62a17ae | 1123 | bgp_debug_list_free(bgp_debug_bestpath_prefixes); |
1124 | ||
1125 | if (vty->node == CONFIG_NODE) | |
1126 | DEBUG_OFF(bestpath, BESTPATH); | |
1127 | else { | |
1128 | TERM_DEBUG_OFF(bestpath, BESTPATH); | |
1129 | vty_out(vty, "BGP bestpath debugging is off\n"); | |
1130 | } | |
1131 | return CMD_SUCCESS; | |
9fbdd100 DS |
1132 | } |
1133 | ||
16286195 | 1134 | /* debug bgp updates */ |
718e3744 | 1135 | DEFUN (debug_bgp_update, |
1136 | debug_bgp_update_cmd, | |
1137 | "debug bgp updates", | |
1138 | DEBUG_STR | |
1139 | BGP_STR | |
1140 | "BGP updates\n") | |
1141 | { | |
d62a17ae | 1142 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1143 | bgp_debug_list_free(bgp_debug_update_out_peers); | |
1144 | bgp_debug_list_free(bgp_debug_update_prefixes); | |
1145 | ||
1146 | if (vty->node == CONFIG_NODE) { | |
1147 | DEBUG_ON(update, UPDATE_IN); | |
1148 | DEBUG_ON(update, UPDATE_OUT); | |
1149 | } else { | |
1150 | TERM_DEBUG_ON(update, UPDATE_IN); | |
1151 | TERM_DEBUG_ON(update, UPDATE_OUT); | |
1152 | vty_out(vty, "BGP updates debugging is on\n"); | |
1153 | } | |
1154 | return CMD_SUCCESS; | |
718e3744 | 1155 | } |
1156 | ||
1157 | DEFUN (debug_bgp_update_direct, | |
1158 | debug_bgp_update_direct_cmd, | |
6147e2c6 | 1159 | "debug bgp updates <in|out>", |
718e3744 | 1160 | DEBUG_STR |
1161 | BGP_STR | |
1162 | "BGP updates\n" | |
1163 | "Inbound updates\n" | |
1164 | "Outbound updates\n") | |
1165 | { | |
d62a17ae | 1166 | int idx_in_out = 3; |
1167 | ||
1168 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) | |
1169 | bgp_debug_list_free(bgp_debug_update_in_peers); | |
1170 | else | |
1171 | bgp_debug_list_free(bgp_debug_update_out_peers); | |
1172 | ||
1173 | if (vty->node == CONFIG_NODE) { | |
1174 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) | |
1175 | DEBUG_ON(update, UPDATE_IN); | |
1176 | else | |
1177 | DEBUG_ON(update, UPDATE_OUT); | |
1178 | } else { | |
1179 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) { | |
1180 | TERM_DEBUG_ON(update, UPDATE_IN); | |
1181 | vty_out(vty, "BGP updates debugging is on (inbound)\n"); | |
1182 | } else { | |
1183 | TERM_DEBUG_ON(update, UPDATE_OUT); | |
1184 | vty_out(vty, | |
1185 | "BGP updates debugging is on (outbound)\n"); | |
1186 | } | |
1187 | } | |
1188 | return CMD_SUCCESS; | |
718e3744 | 1189 | } |
1190 | ||
16286195 DS |
1191 | DEFUN (debug_bgp_update_direct_peer, |
1192 | debug_bgp_update_direct_peer_cmd, | |
6147e2c6 | 1193 | "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 1194 | DEBUG_STR |
1195 | BGP_STR | |
16286195 DS |
1196 | "BGP updates\n" |
1197 | "Inbound updates\n" | |
1198 | "Outbound updates\n" | |
1199 | "BGP neighbor IP address to debug\n" | |
1200 | "BGP IPv6 neighbor to debug\n" | |
1201 | "BGP neighbor on interface to debug\n") | |
718e3744 | 1202 | { |
d62a17ae | 1203 | int idx_in_out = 3; |
1204 | int idx_peer = 4; | |
1205 | const char *host = argv[idx_peer]->arg; | |
1206 | int inbound; | |
1207 | ||
1208 | if (!bgp_debug_update_in_peers) | |
1209 | bgp_debug_update_in_peers = list_new(); | |
1210 | ||
1211 | if (!bgp_debug_update_out_peers) | |
1212 | bgp_debug_update_out_peers = list_new(); | |
1213 | ||
1214 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) | |
1215 | inbound = 1; | |
1216 | else | |
1217 | inbound = 0; | |
1218 | ||
1219 | if (inbound) { | |
1220 | if (bgp_debug_list_has_entry(bgp_debug_update_in_peers, host, | |
1221 | NULL)) { | |
1222 | vty_out(vty, | |
1223 | "BGP inbound update debugging is already enabled for %s\n", | |
1224 | host); | |
1225 | return CMD_SUCCESS; | |
1226 | } | |
1227 | } | |
1228 | ||
1229 | else { | |
1230 | if (bgp_debug_list_has_entry(bgp_debug_update_out_peers, host, | |
1231 | NULL)) { | |
1232 | vty_out(vty, | |
1233 | "BGP outbound update debugging is already enabled for %s\n", | |
1234 | host); | |
1235 | return CMD_SUCCESS; | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | if (inbound) | |
1240 | bgp_debug_list_add_entry(bgp_debug_update_in_peers, host, NULL); | |
1241 | else { | |
1242 | struct peer *peer; | |
1243 | struct peer_af *paf; | |
1244 | int afidx; | |
1245 | ||
1246 | bgp_debug_list_add_entry(bgp_debug_update_out_peers, host, | |
1247 | NULL); | |
1248 | peer = bgp_find_peer(vty, host); | |
1249 | ||
1250 | if (peer) { | |
1251 | for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; | |
1252 | afidx++) { | |
1253 | paf = peer->peer_af_array[afidx]; | |
1254 | if (paf != NULL) { | |
1255 | if (PAF_SUBGRP(paf)) { | |
1256 | UPDGRP_PEER_DBG_EN( | |
1257 | PAF_SUBGRP(paf) | |
1258 | ->update_group); | |
1259 | } | |
1260 | } | |
1261 | } | |
1262 | } | |
1263 | } | |
1264 | ||
1265 | if (vty->node == CONFIG_NODE) { | |
1266 | if (inbound) | |
1267 | DEBUG_ON(update, UPDATE_IN); | |
1268 | else | |
1269 | DEBUG_ON(update, UPDATE_OUT); | |
1270 | } else { | |
1271 | if (inbound) { | |
1272 | TERM_DEBUG_ON(update, UPDATE_IN); | |
1273 | vty_out(vty, | |
1274 | "BGP updates debugging is on (inbound) for %s\n", | |
1275 | argv[idx_peer]->arg); | |
1276 | } else { | |
1277 | TERM_DEBUG_ON(update, UPDATE_OUT); | |
1278 | vty_out(vty, | |
1279 | "BGP updates debugging is on (outbound) for %s\n", | |
1280 | argv[idx_peer]->arg); | |
1281 | } | |
1282 | } | |
1283 | return CMD_SUCCESS; | |
718e3744 | 1284 | } |
1285 | ||
91ba2c8b DS |
1286 | DEFUN (no_debug_bgp_update_direct, |
1287 | no_debug_bgp_update_direct_cmd, | |
6147e2c6 | 1288 | "no debug bgp updates <in|out>", |
91ba2c8b DS |
1289 | NO_STR |
1290 | DEBUG_STR | |
1291 | BGP_STR | |
1292 | "BGP updates\n" | |
1293 | "Inbound updates\n" | |
1294 | "Outbound updates\n") | |
1295 | { | |
d62a17ae | 1296 | int idx_in_out = 4; |
1297 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) { | |
1298 | bgp_debug_list_free(bgp_debug_update_in_peers); | |
1299 | ||
1300 | if (vty->node == CONFIG_NODE) { | |
1301 | DEBUG_OFF(update, UPDATE_IN); | |
1302 | } else { | |
1303 | TERM_DEBUG_OFF(update, UPDATE_IN); | |
1304 | vty_out(vty, | |
1305 | "BGP updates debugging is off (inbound)\n"); | |
1306 | } | |
1307 | } else { | |
1308 | bgp_debug_list_free(bgp_debug_update_out_peers); | |
1309 | ||
1310 | if (vty->node == CONFIG_NODE) { | |
1311 | DEBUG_OFF(update, UPDATE_OUT); | |
1312 | } else { | |
1313 | TERM_DEBUG_OFF(update, UPDATE_OUT); | |
1314 | vty_out(vty, | |
1315 | "BGP updates debugging is off (outbound)\n"); | |
1316 | } | |
1317 | } | |
1318 | ||
1319 | return CMD_SUCCESS; | |
91ba2c8b DS |
1320 | } |
1321 | ||
16286195 DS |
1322 | DEFUN (no_debug_bgp_update_direct_peer, |
1323 | no_debug_bgp_update_direct_peer_cmd, | |
6147e2c6 | 1324 | "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>", |
16286195 DS |
1325 | NO_STR |
1326 | DEBUG_STR | |
718e3744 | 1327 | BGP_STR |
16286195 DS |
1328 | "BGP updates\n" |
1329 | "Inbound updates\n" | |
1330 | "Outbound updates\n" | |
1331 | "BGP neighbor IP address to debug\n" | |
1332 | "BGP IPv6 neighbor to debug\n" | |
1333 | "BGP neighbor on interface to debug\n") | |
1334 | { | |
d62a17ae | 1335 | int idx_in_out = 4; |
1336 | int idx_peer = 5; | |
1337 | int inbound; | |
1338 | int found_peer = 0; | |
1339 | const char *host = argv[idx_peer]->arg; | |
1340 | ||
1341 | if (strncmp("i", argv[idx_in_out]->arg, 1) == 0) | |
1342 | inbound = 1; | |
1343 | else | |
1344 | inbound = 0; | |
1345 | ||
1346 | if (inbound && bgp_debug_update_in_peers | |
1347 | && !list_isempty(bgp_debug_update_in_peers)) { | |
1348 | found_peer = bgp_debug_list_remove_entry( | |
1349 | bgp_debug_update_in_peers, host, NULL); | |
1350 | ||
1351 | if (list_isempty(bgp_debug_update_in_peers)) { | |
1352 | if (vty->node == CONFIG_NODE) | |
1353 | DEBUG_OFF(update, UPDATE_IN); | |
1354 | else { | |
1355 | TERM_DEBUG_OFF(update, UPDATE_IN); | |
1356 | vty_out(vty, | |
1357 | "BGP updates debugging (inbound) is off\n"); | |
1358 | } | |
1359 | } | |
1360 | } | |
1361 | ||
1362 | if (!inbound && bgp_debug_update_out_peers | |
1363 | && !list_isempty(bgp_debug_update_out_peers)) { | |
1364 | found_peer = bgp_debug_list_remove_entry( | |
1365 | bgp_debug_update_out_peers, host, NULL); | |
1366 | ||
1367 | if (list_isempty(bgp_debug_update_out_peers)) { | |
1368 | if (vty->node == CONFIG_NODE) | |
1369 | DEBUG_OFF(update, UPDATE_OUT); | |
1370 | else { | |
1371 | TERM_DEBUG_OFF(update, UPDATE_OUT); | |
1372 | vty_out(vty, | |
1373 | "BGP updates debugging (outbound) is off\n"); | |
1374 | } | |
1375 | } | |
1376 | ||
1377 | struct peer *peer; | |
1378 | struct peer_af *paf; | |
1379 | int afidx; | |
1380 | peer = bgp_find_peer(vty, host); | |
1381 | ||
1382 | if (peer) { | |
1383 | for (afidx = BGP_AF_START; afidx < BGP_AF_MAX; | |
1384 | afidx++) { | |
1385 | paf = peer->peer_af_array[afidx]; | |
1386 | if (paf != NULL) { | |
1387 | if (PAF_SUBGRP(paf)) { | |
1388 | UPDGRP_PEER_DBG_DIS( | |
1389 | PAF_SUBGRP(paf) | |
1390 | ->update_group); | |
1391 | } | |
1392 | } | |
1393 | } | |
1394 | } | |
1395 | } | |
1396 | ||
1397 | if (found_peer) | |
1398 | if (inbound) | |
1399 | vty_out(vty, | |
1400 | "BGP updates debugging (inbound) is off for %s\n", | |
1401 | host); | |
1402 | else | |
1403 | vty_out(vty, | |
1404 | "BGP updates debugging (outbound) is off for %s\n", | |
1405 | host); | |
1406 | else if (inbound) | |
1407 | vty_out(vty, | |
1408 | "BGP updates debugging (inbound) was not enabled for %s\n", | |
1409 | host); | |
1410 | else | |
1411 | vty_out(vty, | |
1412 | "BGP updates debugging (outbound) was not enabled for %s\n", | |
1413 | host); | |
1414 | ||
1415 | return CMD_SUCCESS; | |
16286195 DS |
1416 | } |
1417 | ||
81cf0de5 | 1418 | #include "bgpd/bgp_debug_clippy.c" |
81cf0de5 CS |
1419 | |
1420 | DEFPY (debug_bgp_update_prefix_afi_safi, | |
1421 | debug_bgp_update_prefix_afi_safi_cmd, | |
15dc08a6 | 1422 | "debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>", |
81cf0de5 CS |
1423 | DEBUG_STR |
1424 | BGP_STR | |
1425 | "BGP updates\n" | |
1426 | "Specify a prefix to debug\n" | |
377e3565 QY |
1427 | L2VPN_HELP_STR |
1428 | EVPN_HELP_STR | |
31782fea SW |
1429 | EVPN_TYPE_HELP_STR |
1430 | EVPN_TYPE_2_HELP_STR | |
15dc08a6 | 1431 | EVPN_TYPE_2_HELP_STR |
377e3565 QY |
1432 | MAC_STR MAC_STR MAC_STR |
1433 | IP_STR | |
1434 | "IPv4 address\n" | |
1435 | "IPv6 address\n" | |
31782fea | 1436 | EVPN_TYPE_3_HELP_STR |
15dc08a6 | 1437 | EVPN_TYPE_3_HELP_STR |
377e3565 QY |
1438 | IP_STR |
1439 | "IPv4 address\n" | |
1440 | "IPv6 address\n" | |
31782fea | 1441 | EVPN_TYPE_5_HELP_STR |
15dc08a6 | 1442 | EVPN_TYPE_5_HELP_STR |
377e3565 QY |
1443 | IP_STR |
1444 | "IPv4 prefix\n" | |
1445 | "IPv6 prefix\n") | |
81cf0de5 | 1446 | { |
81cf0de5 CS |
1447 | struct prefix *argv_p; |
1448 | int ret = CMD_SUCCESS; | |
81cf0de5 CS |
1449 | |
1450 | argv_p = prefix_new(); | |
1451 | ||
377e3565 QY |
1452 | ret = bgp_debug_parse_evpn_prefix(vty, argv, argc, &argv_p); |
1453 | if (ret != CMD_SUCCESS) { | |
63265b5c | 1454 | prefix_free(&argv_p); |
377e3565 | 1455 | return ret; |
81cf0de5 CS |
1456 | } |
1457 | ||
1458 | if (!bgp_debug_update_prefixes) | |
1459 | bgp_debug_update_prefixes = list_new(); | |
1460 | ||
1461 | if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) { | |
1462 | vty_out(vty, | |
2dbe669b DA |
1463 | "BGP updates debugging is already enabled for %pFX\n", |
1464 | argv_p); | |
63265b5c | 1465 | prefix_free(&argv_p); |
377e3565 | 1466 | return CMD_SUCCESS; |
81cf0de5 CS |
1467 | } |
1468 | ||
1469 | bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, argv_p); | |
1470 | ||
1471 | if (vty->node == CONFIG_NODE) { | |
1472 | DEBUG_ON(update, UPDATE_PREFIX); | |
1473 | } else { | |
1474 | TERM_DEBUG_ON(update, UPDATE_PREFIX); | |
2dbe669b | 1475 | vty_out(vty, "BGP updates debugging is on for %pFX\n", argv_p); |
81cf0de5 CS |
1476 | } |
1477 | ||
63265b5c | 1478 | prefix_free(&argv_p); |
360f9703 | 1479 | |
377e3565 | 1480 | return CMD_SUCCESS; |
81cf0de5 CS |
1481 | } |
1482 | ||
1483 | DEFPY (no_debug_bgp_update_prefix_afi_safi, | |
1484 | no_debug_bgp_update_prefix_afi_safi_cmd, | |
15dc08a6 | 1485 | "no debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>", |
81cf0de5 CS |
1486 | NO_STR |
1487 | DEBUG_STR | |
1488 | BGP_STR | |
1489 | "BGP updates\n" | |
1490 | "Specify a prefix to debug\n" | |
377e3565 QY |
1491 | L2VPN_HELP_STR |
1492 | EVPN_HELP_STR | |
31782fea SW |
1493 | EVPN_TYPE_HELP_STR |
1494 | EVPN_TYPE_2_HELP_STR | |
15dc08a6 | 1495 | EVPN_TYPE_2_HELP_STR |
377e3565 QY |
1496 | MAC_STR MAC_STR MAC_STR |
1497 | IP_STR | |
1498 | "IPv4 address\n" | |
1499 | "IPv6 address\n" | |
31782fea | 1500 | EVPN_TYPE_3_HELP_STR |
15dc08a6 | 1501 | EVPN_TYPE_3_HELP_STR |
377e3565 QY |
1502 | IP_STR |
1503 | "IPv4 address\n" | |
1504 | "IPv6 address\n" | |
31782fea | 1505 | EVPN_TYPE_5_HELP_STR |
15dc08a6 | 1506 | EVPN_TYPE_5_HELP_STR |
377e3565 QY |
1507 | IP_STR |
1508 | "IPv4 prefix\n" | |
1509 | "IPv6 prefix\n") | |
81cf0de5 | 1510 | { |
81cf0de5 | 1511 | struct prefix *argv_p; |
377e3565 | 1512 | bool found_prefix = false; |
81cf0de5 | 1513 | int ret = CMD_SUCCESS; |
81cf0de5 CS |
1514 | |
1515 | argv_p = prefix_new(); | |
1516 | ||
377e3565 QY |
1517 | ret = bgp_debug_parse_evpn_prefix(vty, argv, argc, &argv_p); |
1518 | if (ret != CMD_SUCCESS) { | |
63265b5c | 1519 | prefix_free(&argv_p); |
377e3565 | 1520 | return ret; |
81cf0de5 CS |
1521 | } |
1522 | ||
1523 | if (bgp_debug_update_prefixes | |
1524 | && !list_isempty(bgp_debug_update_prefixes)) { | |
1525 | found_prefix = bgp_debug_list_remove_entry( | |
1526 | bgp_debug_update_prefixes, NULL, argv_p); | |
1527 | ||
1528 | if (list_isempty(bgp_debug_update_prefixes)) { | |
1529 | if (vty->node == CONFIG_NODE) { | |
1530 | DEBUG_OFF(update, UPDATE_PREFIX); | |
1531 | } else { | |
1532 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); | |
1533 | vty_out(vty, | |
1534 | "BGP updates debugging (per prefix) is off\n"); | |
1535 | } | |
1536 | } | |
1537 | } | |
1538 | ||
1539 | if (found_prefix) | |
2dbe669b | 1540 | vty_out(vty, "BGP updates debugging is off for %pFX\n", argv_p); |
81cf0de5 | 1541 | else |
2dbe669b DA |
1542 | vty_out(vty, "BGP updates debugging was not enabled for %pFX\n", |
1543 | argv_p); | |
81cf0de5 | 1544 | |
63265b5c | 1545 | prefix_free(&argv_p); |
360f9703 A |
1546 | |
1547 | return ret; | |
81cf0de5 CS |
1548 | } |
1549 | ||
1550 | ||
16286195 DS |
1551 | DEFUN (debug_bgp_update_prefix, |
1552 | debug_bgp_update_prefix_cmd, | |
6147e2c6 | 1553 | "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>", |
718e3744 | 1554 | DEBUG_STR |
16286195 DS |
1555 | BGP_STR |
1556 | "BGP updates\n" | |
1557 | "Specify a prefix to debug\n" | |
0c7b1b01 QY |
1558 | "IPv4 prefix\n" |
1559 | "IPv6 prefix\n") | |
718e3744 | 1560 | { |
d62a17ae | 1561 | int idx_ipv4_ipv6_prefixlen = 4; |
1562 | struct prefix *argv_p; | |
d62a17ae | 1563 | |
1564 | argv_p = prefix_new(); | |
ffd71765 | 1565 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c | 1566 | apply_mask(argv_p); |
d62a17ae | 1567 | |
1568 | if (!bgp_debug_update_prefixes) | |
1569 | bgp_debug_update_prefixes = list_new(); | |
1570 | ||
1571 | if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) { | |
1572 | vty_out(vty, | |
1573 | "BGP updates debugging is already enabled for %s\n", | |
1574 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1575 | return CMD_SUCCESS; | |
1576 | } | |
1577 | ||
1578 | bgp_debug_list_add_entry(bgp_debug_update_prefixes, NULL, argv_p); | |
1579 | ||
1580 | if (vty->node == CONFIG_NODE) { | |
1581 | DEBUG_ON(update, UPDATE_PREFIX); | |
1582 | } else { | |
1583 | TERM_DEBUG_ON(update, UPDATE_PREFIX); | |
1584 | vty_out(vty, "BGP updates debugging is on for %s\n", | |
1585 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1586 | } | |
1587 | ||
1588 | return CMD_SUCCESS; | |
718e3744 | 1589 | } |
1590 | ||
16286195 DS |
1591 | DEFUN (no_debug_bgp_update_prefix, |
1592 | no_debug_bgp_update_prefix_cmd, | |
6147e2c6 | 1593 | "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>", |
718e3744 | 1594 | NO_STR |
1595 | DEBUG_STR | |
16286195 DS |
1596 | BGP_STR |
1597 | "BGP updates\n" | |
1598 | "Specify a prefix to debug\n" | |
0c7b1b01 QY |
1599 | "IPv4 prefix\n" |
1600 | "IPv6 prefix\n") | |
16286195 | 1601 | { |
d62a17ae | 1602 | int idx_ipv4_ipv6_prefixlen = 5; |
1603 | struct prefix *argv_p; | |
1604 | int found_prefix = 0; | |
d62a17ae | 1605 | |
1606 | argv_p = prefix_new(); | |
ffd71765 | 1607 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c | 1608 | apply_mask(argv_p); |
d62a17ae | 1609 | |
1610 | if (bgp_debug_update_prefixes | |
1611 | && !list_isempty(bgp_debug_update_prefixes)) { | |
1612 | found_prefix = bgp_debug_list_remove_entry( | |
1613 | bgp_debug_update_prefixes, NULL, argv_p); | |
1614 | ||
1615 | if (list_isempty(bgp_debug_update_prefixes)) { | |
1616 | if (vty->node == CONFIG_NODE) { | |
1617 | DEBUG_OFF(update, UPDATE_PREFIX); | |
1618 | } else { | |
1619 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); | |
1620 | vty_out(vty, | |
1621 | "BGP updates debugging (per prefix) is off\n"); | |
1622 | } | |
1623 | } | |
1624 | } | |
1625 | ||
1626 | if (found_prefix) | |
1627 | vty_out(vty, "BGP updates debugging is off for %s\n", | |
1628 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1629 | else | |
1630 | vty_out(vty, "BGP updates debugging was not enabled for %s\n", | |
1631 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1632 | ||
1633 | return CMD_SUCCESS; | |
16286195 DS |
1634 | } |
1635 | ||
1636 | DEFUN (no_debug_bgp_update, | |
1637 | no_debug_bgp_update_cmd, | |
1638 | "no debug bgp updates", | |
1639 | NO_STR | |
1640 | DEBUG_STR | |
1641 | BGP_STR | |
1642 | "BGP updates\n") | |
718e3744 | 1643 | { |
87f42c2c QY |
1644 | struct listnode *ln; |
1645 | struct bgp *bgp; | |
1646 | ||
d62a17ae | 1647 | bgp_debug_list_free(bgp_debug_update_in_peers); |
1648 | bgp_debug_list_free(bgp_debug_update_out_peers); | |
1649 | bgp_debug_list_free(bgp_debug_update_prefixes); | |
1650 | ||
87f42c2c QY |
1651 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, ln, bgp)) |
1652 | bgp_debug_clear_updgrp_update_dbg(bgp); | |
d62a17ae | 1653 | |
1654 | if (vty->node == CONFIG_NODE) { | |
1655 | DEBUG_OFF(update, UPDATE_IN); | |
1656 | DEBUG_OFF(update, UPDATE_OUT); | |
1657 | DEBUG_OFF(update, UPDATE_PREFIX); | |
1658 | } else { | |
1659 | TERM_DEBUG_OFF(update, UPDATE_IN); | |
1660 | TERM_DEBUG_OFF(update, UPDATE_OUT); | |
1661 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); | |
1662 | vty_out(vty, "BGP updates debugging is off\n"); | |
1663 | } | |
1664 | return CMD_SUCCESS; | |
718e3744 | 1665 | } |
1666 | ||
16286195 | 1667 | /* debug bgp zebra */ |
a39275d7 AS |
1668 | DEFUN (debug_bgp_zebra, |
1669 | debug_bgp_zebra_cmd, | |
1670 | "debug bgp zebra", | |
1671 | DEBUG_STR | |
1672 | BGP_STR | |
1673 | "BGP Zebra messages\n") | |
1674 | { | |
d62a17ae | 1675 | if (vty->node == CONFIG_NODE) |
1676 | DEBUG_ON(zebra, ZEBRA); | |
1677 | else { | |
1678 | TERM_DEBUG_ON(zebra, ZEBRA); | |
1679 | vty_out(vty, "BGP zebra debugging is on\n"); | |
1680 | } | |
1681 | return CMD_SUCCESS; | |
a39275d7 AS |
1682 | } |
1683 | ||
794b37d5 | 1684 | DEFUN (debug_bgp_graceful_restart, |
1685 | debug_bgp_graceful_restart_cmd, | |
1686 | "debug bgp graceful-restart", | |
1687 | DEBUG_STR | |
1688 | BGP_STR | |
1689 | GR_DEBUG) | |
1690 | { | |
1691 | if (vty->node == CONFIG_NODE) { | |
1692 | DEBUG_ON(graceful_restart, GRACEFUL_RESTART); | |
1693 | } else { | |
1694 | TERM_DEBUG_ON(graceful_restart, GRACEFUL_RESTART); | |
1695 | vty_out(vty, "BGP Graceful Restart debugging is on\n"); | |
1696 | } | |
1697 | return CMD_SUCCESS; | |
1698 | } | |
1699 | ||
1700 | ||
16286195 DS |
1701 | DEFUN (debug_bgp_zebra_prefix, |
1702 | debug_bgp_zebra_prefix_cmd, | |
6147e2c6 | 1703 | "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>", |
16286195 DS |
1704 | DEBUG_STR |
1705 | BGP_STR | |
1706 | "BGP Zebra messages\n" | |
1707 | "Specify a prefix to debug\n" | |
0c7b1b01 QY |
1708 | "IPv4 prefix\n" |
1709 | "IPv6 prefix\n") | |
16286195 | 1710 | { |
d62a17ae | 1711 | int idx_ipv4_ipv6_prefixlen = 4; |
1712 | struct prefix *argv_p; | |
d62a17ae | 1713 | |
1714 | argv_p = prefix_new(); | |
ffd71765 | 1715 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c | 1716 | apply_mask(argv_p); |
d62a17ae | 1717 | |
1718 | if (!bgp_debug_zebra_prefixes) | |
1719 | bgp_debug_zebra_prefixes = list_new(); | |
1720 | ||
1721 | if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p)) { | |
1722 | vty_out(vty, "BGP zebra debugging is already enabled for %s\n", | |
1723 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1724 | return CMD_SUCCESS; | |
1725 | } | |
1726 | ||
1727 | bgp_debug_list_add_entry(bgp_debug_zebra_prefixes, NULL, argv_p); | |
1728 | ||
1729 | if (vty->node == CONFIG_NODE) | |
1730 | DEBUG_ON(zebra, ZEBRA); | |
1731 | else { | |
1732 | TERM_DEBUG_ON(zebra, ZEBRA); | |
1733 | vty_out(vty, "BGP zebra debugging is on for %s\n", | |
1734 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1735 | } | |
1736 | ||
1737 | return CMD_SUCCESS; | |
16286195 DS |
1738 | } |
1739 | ||
a39275d7 AS |
1740 | DEFUN (no_debug_bgp_zebra, |
1741 | no_debug_bgp_zebra_cmd, | |
1742 | "no debug bgp zebra", | |
1743 | NO_STR | |
1744 | DEBUG_STR | |
1745 | BGP_STR | |
1746 | "BGP Zebra messages\n") | |
1747 | { | |
d62a17ae | 1748 | bgp_debug_list_free(bgp_debug_zebra_prefixes); |
1749 | ||
1750 | if (vty->node == CONFIG_NODE) | |
1751 | DEBUG_OFF(zebra, ZEBRA); | |
1752 | else { | |
1753 | TERM_DEBUG_OFF(zebra, ZEBRA); | |
1754 | vty_out(vty, "BGP zebra debugging is off\n"); | |
1755 | } | |
1756 | return CMD_SUCCESS; | |
a39275d7 AS |
1757 | } |
1758 | ||
794b37d5 | 1759 | DEFUN (no_debug_bgp_graceful_restart, |
1760 | no_debug_bgp_graceful_restart_cmd, | |
1761 | "no debug bgp graceful-restart", | |
1762 | DEBUG_STR | |
1763 | BGP_STR | |
1764 | GR_DEBUG | |
1765 | NO_STR) | |
1766 | { | |
1767 | if (vty->node == CONFIG_NODE) { | |
1768 | DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); | |
1769 | } else { | |
1770 | TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); | |
1771 | vty_out(vty, "BGP Graceful Restart debugging is off\n"); | |
1772 | } | |
1773 | return CMD_SUCCESS; | |
1774 | } | |
1775 | ||
16286195 DS |
1776 | DEFUN (no_debug_bgp_zebra_prefix, |
1777 | no_debug_bgp_zebra_prefix_cmd, | |
6147e2c6 | 1778 | "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>", |
16286195 DS |
1779 | NO_STR |
1780 | DEBUG_STR | |
a39275d7 | 1781 | BGP_STR |
16286195 DS |
1782 | "BGP Zebra messages\n" |
1783 | "Specify a prefix to debug\n" | |
0c7b1b01 QY |
1784 | "IPv4 prefix\n" |
1785 | "IPv6 prefix\n") | |
16286195 | 1786 | { |
d62a17ae | 1787 | int idx_ipv4_ipv6_prefixlen = 5; |
1788 | struct prefix *argv_p; | |
1789 | int found_prefix = 0; | |
d62a17ae | 1790 | |
1791 | argv_p = prefix_new(); | |
ffd71765 | 1792 | (void)str2prefix(argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p); |
0be4b77c | 1793 | apply_mask(argv_p); |
d62a17ae | 1794 | |
1795 | if (bgp_debug_zebra_prefixes | |
1796 | && !list_isempty(bgp_debug_zebra_prefixes)) { | |
1797 | found_prefix = bgp_debug_list_remove_entry( | |
1798 | bgp_debug_zebra_prefixes, NULL, argv_p); | |
1799 | ||
1800 | if (list_isempty(bgp_debug_zebra_prefixes)) { | |
1801 | if (vty->node == CONFIG_NODE) | |
1802 | DEBUG_OFF(zebra, ZEBRA); | |
1803 | else { | |
1804 | TERM_DEBUG_OFF(zebra, ZEBRA); | |
1805 | vty_out(vty, "BGP zebra debugging is off\n"); | |
1806 | } | |
1807 | } | |
1808 | } | |
1809 | ||
1810 | if (found_prefix) | |
1811 | vty_out(vty, "BGP zebra debugging is off for %s\n", | |
1812 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1813 | else | |
1814 | vty_out(vty, "BGP zebra debugging was not enabled for %s\n", | |
1815 | argv[idx_ipv4_ipv6_prefixlen]->arg); | |
1816 | ||
1817 | return CMD_SUCCESS; | |
16286195 DS |
1818 | } |
1819 | ||
3f9c7369 DS |
1820 | /* debug bgp update-groups */ |
1821 | DEFUN (debug_bgp_update_groups, | |
1822 | debug_bgp_update_groups_cmd, | |
1823 | "debug bgp update-groups", | |
1824 | DEBUG_STR | |
1825 | BGP_STR | |
1826 | "BGP update-groups\n") | |
1827 | { | |
d62a17ae | 1828 | if (vty->node == CONFIG_NODE) |
1829 | DEBUG_ON(update_groups, UPDATE_GROUPS); | |
1830 | else { | |
1831 | TERM_DEBUG_ON(update_groups, UPDATE_GROUPS); | |
1832 | vty_out(vty, "BGP update-groups debugging is on\n"); | |
1833 | } | |
1834 | return CMD_SUCCESS; | |
3f9c7369 DS |
1835 | } |
1836 | ||
1837 | DEFUN (no_debug_bgp_update_groups, | |
1838 | no_debug_bgp_update_groups_cmd, | |
1839 | "no debug bgp update-groups", | |
1840 | NO_STR | |
1841 | DEBUG_STR | |
1842 | BGP_STR | |
1843 | "BGP update-groups\n") | |
1844 | { | |
d62a17ae | 1845 | if (vty->node == CONFIG_NODE) |
1846 | DEBUG_OFF(update_groups, UPDATE_GROUPS); | |
1847 | else { | |
1848 | TERM_DEBUG_OFF(update_groups, UPDATE_GROUPS); | |
1849 | vty_out(vty, "BGP update-groups debugging is off\n"); | |
1850 | } | |
1851 | return CMD_SUCCESS; | |
3f9c7369 DS |
1852 | } |
1853 | ||
ddb5b488 PZ |
1854 | DEFUN (debug_bgp_vpn, |
1855 | debug_bgp_vpn_cmd, | |
1856 | "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>", | |
1857 | DEBUG_STR | |
1858 | BGP_STR | |
1859 | "VPN routes\n" | |
1860 | "leaked from vrf to vpn\n" | |
1861 | "leaked to vrf from vpn\n" | |
1862 | "route-map updates\n" | |
1863 | "labels\n") | |
1864 | { | |
1865 | int idx = 3; | |
1866 | ||
1867 | if (argv_find(argv, argc, "leak-from-vrf", &idx)) { | |
1868 | if (vty->node == CONFIG_NODE) | |
1869 | DEBUG_ON(vpn, VPN_LEAK_FROM_VRF); | |
1870 | else | |
1871 | TERM_DEBUG_ON(vpn, VPN_LEAK_FROM_VRF); | |
1872 | } else if (argv_find(argv, argc, "leak-to-vrf", &idx)) { | |
1873 | if (vty->node == CONFIG_NODE) | |
1874 | DEBUG_ON(vpn, VPN_LEAK_TO_VRF); | |
1875 | else | |
1876 | TERM_DEBUG_ON(vpn, VPN_LEAK_TO_VRF); | |
1877 | } else if (argv_find(argv, argc, "rmap-event", &idx)) { | |
1878 | if (vty->node == CONFIG_NODE) | |
1879 | DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT); | |
1880 | else | |
1881 | TERM_DEBUG_ON(vpn, VPN_LEAK_RMAP_EVENT); | |
1882 | } else if (argv_find(argv, argc, "label", &idx)) { | |
1883 | if (vty->node == CONFIG_NODE) | |
1884 | DEBUG_ON(vpn, VPN_LEAK_LABEL); | |
1885 | else | |
1886 | TERM_DEBUG_ON(vpn, VPN_LEAK_LABEL); | |
1887 | } else { | |
1888 | vty_out(vty, "%% unknown debug bgp vpn keyword\n"); | |
1889 | return CMD_WARNING_CONFIG_FAILED; | |
1890 | } | |
1891 | ||
1892 | if (vty->node != CONFIG_NODE) | |
1893 | vty_out(vty, "enabled debug bgp vpn %s\n", argv[idx]->text); | |
1894 | ||
1895 | return CMD_SUCCESS; | |
1896 | } | |
1897 | ||
1898 | DEFUN (no_debug_bgp_vpn, | |
1899 | no_debug_bgp_vpn_cmd, | |
1900 | "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>", | |
1901 | NO_STR | |
1902 | DEBUG_STR | |
1903 | BGP_STR | |
1904 | "VPN routes\n" | |
1905 | "leaked from vrf to vpn\n" | |
1906 | "leaked to vrf from vpn\n" | |
1907 | "route-map updates\n" | |
1908 | "labels\n") | |
1909 | { | |
1910 | int idx = 4; | |
1911 | ||
1912 | if (argv_find(argv, argc, "leak-from-vrf", &idx)) { | |
1913 | if (vty->node == CONFIG_NODE) | |
1914 | DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); | |
1915 | else | |
1916 | TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); | |
1917 | ||
1918 | } else if (argv_find(argv, argc, "leak-to-vrf", &idx)) { | |
1919 | if (vty->node == CONFIG_NODE) | |
1920 | DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); | |
1921 | else | |
1922 | TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); | |
1923 | } else if (argv_find(argv, argc, "rmap-event", &idx)) { | |
1924 | if (vty->node == CONFIG_NODE) | |
1925 | DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); | |
1926 | else | |
1927 | TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); | |
1928 | } else if (argv_find(argv, argc, "label", &idx)) { | |
1929 | if (vty->node == CONFIG_NODE) | |
1930 | DEBUG_OFF(vpn, VPN_LEAK_LABEL); | |
1931 | else | |
1932 | TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL); | |
1933 | } else { | |
1934 | vty_out(vty, "%% unknown debug bgp vpn keyword\n"); | |
1935 | return CMD_WARNING_CONFIG_FAILED; | |
1936 | } | |
1937 | ||
1938 | if (vty->node != CONFIG_NODE) | |
1939 | vty_out(vty, "disabled debug bgp vpn %s\n", argv[idx]->text); | |
1a80fc0f PG |
1940 | return CMD_SUCCESS; |
1941 | } | |
ddb5b488 | 1942 | |
1a80fc0f PG |
1943 | /* debug bgp pbr */ |
1944 | DEFUN (debug_bgp_pbr, | |
1945 | debug_bgp_pbr_cmd, | |
e9d0aa99 | 1946 | "debug bgp pbr [error]", |
1a80fc0f PG |
1947 | DEBUG_STR |
1948 | BGP_STR | |
e9d0aa99 PG |
1949 | "BGP policy based routing\n" |
1950 | "BGP PBR error\n") | |
1a80fc0f | 1951 | { |
e9d0aa99 PG |
1952 | int idx = 3; |
1953 | ||
1954 | if (argv_find(argv, argc, "error", &idx)) { | |
1955 | if (vty->node == CONFIG_NODE) | |
1956 | DEBUG_ON(pbr, PBR_ERROR); | |
1957 | else { | |
1958 | TERM_DEBUG_ON(pbr, PBR_ERROR); | |
1959 | vty_out(vty, "BGP policy based routing error is on\n"); | |
1960 | } | |
1961 | return CMD_SUCCESS; | |
1962 | } | |
1a80fc0f PG |
1963 | if (vty->node == CONFIG_NODE) |
1964 | DEBUG_ON(pbr, PBR); | |
1965 | else { | |
1966 | TERM_DEBUG_ON(pbr, PBR); | |
1967 | vty_out(vty, "BGP policy based routing is on\n"); | |
1968 | } | |
1969 | return CMD_SUCCESS; | |
1970 | } | |
1971 | ||
1972 | DEFUN (no_debug_bgp_pbr, | |
1973 | no_debug_bgp_pbr_cmd, | |
e9d0aa99 | 1974 | "no debug bgp pbr [error]", |
1a80fc0f PG |
1975 | NO_STR |
1976 | DEBUG_STR | |
1977 | BGP_STR | |
e9d0aa99 PG |
1978 | "BGP policy based routing\n" |
1979 | "BGP PBR Error\n") | |
1a80fc0f | 1980 | { |
e9d0aa99 PG |
1981 | int idx = 3; |
1982 | ||
1983 | if (argv_find(argv, argc, "error", &idx)) { | |
1984 | if (vty->node == CONFIG_NODE) | |
1985 | DEBUG_OFF(pbr, PBR_ERROR); | |
1986 | else { | |
1987 | TERM_DEBUG_OFF(pbr, PBR_ERROR); | |
1988 | vty_out(vty, "BGP policy based routing error is off\n"); | |
1989 | } | |
1990 | return CMD_SUCCESS; | |
1991 | } | |
1a80fc0f PG |
1992 | if (vty->node == CONFIG_NODE) |
1993 | DEBUG_OFF(pbr, PBR); | |
1994 | else { | |
1995 | TERM_DEBUG_OFF(pbr, PBR); | |
1996 | vty_out(vty, "BGP policy based routing is off\n"); | |
1997 | } | |
ddb5b488 PZ |
1998 | return CMD_SUCCESS; |
1999 | } | |
2000 | ||
52653398 AK |
2001 | DEFPY (debug_bgp_evpn_mh, |
2002 | debug_bgp_evpn_mh_cmd, | |
2003 | "[no$no] debug bgp evpn mh <es$es|route$rt>", | |
2004 | NO_STR | |
2005 | DEBUG_STR | |
2006 | BGP_STR | |
2007 | "EVPN\n" | |
2008 | "Multihoming\n" | |
2009 | "Ethernet Segment debugging\n" | |
2010 | "Route debugging\n") | |
2011 | { | |
2012 | if (es) { | |
2013 | if (vty->node == CONFIG_NODE) { | |
2014 | if (no) | |
2015 | DEBUG_OFF(evpn_mh, EVPN_MH_ES); | |
2016 | else | |
2017 | DEBUG_ON(evpn_mh, EVPN_MH_ES); | |
2018 | } else { | |
2019 | if (no) { | |
2020 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES); | |
2021 | vty_out(vty, | |
2022 | "BGP EVPN-MH ES debugging is off\n"); | |
2023 | } else { | |
2024 | TERM_DEBUG_ON(evpn_mh, EVPN_MH_ES); | |
2025 | vty_out(vty, | |
2026 | "BGP EVPN-MH ES debugging is on\n"); | |
2027 | } | |
2028 | } | |
2029 | } | |
2030 | if (rt) { | |
2031 | if (vty->node == CONFIG_NODE) { | |
2032 | if (no) | |
2033 | DEBUG_OFF(evpn_mh, EVPN_MH_RT); | |
2034 | else | |
2035 | DEBUG_ON(evpn_mh, EVPN_MH_RT); | |
2036 | } else { | |
2037 | if (no) { | |
2038 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT); | |
2039 | vty_out(vty, | |
2040 | "BGP EVPN-MH route debugging is off\n"); | |
2041 | } else { | |
2042 | TERM_DEBUG_ON(evpn_mh, EVPN_MH_RT); | |
2043 | vty_out(vty, | |
2044 | "BGP EVPN-MH route debugging is on\n"); | |
2045 | } | |
2046 | } | |
2047 | } | |
2048 | ||
2049 | return CMD_SUCCESS; | |
2050 | } | |
2051 | ||
70cd87ca MK |
2052 | DEFPY (debug_bgp_optimal_route_reflection, |
2053 | debug_bgp_optimal_route_reflection_cmd, | |
2054 | "[no$no] debug bgp optimal-route-reflection", | |
2055 | NO_STR | |
2056 | DEBUG_STR | |
2057 | BGP_STR | |
2058 | BGP_ORR_DEBUG) | |
2059 | { | |
2060 | if (vty->node == CONFIG_NODE) { | |
2061 | if (no) | |
2062 | DEBUG_OFF(optimal_route_reflection, ORR); | |
2063 | else | |
2064 | DEBUG_ON(optimal_route_reflection, ORR); | |
2065 | } else { | |
2066 | if (no) { | |
2067 | TERM_DEBUG_OFF(optimal_route_reflection, ORR); | |
2068 | vty_out(vty, | |
2069 | "BGP Optimal Route Reflection debugging is off\n"); | |
2070 | } else { | |
2071 | TERM_DEBUG_ON(optimal_route_reflection, ORR); | |
2072 | vty_out(vty, | |
2073 | "BGP Optimal Route Reflection debugging is on\n"); | |
2074 | } | |
2075 | } | |
2076 | return CMD_SUCCESS; | |
2077 | } | |
2078 | ||
955bfd98 PZ |
2079 | DEFUN (debug_bgp_labelpool, |
2080 | debug_bgp_labelpool_cmd, | |
2081 | "debug bgp labelpool", | |
2082 | DEBUG_STR | |
2083 | BGP_STR | |
2084 | "label pool\n") | |
2085 | { | |
2086 | if (vty->node == CONFIG_NODE) | |
2087 | DEBUG_ON(labelpool, LABELPOOL); | |
2088 | else | |
2089 | TERM_DEBUG_ON(labelpool, LABELPOOL); | |
2090 | ||
2091 | if (vty->node != CONFIG_NODE) | |
2092 | vty_out(vty, "enabled debug bgp labelpool\n"); | |
2093 | ||
2094 | return CMD_SUCCESS; | |
2095 | } | |
2096 | ||
2097 | DEFUN (no_debug_bgp_labelpool, | |
2098 | no_debug_bgp_labelpool_cmd, | |
2099 | "no debug bgp labelpool", | |
2100 | NO_STR | |
2101 | DEBUG_STR | |
2102 | BGP_STR | |
2103 | "label pool\n") | |
2104 | { | |
2105 | if (vty->node == CONFIG_NODE) | |
2106 | DEBUG_OFF(labelpool, LABELPOOL); | |
2107 | else | |
2108 | TERM_DEBUG_OFF(labelpool, LABELPOOL); | |
2109 | ||
2110 | ||
2111 | if (vty->node != CONFIG_NODE) | |
2112 | vty_out(vty, "disabled debug bgp labelpool\n"); | |
2113 | ||
2114 | return CMD_SUCCESS; | |
2115 | } | |
2116 | ||
259f4236 RZ |
2117 | DEFPY(debug_bgp_bfd, debug_bgp_bfd_cmd, |
2118 | "[no] debug bgp bfd", | |
2119 | NO_STR | |
2120 | DEBUG_STR | |
2121 | BGP_STR | |
2122 | "Bidirection Forwarding Detection\n") | |
2123 | { | |
2124 | if (vty->node == CONFIG_NODE) { | |
2125 | if (no) { | |
2126 | DEBUG_OFF(bfd, BFD_LIB); | |
2127 | bfd_protocol_integration_set_debug(false); | |
2128 | } else { | |
2129 | DEBUG_ON(bfd, BFD_LIB); | |
2130 | bfd_protocol_integration_set_debug(true); | |
2131 | } | |
2132 | } else { | |
edc0d8cf | 2133 | if (no) { |
259f4236 | 2134 | TERM_DEBUG_OFF(bfd, BFD_LIB); |
edc0d8cf IR |
2135 | bfd_protocol_integration_set_debug(false); |
2136 | } else { | |
259f4236 | 2137 | TERM_DEBUG_ON(bfd, BFD_LIB); |
edc0d8cf IR |
2138 | bfd_protocol_integration_set_debug(true); |
2139 | } | |
259f4236 RZ |
2140 | } |
2141 | ||
2142 | return CMD_SUCCESS; | |
2143 | } | |
2144 | ||
8093d799 MK |
2145 | DEFPY (debug_bgp_cond_adv, |
2146 | debug_bgp_cond_adv_cmd, | |
2147 | "[no$no] debug bgp conditional-advertisement", | |
2148 | NO_STR | |
2149 | DEBUG_STR | |
2150 | BGP_STR | |
2151 | "BGP conditional advertisement\n") | |
2152 | { | |
2153 | if (vty->node == CONFIG_NODE) { | |
2154 | if (no) | |
2155 | DEBUG_OFF(cond_adv, COND_ADV); | |
2156 | else | |
2157 | DEBUG_ON(cond_adv, COND_ADV); | |
2158 | } else { | |
2159 | if (no) { | |
2160 | TERM_DEBUG_OFF(cond_adv, COND_ADV); | |
2161 | vty_out(vty, | |
2162 | "BGP conditional advertisement debugging is off\n"); | |
2163 | } else { | |
2164 | TERM_DEBUG_ON(cond_adv, COND_ADV); | |
2165 | vty_out(vty, | |
2166 | "BGP conditional advertisement debugging is on\n"); | |
2167 | } | |
2168 | } | |
2169 | return CMD_SUCCESS; | |
2170 | } | |
2171 | ||
16286195 DS |
2172 | DEFUN (no_debug_bgp, |
2173 | no_debug_bgp_cmd, | |
2174 | "no debug bgp", | |
718e3744 | 2175 | NO_STR |
2176 | DEBUG_STR | |
718e3744 | 2177 | BGP_STR) |
2178 | { | |
87f42c2c QY |
2179 | struct bgp *bgp; |
2180 | struct listnode *ln; | |
2181 | ||
d62a17ae | 2182 | bgp_debug_list_free(bgp_debug_neighbor_events_peers); |
2183 | bgp_debug_list_free(bgp_debug_keepalive_peers); | |
2184 | bgp_debug_list_free(bgp_debug_update_in_peers); | |
2185 | bgp_debug_list_free(bgp_debug_update_out_peers); | |
2186 | bgp_debug_list_free(bgp_debug_update_prefixes); | |
2187 | bgp_debug_list_free(bgp_debug_bestpath_prefixes); | |
2188 | bgp_debug_list_free(bgp_debug_zebra_prefixes); | |
2189 | ||
87f42c2c QY |
2190 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, ln, bgp)) |
2191 | bgp_debug_clear_updgrp_update_dbg(bgp); | |
d62a17ae | 2192 | |
2193 | TERM_DEBUG_OFF(keepalive, KEEPALIVE); | |
2194 | TERM_DEBUG_OFF(update, UPDATE_IN); | |
2195 | TERM_DEBUG_OFF(update, UPDATE_OUT); | |
2196 | TERM_DEBUG_OFF(update, UPDATE_PREFIX); | |
2197 | TERM_DEBUG_OFF(bestpath, BESTPATH); | |
2198 | TERM_DEBUG_OFF(as4, AS4); | |
2199 | TERM_DEBUG_OFF(as4, AS4_SEGMENT); | |
2200 | TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS); | |
2201 | TERM_DEBUG_OFF(zebra, ZEBRA); | |
2202 | TERM_DEBUG_OFF(allow_martians, ALLOW_MARTIANS); | |
c33b83b3 | 2203 | TERM_DEBUG_OFF(nht, NHT); |
ddb5b488 PZ |
2204 | TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF); |
2205 | TERM_DEBUG_OFF(vpn, VPN_LEAK_TO_VRF); | |
2206 | TERM_DEBUG_OFF(vpn, VPN_LEAK_RMAP_EVENT); | |
2207 | TERM_DEBUG_OFF(vpn, VPN_LEAK_LABEL); | |
268e1b9b | 2208 | TERM_DEBUG_OFF(flowspec, FLOWSPEC); |
955bfd98 | 2209 | TERM_DEBUG_OFF(labelpool, LABELPOOL); |
1a80fc0f | 2210 | TERM_DEBUG_OFF(pbr, PBR); |
e9d0aa99 | 2211 | TERM_DEBUG_OFF(pbr, PBR_ERROR); |
794b37d5 | 2212 | TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART); |
52653398 AK |
2213 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES); |
2214 | TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT); | |
259f4236 | 2215 | TERM_DEBUG_OFF(bfd, BFD_LIB); |
8093d799 | 2216 | TERM_DEBUG_OFF(cond_adv, COND_ADV); |
70cd87ca | 2217 | TERM_DEBUG_OFF(optimal_route_reflection, ORR); |
794b37d5 | 2218 | |
d62a17ae | 2219 | vty_out(vty, "All possible debugging has been turned off\n"); |
2220 | ||
2221 | return CMD_SUCCESS; | |
718e3744 | 2222 | } |
2223 | ||
87f6dc50 DS |
2224 | DEFUN_NOSH (show_debugging_bgp, |
2225 | show_debugging_bgp_cmd, | |
2226 | "show debugging [bgp]", | |
2227 | SHOW_STR | |
2228 | DEBUG_STR | |
2229 | BGP_STR) | |
718e3744 | 2230 | { |
d62a17ae | 2231 | vty_out(vty, "BGP debugging status:\n"); |
718e3744 | 2232 | |
d62a17ae | 2233 | if (BGP_DEBUG(as4, AS4)) |
2234 | vty_out(vty, " BGP as4 debugging is on\n"); | |
16286195 | 2235 | |
d62a17ae | 2236 | if (BGP_DEBUG(as4, AS4_SEGMENT)) |
2237 | vty_out(vty, " BGP as4 aspath segment debugging is on\n"); | |
16286195 | 2238 | |
d62a17ae | 2239 | if (BGP_DEBUG(bestpath, BESTPATH)) |
2240 | bgp_debug_list_print(vty, " BGP bestpath debugging is on", | |
29a643ca | 2241 | bgp_debug_bestpath_prefixes); |
16286195 | 2242 | |
d62a17ae | 2243 | if (BGP_DEBUG(keepalive, KEEPALIVE)) |
2244 | bgp_debug_list_print(vty, " BGP keepalives debugging is on", | |
29a643ca | 2245 | bgp_debug_keepalive_peers); |
16286195 | 2246 | |
d62a17ae | 2247 | if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS)) |
2248 | bgp_debug_list_print(vty, | |
2249 | " BGP neighbor-events debugging is on", | |
29a643ca | 2250 | bgp_debug_neighbor_events_peers); |
91ba2c8b | 2251 | |
d62a17ae | 2252 | if (BGP_DEBUG(nht, NHT)) |
2253 | vty_out(vty, " BGP next-hop tracking debugging is on\n"); | |
16286195 | 2254 | |
d62a17ae | 2255 | if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) |
2256 | vty_out(vty, " BGP update-groups debugging is on\n"); | |
91ba2c8b | 2257 | |
d62a17ae | 2258 | if (BGP_DEBUG(update, UPDATE_PREFIX)) |
2259 | bgp_debug_list_print(vty, " BGP updates debugging is on", | |
29a643ca | 2260 | bgp_debug_update_prefixes); |
16286195 | 2261 | |
d62a17ae | 2262 | if (BGP_DEBUG(update, UPDATE_IN)) |
2263 | bgp_debug_list_print(vty, | |
2264 | " BGP updates debugging is on (inbound)", | |
29a643ca | 2265 | bgp_debug_update_in_peers); |
16286195 | 2266 | |
d62a17ae | 2267 | if (BGP_DEBUG(update, UPDATE_OUT)) |
2268 | bgp_debug_list_print(vty, | |
2269 | " BGP updates debugging is on (outbound)", | |
29a643ca | 2270 | bgp_debug_update_out_peers); |
16286195 | 2271 | |
d62a17ae | 2272 | if (BGP_DEBUG(zebra, ZEBRA)) |
2273 | bgp_debug_list_print(vty, " BGP zebra debugging is on", | |
36235319 | 2274 | bgp_debug_zebra_prefixes); |
794b37d5 | 2275 | |
2276 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
81bf7425 | 2277 | vty_out(vty, " BGP graceful-restart debugging is on\n"); |
16286195 | 2278 | |
d62a17ae | 2279 | if (BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) |
2280 | vty_out(vty, " BGP allow martian next hop debugging is on\n"); | |
ddb5b488 PZ |
2281 | |
2282 | if (BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)) | |
2283 | vty_out(vty, | |
2284 | " BGP route leak from vrf to vpn debugging is on\n"); | |
2285 | if (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF)) | |
2286 | vty_out(vty, | |
2287 | " BGP route leak to vrf from vpn debugging is on\n"); | |
2288 | if (BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT)) | |
2289 | vty_out(vty, " BGP vpn route-map event debugging is on\n"); | |
2290 | if (BGP_DEBUG(vpn, VPN_LEAK_LABEL)) | |
2291 | vty_out(vty, " BGP vpn label event debugging is on\n"); | |
268e1b9b PG |
2292 | if (BGP_DEBUG(flowspec, FLOWSPEC)) |
2293 | vty_out(vty, " BGP flowspec debugging is on\n"); | |
955bfd98 PZ |
2294 | if (BGP_DEBUG(labelpool, LABELPOOL)) |
2295 | vty_out(vty, " BGP labelpool debugging is on\n"); | |
ddb5b488 | 2296 | |
1a80fc0f PG |
2297 | if (BGP_DEBUG(pbr, PBR)) |
2298 | vty_out(vty, " BGP policy based routing debugging is on\n"); | |
e9d0aa99 PG |
2299 | if (BGP_DEBUG(pbr, PBR_ERROR)) |
2300 | vty_out(vty, " BGP policy based routing error debugging is on\n"); | |
1d4cfa5d | 2301 | |
52653398 AK |
2302 | if (BGP_DEBUG(evpn_mh, EVPN_MH_ES)) |
2303 | vty_out(vty, " BGP EVPN-MH ES debugging is on\n"); | |
2304 | if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) | |
2305 | vty_out(vty, " BGP EVPN-MH route debugging is on\n"); | |
2306 | ||
259f4236 RZ |
2307 | if (BGP_DEBUG(bfd, BFD_LIB)) |
2308 | vty_out(vty, " BGP BFD library debugging is on\n"); | |
2309 | ||
8093d799 MK |
2310 | if (BGP_DEBUG(cond_adv, COND_ADV)) |
2311 | vty_out(vty, | |
2312 | " BGP conditional advertisement debugging is on\n"); | |
2313 | ||
70cd87ca MK |
2314 | if (BGP_DEBUG(optimal_route_reflection, ORR)) |
2315 | vty_out(vty, | |
2316 | " BGP Optimal Route Reflection debugging is on\n"); | |
2317 | ||
cf00164b DS |
2318 | cmd_show_lib_debugs(vty); |
2319 | ||
d62a17ae | 2320 | return CMD_SUCCESS; |
718e3744 | 2321 | } |
2322 | ||
d62a17ae | 2323 | static int bgp_config_write_debug(struct vty *vty) |
718e3744 | 2324 | { |
d62a17ae | 2325 | int write = 0; |
718e3744 | 2326 | |
d62a17ae | 2327 | if (CONF_BGP_DEBUG(as4, AS4)) { |
2328 | vty_out(vty, "debug bgp as4\n"); | |
2329 | write++; | |
2330 | } | |
718e3744 | 2331 | |
d62a17ae | 2332 | if (CONF_BGP_DEBUG(as4, AS4_SEGMENT)) { |
2333 | vty_out(vty, "debug bgp as4 segment\n"); | |
2334 | write++; | |
2335 | } | |
16286195 | 2336 | |
d62a17ae | 2337 | if (CONF_BGP_DEBUG(bestpath, BESTPATH)) { |
2338 | write += bgp_debug_list_conf_print(vty, "debug bgp bestpath", | |
29a643ca | 2339 | bgp_debug_bestpath_prefixes); |
d62a17ae | 2340 | } |
2341 | ||
2342 | if (CONF_BGP_DEBUG(keepalive, KEEPALIVE)) { | |
2343 | write += bgp_debug_list_conf_print(vty, "debug bgp keepalives", | |
29a643ca | 2344 | bgp_debug_keepalive_peers); |
d62a17ae | 2345 | } |
2346 | ||
2347 | if (CONF_BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS)) { | |
2348 | write += bgp_debug_list_conf_print( | |
2349 | vty, "debug bgp neighbor-events", | |
29a643ca | 2350 | bgp_debug_neighbor_events_peers); |
d62a17ae | 2351 | } |
2352 | ||
2353 | if (CONF_BGP_DEBUG(nht, NHT)) { | |
2354 | vty_out(vty, "debug bgp nht\n"); | |
2355 | write++; | |
2356 | } | |
2357 | ||
2358 | if (CONF_BGP_DEBUG(update_groups, UPDATE_GROUPS)) { | |
2359 | vty_out(vty, "debug bgp update-groups\n"); | |
2360 | write++; | |
2361 | } | |
2362 | ||
2363 | if (CONF_BGP_DEBUG(update, UPDATE_PREFIX)) { | |
2364 | write += bgp_debug_list_conf_print(vty, | |
2365 | "debug bgp updates prefix", | |
29a643ca | 2366 | bgp_debug_update_prefixes); |
d62a17ae | 2367 | } |
2368 | ||
2369 | if (CONF_BGP_DEBUG(update, UPDATE_IN)) { | |
2370 | write += bgp_debug_list_conf_print(vty, "debug bgp updates in", | |
29a643ca | 2371 | bgp_debug_update_in_peers); |
d62a17ae | 2372 | } |
2373 | ||
2374 | if (CONF_BGP_DEBUG(update, UPDATE_OUT)) { | |
2375 | write += bgp_debug_list_conf_print(vty, "debug bgp updates out", | |
29a643ca | 2376 | bgp_debug_update_out_peers); |
d62a17ae | 2377 | } |
16286195 | 2378 | |
d62a17ae | 2379 | if (CONF_BGP_DEBUG(zebra, ZEBRA)) { |
2380 | if (!bgp_debug_zebra_prefixes | |
2381 | || list_isempty(bgp_debug_zebra_prefixes)) { | |
2382 | vty_out(vty, "debug bgp zebra\n"); | |
2383 | write++; | |
2384 | } else { | |
2385 | write += bgp_debug_list_conf_print( | |
2386 | vty, "debug bgp zebra prefix", | |
29a643ca | 2387 | bgp_debug_zebra_prefixes); |
d62a17ae | 2388 | } |
2389 | } | |
16286195 | 2390 | |
d62a17ae | 2391 | if (CONF_BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) { |
2392 | vty_out(vty, "debug bgp allow-martians\n"); | |
2393 | write++; | |
2394 | } | |
16286195 | 2395 | |
ddb5b488 PZ |
2396 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)) { |
2397 | vty_out(vty, "debug bgp vpn leak-from-vrf\n"); | |
2398 | write++; | |
2399 | } | |
2400 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_TO_VRF)) { | |
2401 | vty_out(vty, "debug bgp vpn leak-to-vrf\n"); | |
2402 | write++; | |
2403 | } | |
2404 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_RMAP_EVENT)) { | |
2405 | vty_out(vty, "debug bgp vpn rmap-event\n"); | |
2406 | write++; | |
2407 | } | |
2408 | if (CONF_BGP_DEBUG(vpn, VPN_LEAK_LABEL)) { | |
2409 | vty_out(vty, "debug bgp vpn label\n"); | |
2410 | write++; | |
2411 | } | |
268e1b9b PG |
2412 | if (CONF_BGP_DEBUG(flowspec, FLOWSPEC)) { |
2413 | vty_out(vty, "debug bgp flowspec\n"); | |
2414 | write++; | |
2415 | } | |
955bfd98 PZ |
2416 | if (CONF_BGP_DEBUG(labelpool, LABELPOOL)) { |
2417 | vty_out(vty, "debug bgp labelpool\n"); | |
2418 | write++; | |
2419 | } | |
ddb5b488 | 2420 | |
1a80fc0f PG |
2421 | if (CONF_BGP_DEBUG(pbr, PBR)) { |
2422 | vty_out(vty, "debug bgp pbr\n"); | |
2423 | write++; | |
e9d0aa99 PG |
2424 | } |
2425 | if (CONF_BGP_DEBUG(pbr, PBR_ERROR)) { | |
2426 | vty_out(vty, "debug bgp pbr error\n"); | |
2427 | write++; | |
1a80fc0f | 2428 | } |
794b37d5 | 2429 | |
2430 | if (CONF_BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) { | |
2431 | vty_out(vty, "debug bgp graceful-restart\n"); | |
2432 | write++; | |
2433 | } | |
52653398 AK |
2434 | |
2435 | if (CONF_BGP_DEBUG(evpn_mh, EVPN_MH_ES)) { | |
2436 | vty_out(vty, "debug bgp evpn mh es\n"); | |
2437 | write++; | |
2438 | } | |
2439 | if (CONF_BGP_DEBUG(evpn_mh, EVPN_MH_RT)) { | |
2440 | vty_out(vty, "debug bgp evpn mh route\n"); | |
2441 | write++; | |
2442 | } | |
2443 | ||
259f4236 RZ |
2444 | if (CONF_BGP_DEBUG(bfd, BFD_LIB)) { |
2445 | vty_out(vty, "debug bgp bfd\n"); | |
2446 | write++; | |
2447 | } | |
2448 | ||
8093d799 MK |
2449 | if (CONF_BGP_DEBUG(cond_adv, COND_ADV)) { |
2450 | vty_out(vty, "debug bgp conditional-advertisement\n"); | |
80f6ea8b | 2451 | write++; |
70cd87ca MK |
2452 | } |
2453 | ||
2454 | if (CONF_BGP_DEBUG(optimal_route_reflection, ORR)) { | |
2455 | vty_out(vty, "debug bgp optimal-route-reflection\n"); | |
8093d799 MK |
2456 | write++; |
2457 | } | |
2458 | ||
d62a17ae | 2459 | return write; |
2460 | } | |
16286195 | 2461 | |
612c2c15 | 2462 | static int bgp_config_write_debug(struct vty *vty); |
62b346ee | 2463 | static struct cmd_node debug_node = { |
f4b8291f | 2464 | .name = "debug", |
62b346ee DL |
2465 | .node = DEBUG_NODE, |
2466 | .prompt = "", | |
612c2c15 | 2467 | .config_write = bgp_config_write_debug, |
62b346ee | 2468 | }; |
d62a17ae | 2469 | |
2470 | void bgp_debug_init(void) | |
2471 | { | |
612c2c15 | 2472 | install_node(&debug_node); |
d62a17ae | 2473 | |
2474 | install_element(ENABLE_NODE, &show_debugging_bgp_cmd); | |
2475 | ||
2476 | install_element(ENABLE_NODE, &debug_bgp_as4_cmd); | |
2477 | install_element(CONFIG_NODE, &debug_bgp_as4_cmd); | |
2478 | install_element(ENABLE_NODE, &debug_bgp_as4_segment_cmd); | |
2479 | install_element(CONFIG_NODE, &debug_bgp_as4_segment_cmd); | |
2480 | ||
2481 | install_element(ENABLE_NODE, &debug_bgp_neighbor_events_cmd); | |
2482 | install_element(CONFIG_NODE, &debug_bgp_neighbor_events_cmd); | |
2483 | install_element(ENABLE_NODE, &debug_bgp_nht_cmd); | |
2484 | install_element(CONFIG_NODE, &debug_bgp_nht_cmd); | |
2485 | install_element(ENABLE_NODE, &debug_bgp_keepalive_cmd); | |
2486 | install_element(CONFIG_NODE, &debug_bgp_keepalive_cmd); | |
2487 | install_element(ENABLE_NODE, &debug_bgp_update_cmd); | |
2488 | install_element(CONFIG_NODE, &debug_bgp_update_cmd); | |
2489 | install_element(ENABLE_NODE, &debug_bgp_zebra_cmd); | |
2490 | install_element(CONFIG_NODE, &debug_bgp_zebra_cmd); | |
d62a17ae | 2491 | install_element(ENABLE_NODE, &debug_bgp_update_groups_cmd); |
2492 | install_element(CONFIG_NODE, &debug_bgp_update_groups_cmd); | |
2493 | install_element(ENABLE_NODE, &debug_bgp_bestpath_prefix_cmd); | |
2494 | install_element(CONFIG_NODE, &debug_bgp_bestpath_prefix_cmd); | |
2495 | ||
794b37d5 | 2496 | install_element(ENABLE_NODE, &debug_bgp_graceful_restart_cmd); |
2497 | install_element(CONFIG_NODE, &debug_bgp_graceful_restart_cmd); | |
2498 | ||
d62a17ae | 2499 | /* debug bgp updates (in|out) */ |
2500 | install_element(ENABLE_NODE, &debug_bgp_update_direct_cmd); | |
2501 | install_element(CONFIG_NODE, &debug_bgp_update_direct_cmd); | |
2502 | install_element(ENABLE_NODE, &no_debug_bgp_update_direct_cmd); | |
2503 | install_element(CONFIG_NODE, &no_debug_bgp_update_direct_cmd); | |
2504 | ||
2505 | /* debug bgp updates (in|out) A.B.C.D */ | |
2506 | install_element(ENABLE_NODE, &debug_bgp_update_direct_peer_cmd); | |
2507 | install_element(CONFIG_NODE, &debug_bgp_update_direct_peer_cmd); | |
2508 | install_element(ENABLE_NODE, &no_debug_bgp_update_direct_peer_cmd); | |
2509 | install_element(CONFIG_NODE, &no_debug_bgp_update_direct_peer_cmd); | |
2510 | ||
2511 | /* debug bgp updates prefix A.B.C.D/M */ | |
2512 | install_element(ENABLE_NODE, &debug_bgp_update_prefix_cmd); | |
2513 | install_element(CONFIG_NODE, &debug_bgp_update_prefix_cmd); | |
2514 | install_element(ENABLE_NODE, &no_debug_bgp_update_prefix_cmd); | |
2515 | install_element(CONFIG_NODE, &no_debug_bgp_update_prefix_cmd); | |
81cf0de5 CS |
2516 | install_element(ENABLE_NODE, &debug_bgp_update_prefix_afi_safi_cmd); |
2517 | install_element(CONFIG_NODE, &debug_bgp_update_prefix_afi_safi_cmd); | |
2518 | install_element(ENABLE_NODE, &no_debug_bgp_update_prefix_afi_safi_cmd); | |
2519 | install_element(CONFIG_NODE, &no_debug_bgp_update_prefix_afi_safi_cmd); | |
d62a17ae | 2520 | |
2521 | /* debug bgp zebra prefix A.B.C.D/M */ | |
2522 | install_element(ENABLE_NODE, &debug_bgp_zebra_prefix_cmd); | |
2523 | install_element(CONFIG_NODE, &debug_bgp_zebra_prefix_cmd); | |
2524 | install_element(ENABLE_NODE, &no_debug_bgp_zebra_prefix_cmd); | |
2525 | install_element(CONFIG_NODE, &no_debug_bgp_zebra_prefix_cmd); | |
2526 | ||
2527 | install_element(ENABLE_NODE, &no_debug_bgp_as4_cmd); | |
2528 | install_element(CONFIG_NODE, &no_debug_bgp_as4_cmd); | |
2529 | install_element(ENABLE_NODE, &no_debug_bgp_as4_segment_cmd); | |
2530 | install_element(CONFIG_NODE, &no_debug_bgp_as4_segment_cmd); | |
2531 | ||
2532 | /* debug bgp neighbor-events A.B.C.D */ | |
2533 | install_element(ENABLE_NODE, &debug_bgp_neighbor_events_peer_cmd); | |
2534 | install_element(CONFIG_NODE, &debug_bgp_neighbor_events_peer_cmd); | |
2535 | install_element(ENABLE_NODE, &no_debug_bgp_neighbor_events_peer_cmd); | |
2536 | install_element(CONFIG_NODE, &no_debug_bgp_neighbor_events_peer_cmd); | |
2537 | ||
2538 | /* debug bgp keepalive A.B.C.D */ | |
2539 | install_element(ENABLE_NODE, &debug_bgp_keepalive_peer_cmd); | |
2540 | install_element(CONFIG_NODE, &debug_bgp_keepalive_peer_cmd); | |
2541 | install_element(ENABLE_NODE, &no_debug_bgp_keepalive_peer_cmd); | |
2542 | install_element(CONFIG_NODE, &no_debug_bgp_keepalive_peer_cmd); | |
2543 | ||
2544 | install_element(ENABLE_NODE, &no_debug_bgp_neighbor_events_cmd); | |
2545 | install_element(CONFIG_NODE, &no_debug_bgp_neighbor_events_cmd); | |
2546 | install_element(ENABLE_NODE, &no_debug_bgp_nht_cmd); | |
2547 | install_element(CONFIG_NODE, &no_debug_bgp_nht_cmd); | |
2548 | install_element(ENABLE_NODE, &no_debug_bgp_keepalive_cmd); | |
2549 | install_element(CONFIG_NODE, &no_debug_bgp_keepalive_cmd); | |
2550 | install_element(ENABLE_NODE, &no_debug_bgp_update_cmd); | |
2551 | install_element(CONFIG_NODE, &no_debug_bgp_update_cmd); | |
2552 | install_element(ENABLE_NODE, &no_debug_bgp_zebra_cmd); | |
2553 | install_element(CONFIG_NODE, &no_debug_bgp_zebra_cmd); | |
d62a17ae | 2554 | install_element(ENABLE_NODE, &no_debug_bgp_update_groups_cmd); |
2555 | install_element(CONFIG_NODE, &no_debug_bgp_update_groups_cmd); | |
2556 | install_element(ENABLE_NODE, &no_debug_bgp_cmd); | |
2557 | install_element(ENABLE_NODE, &no_debug_bgp_bestpath_cmd); | |
2558 | install_element(CONFIG_NODE, &no_debug_bgp_bestpath_cmd); | |
2559 | install_element(ENABLE_NODE, &no_debug_bgp_bestpath_prefix_cmd); | |
2560 | install_element(CONFIG_NODE, &no_debug_bgp_bestpath_prefix_cmd); | |
ddb5b488 | 2561 | |
794b37d5 | 2562 | install_element(ENABLE_NODE, &no_debug_bgp_graceful_restart_cmd); |
2563 | install_element(CONFIG_NODE, &no_debug_bgp_graceful_restart_cmd); | |
2564 | ||
ddb5b488 PZ |
2565 | install_element(ENABLE_NODE, &debug_bgp_vpn_cmd); |
2566 | install_element(CONFIG_NODE, &debug_bgp_vpn_cmd); | |
2567 | install_element(ENABLE_NODE, &no_debug_bgp_vpn_cmd); | |
2568 | install_element(CONFIG_NODE, &no_debug_bgp_vpn_cmd); | |
955bfd98 PZ |
2569 | |
2570 | install_element(ENABLE_NODE, &debug_bgp_labelpool_cmd); | |
2571 | install_element(CONFIG_NODE, &debug_bgp_labelpool_cmd); | |
2572 | install_element(ENABLE_NODE, &no_debug_bgp_labelpool_cmd); | |
2573 | install_element(CONFIG_NODE, &no_debug_bgp_labelpool_cmd); | |
1a80fc0f PG |
2574 | |
2575 | /* debug bgp pbr */ | |
2576 | install_element(ENABLE_NODE, &debug_bgp_pbr_cmd); | |
2577 | install_element(CONFIG_NODE, &debug_bgp_pbr_cmd); | |
2578 | install_element(ENABLE_NODE, &no_debug_bgp_pbr_cmd); | |
2579 | install_element(CONFIG_NODE, &no_debug_bgp_pbr_cmd); | |
2580 | ||
52653398 AK |
2581 | install_element(ENABLE_NODE, &debug_bgp_evpn_mh_cmd); |
2582 | install_element(CONFIG_NODE, &debug_bgp_evpn_mh_cmd); | |
259f4236 RZ |
2583 | |
2584 | /* debug bgp bfd */ | |
2585 | install_element(ENABLE_NODE, &debug_bgp_bfd_cmd); | |
2586 | install_element(CONFIG_NODE, &debug_bgp_bfd_cmd); | |
8093d799 MK |
2587 | |
2588 | /* debug bgp conditional advertisement */ | |
2589 | install_element(ENABLE_NODE, &debug_bgp_cond_adv_cmd); | |
2590 | install_element(CONFIG_NODE, &debug_bgp_cond_adv_cmd); | |
70cd87ca MK |
2591 | |
2592 | /* debug bgp optimal route reflection */ | |
2593 | install_element(ENABLE_NODE, &debug_bgp_optimal_route_reflection_cmd); | |
2594 | install_element(CONFIG_NODE, &debug_bgp_optimal_route_reflection_cmd); | |
d62a17ae | 2595 | } |
16286195 | 2596 | |
d62a17ae | 2597 | /* Return true if this prefix is on the per_prefix_list of prefixes to debug |
2598 | * for BGP_DEBUG_TYPE | |
2599 | */ | |
b8685f9b | 2600 | static int bgp_debug_per_prefix(const struct prefix *p, |
d62a17ae | 2601 | unsigned long term_bgp_debug_type, |
2602 | unsigned int BGP_DEBUG_TYPE, | |
2603 | struct list *per_prefix_list) | |
2604 | { | |
2605 | struct bgp_debug_filter *filter; | |
2606 | struct listnode *node, *nnode; | |
2607 | ||
2608 | if (term_bgp_debug_type & BGP_DEBUG_TYPE) { | |
2609 | /* We are debugging all prefixes so return true */ | |
2610 | if (!per_prefix_list || list_isempty(per_prefix_list)) | |
2611 | return 1; | |
2612 | ||
2613 | else { | |
2614 | if (!p) | |
2615 | return 0; | |
2616 | ||
2617 | for (ALL_LIST_ELEMENTS(per_prefix_list, node, nnode, | |
2618 | filter)) | |
2619 | if (filter->p->prefixlen == p->prefixlen | |
2620 | && prefix_match(filter->p, p)) | |
2621 | return 1; | |
2622 | ||
2623 | return 0; | |
2624 | } | |
2625 | } | |
2626 | ||
2627 | return 0; | |
16286195 DS |
2628 | } |
2629 | ||
2630 | /* Return true if this peer is on the per_peer_list of peers to debug | |
2631 | * for BGP_DEBUG_TYPE | |
2632 | */ | |
d032ddce DS |
2633 | static bool bgp_debug_per_peer(char *host, unsigned long term_bgp_debug_type, |
2634 | unsigned int BGP_DEBUG_TYPE, | |
2635 | struct list *per_peer_list) | |
16286195 | 2636 | { |
d62a17ae | 2637 | struct bgp_debug_filter *filter; |
2638 | struct listnode *node, *nnode; | |
16286195 | 2639 | |
d62a17ae | 2640 | if (term_bgp_debug_type & BGP_DEBUG_TYPE) { |
2641 | /* We are debugging all peers so return true */ | |
2642 | if (!per_peer_list || list_isempty(per_peer_list)) | |
d032ddce | 2643 | return true; |
16286195 | 2644 | |
d62a17ae | 2645 | else { |
2646 | if (!host) | |
d032ddce | 2647 | return false; |
16286195 | 2648 | |
d62a17ae | 2649 | for (ALL_LIST_ELEMENTS(per_peer_list, node, nnode, |
2650 | filter)) | |
2651 | if (strcmp(filter->host, host) == 0) | |
d032ddce | 2652 | return true; |
16286195 | 2653 | |
d032ddce | 2654 | return false; |
d62a17ae | 2655 | } |
2656 | } | |
16286195 | 2657 | |
d032ddce | 2658 | return false; |
16286195 DS |
2659 | } |
2660 | ||
d032ddce | 2661 | bool bgp_debug_neighbor_events(const struct peer *peer) |
16286195 | 2662 | { |
d62a17ae | 2663 | char *host = NULL; |
167d390a | 2664 | |
d62a17ae | 2665 | if (peer) |
2666 | host = peer->host; | |
167d390a | 2667 | |
d62a17ae | 2668 | return bgp_debug_per_peer(host, term_bgp_debug_neighbor_events, |
2669 | BGP_DEBUG_NEIGHBOR_EVENTS, | |
2670 | bgp_debug_neighbor_events_peers); | |
16286195 DS |
2671 | } |
2672 | ||
d032ddce | 2673 | bool bgp_debug_keepalive(const struct peer *peer) |
16286195 | 2674 | { |
d62a17ae | 2675 | char *host = NULL; |
167d390a | 2676 | |
d62a17ae | 2677 | if (peer) |
2678 | host = peer->host; | |
167d390a | 2679 | |
d62a17ae | 2680 | return bgp_debug_per_peer(host, term_bgp_debug_keepalive, |
2681 | BGP_DEBUG_KEEPALIVE, | |
2682 | bgp_debug_keepalive_peers); | |
16286195 DS |
2683 | } |
2684 | ||
d032ddce | 2685 | bool bgp_debug_update(const struct peer *peer, const struct prefix *p, |
3dc339cd | 2686 | struct update_group *updgrp, unsigned int inbound) |
16286195 | 2687 | { |
d62a17ae | 2688 | char *host = NULL; |
2689 | ||
2690 | if (peer) | |
2691 | host = peer->host; | |
2692 | ||
2693 | if (inbound) { | |
2694 | if (bgp_debug_per_peer(host, term_bgp_debug_update, | |
2695 | BGP_DEBUG_UPDATE_IN, | |
2696 | bgp_debug_update_in_peers)) | |
3dc339cd | 2697 | return true; |
d62a17ae | 2698 | } |
2699 | ||
2700 | /* outbound */ | |
2701 | else { | |
2702 | if (bgp_debug_per_peer(host, term_bgp_debug_update, | |
2703 | BGP_DEBUG_UPDATE_OUT, | |
2704 | bgp_debug_update_out_peers)) | |
3dc339cd | 2705 | return true; |
d62a17ae | 2706 | |
2707 | /* Check if update debugging implicitly enabled for the group. | |
2708 | */ | |
2709 | if (updgrp && UPDGRP_DBG_ON(updgrp)) | |
3dc339cd | 2710 | return true; |
d62a17ae | 2711 | } |
2712 | ||
2713 | ||
2714 | if (BGP_DEBUG(update, UPDATE_PREFIX)) { | |
2715 | if (bgp_debug_per_prefix(p, term_bgp_debug_update, | |
2716 | BGP_DEBUG_UPDATE_PREFIX, | |
2717 | bgp_debug_update_prefixes)) | |
3dc339cd | 2718 | return true; |
d62a17ae | 2719 | } |
2720 | ||
3dc339cd | 2721 | return false; |
16286195 DS |
2722 | } |
2723 | ||
9bcb3eef | 2724 | bool bgp_debug_bestpath(struct bgp_dest *dest) |
9fbdd100 | 2725 | { |
d62a17ae | 2726 | if (BGP_DEBUG(bestpath, BESTPATH)) { |
cb9f254c | 2727 | if (bgp_debug_per_prefix( |
9bcb3eef | 2728 | bgp_dest_get_prefix(dest), term_bgp_debug_bestpath, |
cb9f254c | 2729 | BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes)) |
3dc339cd | 2730 | return true; |
d62a17ae | 2731 | } |
2732 | ||
3dc339cd | 2733 | return false; |
9fbdd100 DS |
2734 | } |
2735 | ||
b8685f9b | 2736 | bool bgp_debug_zebra(const struct prefix *p) |
16286195 | 2737 | { |
d62a17ae | 2738 | if (BGP_DEBUG(zebra, ZEBRA)) { |
2739 | if (bgp_debug_per_prefix(p, term_bgp_debug_zebra, | |
2740 | BGP_DEBUG_ZEBRA, | |
2741 | bgp_debug_zebra_prefixes)) | |
3dc339cd | 2742 | return true; |
d62a17ae | 2743 | } |
2744 | ||
3dc339cd | 2745 | return false; |
718e3744 | 2746 | } |
906ad49b | 2747 | |
d62a17ae | 2748 | const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, |
5f040085 | 2749 | const struct prefix_rd *prd, |
d62a17ae | 2750 | union prefixconstptr pu, |
d7c0a89a QY |
2751 | mpls_label_t *label, uint32_t num_labels, |
2752 | int addpath_valid, uint32_t addpath_id, | |
6c995628 | 2753 | struct bgp_route_evpn *overlay_index, |
b57ba6d2 | 2754 | char *str, int size) |
d62a17ae | 2755 | { |
d62a17ae | 2756 | char tag_buf[30]; |
6c995628 AD |
2757 | char overlay_index_buf[INET6_ADDRSTRLEN + 14]; |
2758 | const struct prefix_evpn *evp; | |
2759 | ||
d62a17ae | 2760 | /* ' with addpath ID ' 17 |
2761 | * max strlen of uint32 + 10 | |
2762 | * +/- (just in case) + 1 | |
2763 | * null terminator + 1 | |
2764 | * ============================ 29 */ | |
2765 | char pathid_buf[30]; | |
2766 | ||
2767 | if (size < BGP_PRD_PATH_STRLEN) | |
2768 | return NULL; | |
2769 | ||
2770 | /* Note: Path-id is created by default, but only included in update | |
2771 | * sometimes. */ | |
2772 | pathid_buf[0] = '\0'; | |
2773 | if (addpath_valid) | |
2774 | snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", | |
2775 | addpath_id); | |
2776 | ||
6c995628 AD |
2777 | overlay_index_buf[0] = '\0'; |
2778 | if (overlay_index && overlay_index->type == OVERLAY_INDEX_GATEWAY_IP) { | |
2779 | char obuf[INET6_ADDRSTRLEN]; | |
2780 | ||
2781 | obuf[0] = '\0'; | |
2782 | evp = pu.evp; | |
2783 | if (is_evpn_prefix_ipaddr_v4(evp)) | |
2784 | inet_ntop(AF_INET, &overlay_index->gw_ip, obuf, | |
2785 | sizeof(obuf)); | |
2786 | else if (is_evpn_prefix_ipaddr_v6(evp)) | |
2787 | inet_ntop(AF_INET6, &overlay_index->gw_ip, obuf, | |
2788 | sizeof(obuf)); | |
2789 | ||
2790 | snprintf(overlay_index_buf, sizeof(overlay_index_buf), | |
2791 | " gateway IP %s", obuf); | |
2792 | } | |
2793 | ||
d62a17ae | 2794 | tag_buf[0] = '\0'; |
b57ba6d2 | 2795 | if (bgp_labeled_safi(safi) && num_labels) { |
d62a17ae | 2796 | |
b57ba6d2 MK |
2797 | if (safi == SAFI_EVPN) { |
2798 | char tag_buf2[20]; | |
2799 | ||
2800 | bgp_evpn_label2str(label, num_labels, tag_buf2, 20); | |
772270f3 QY |
2801 | snprintf(tag_buf, sizeof(tag_buf), " label %s", |
2802 | tag_buf2); | |
b57ba6d2 | 2803 | } else { |
d7c0a89a | 2804 | uint32_t label_value; |
b57ba6d2 MK |
2805 | |
2806 | label_value = decode_label(label); | |
772270f3 QY |
2807 | snprintf(tag_buf, sizeof(tag_buf), " label %u", |
2808 | label_value); | |
b57ba6d2 | 2809 | } |
d62a17ae | 2810 | } |
2811 | ||
2812 | if (prd) | |
c4f64ea9 | 2813 | snprintfrr(str, size, "RD %pRD %pFX%s%s%s %s %s", prd, pu.p, |
6c995628 AD |
2814 | overlay_index_buf, tag_buf, pathid_buf, afi2str(afi), |
2815 | safi2str(safi)); | |
268e1b9b PG |
2816 | else if (safi == SAFI_FLOWSPEC) { |
2817 | char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; | |
2818 | const struct prefix_fs *fs = pu.fs; | |
2819 | ||
2820 | bgp_fs_nlri_get_string((unsigned char *)fs->prefix.ptr, | |
2821 | fs->prefix.prefixlen, | |
2822 | return_string, | |
1840384b PG |
2823 | NLRI_STRING_FORMAT_DEBUG, NULL, |
2824 | family2afi(fs->prefix.family)); | |
268e1b9b PG |
2825 | snprintf(str, size, "FS %s Match{%s}", afi2str(afi), |
2826 | return_string); | |
2827 | } else | |
2dbe669b DA |
2828 | snprintfrr(str, size, "%pFX%s%s %s %s", pu.p, tag_buf, |
2829 | pathid_buf, afi2str(afi), safi2str(safi)); | |
d62a17ae | 2830 | |
2831 | return str; | |
906ad49b | 2832 | } |