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