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