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