1 /* BGP-4, BGP-4+ packet debug routine
2 * Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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
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.
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
23 #include <lib/version.h>
25 #include "lib/printfrr.h"
31 #include "sockunion.h"
36 #include "bgpd/bgpd.h"
37 #include "bgpd/bgp_aspath.h"
38 #include "bgpd/bgp_route.h"
39 #include "bgpd/bgp_attr.h"
40 #include "bgpd/bgp_debug.h"
41 #include "bgpd/bgp_community.h"
42 #include "bgpd/bgp_lcommunity.h"
43 #include "bgpd/bgp_updgrp.h"
44 #include "bgpd/bgp_mplsvpn.h"
45 #include "bgpd/bgp_ecommunity.h"
46 #include "bgpd/bgp_label.h"
47 #include "bgpd/bgp_evpn.h"
48 #include "bgpd/bgp_evpn_private.h"
49 #include "bgpd/bgp_evpn_vty.h"
50 #include "bgpd/bgp_vty.h"
51 #include "bgpd/bgp_flowspec.h"
52 #include "bgpd/bgp_packet.h"
54 unsigned long conf_bgp_debug_as4
;
55 unsigned long conf_bgp_debug_neighbor_events
;
56 unsigned long conf_bgp_debug_events
;
57 unsigned long conf_bgp_debug_packet
;
58 unsigned long conf_bgp_debug_filter
;
59 unsigned long conf_bgp_debug_keepalive
;
60 unsigned long conf_bgp_debug_update
;
61 unsigned long conf_bgp_debug_bestpath
;
62 unsigned long conf_bgp_debug_zebra
;
63 unsigned long conf_bgp_debug_allow_martians
;
64 unsigned long conf_bgp_debug_nht
;
65 unsigned long conf_bgp_debug_update_groups
;
66 unsigned long conf_bgp_debug_vpn
;
67 unsigned long conf_bgp_debug_flowspec
;
68 unsigned long conf_bgp_debug_labelpool
;
69 unsigned long conf_bgp_debug_pbr
;
70 unsigned long conf_bgp_debug_graceful_restart
;
71 unsigned long conf_bgp_debug_evpn_mh
;
72 unsigned long conf_bgp_debug_bfd
;
73 unsigned long conf_bgp_debug_cond_adv
;
74 unsigned long conf_bgp_debug_optimal_route_reflection
;
76 unsigned long term_bgp_debug_as4
;
77 unsigned long term_bgp_debug_neighbor_events
;
78 unsigned long term_bgp_debug_events
;
79 unsigned long term_bgp_debug_packet
;
80 unsigned long term_bgp_debug_filter
;
81 unsigned long term_bgp_debug_keepalive
;
82 unsigned long term_bgp_debug_update
;
83 unsigned long term_bgp_debug_bestpath
;
84 unsigned long term_bgp_debug_zebra
;
85 unsigned long term_bgp_debug_allow_martians
;
86 unsigned long term_bgp_debug_nht
;
87 unsigned long term_bgp_debug_update_groups
;
88 unsigned long term_bgp_debug_vpn
;
89 unsigned long term_bgp_debug_flowspec
;
90 unsigned long term_bgp_debug_labelpool
;
91 unsigned long term_bgp_debug_pbr
;
92 unsigned long term_bgp_debug_graceful_restart
;
93 unsigned long term_bgp_debug_evpn_mh
;
94 unsigned long term_bgp_debug_bfd
;
95 unsigned long term_bgp_debug_cond_adv
;
96 unsigned long term_bgp_debug_optimal_route_reflection
;
98 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
99 struct list
*bgp_debug_keepalive_peers
= NULL
;
100 struct list
*bgp_debug_update_out_peers
= NULL
;
101 struct list
*bgp_debug_update_in_peers
= NULL
;
102 struct list
*bgp_debug_update_prefixes
= NULL
;
103 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
104 struct list
*bgp_debug_zebra_prefixes
= NULL
;
106 /* messages for BGP-4 status */
107 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
108 {Connect
, "Connect"},
110 {OpenSent
, "OpenSent"},
111 {OpenConfirm
, "OpenConfirm"},
112 {Established
, "Established"},
113 {Clearing
, "Clearing"},
114 {Deleted
, "Deleted"},
117 /* BGP message type string. */
118 const char *const bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
119 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
122 /* message for BGP-4 Notify */
123 static const struct message bgp_notify_msg
[] = {
124 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
125 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
126 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
127 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
128 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
129 {BGP_NOTIFY_CEASE
, "Cease"},
130 {BGP_NOTIFY_ROUTE_REFRESH_ERR
, "ROUTE-REFRESH Message Error"},
133 static const struct message bgp_notify_head_msg
[] = {
134 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
135 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
136 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
139 static const struct message bgp_notify_open_msg
[] = {
140 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
141 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
142 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
143 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
144 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
145 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
146 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
147 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
148 {BGP_NOTIFY_OPEN_ROLE_MISMATCH
, "/Role Mismatch"},
151 static const struct message bgp_notify_update_msg
[] = {
152 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
153 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
154 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
155 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
156 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
157 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
158 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
159 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
160 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
161 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
162 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
163 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
166 static const struct message bgp_notify_cease_msg
[] = {
167 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
168 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
169 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administrative Shutdown"},
170 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer De-configured"},
171 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administrative Reset"},
172 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
173 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
174 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
175 "/Connection Collision Resolution"},
176 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resources"},
177 {BGP_NOTIFY_CEASE_HARD_RESET
, "/Hard Reset"},
178 {BGP_NOTIFY_CEASE_BFD_DOWN
, "/BFD Down"},
181 static const struct message bgp_notify_route_refresh_msg
[] = {
182 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
183 {BGP_NOTIFY_ROUTE_REFRESH_INVALID_MSG_LEN
, "/Invalid Message Length"},
186 static const struct message bgp_notify_fsm_msg
[] = {
187 {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC
, "/Unspecific"},
188 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT
,
189 "/Receive Unexpected Message in OpenSent State"},
190 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM
,
191 "/Receive Unexpected Message in OpenConfirm State"},
192 {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED
,
193 "/Receive Unexpected Message in Established State"},
196 /* Origin strings. */
197 const char *const bgp_origin_str
[] = {"i", "e", "?"};
198 const char *const bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
200 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
202 /* Given a string return a pointer the corresponding peer structure */
203 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
205 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
213 ret
= str2sockunion(peer_str
, &su
);
217 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
220 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
224 return peer_lookup(bgp
, &su
);
227 static void bgp_debug_list_free(struct list
*list
)
229 struct bgp_debug_filter
*filter
;
230 struct listnode
*node
, *nnode
;
233 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
234 listnode_delete(list
, filter
);
235 prefix_free(&filter
->p
);
236 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
237 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
242 * Print the desc along with a list of peers/prefixes this debug is
245 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
248 struct bgp_debug_filter
*filter
;
249 struct listnode
*node
, *nnode
;
251 vty_out(vty
, "%s", desc
);
253 if (list
&& !list_isempty(list
)) {
254 vty_out(vty
, " for");
255 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
257 vty_out(vty
, " %s", filter
->host
);
259 if (filter
->p
&& filter
->p
->family
== AF_EVPN
)
260 bgp_debug_print_evpn_prefix(vty
, "", filter
->p
);
262 vty_out(vty
, " %pFX", filter
->p
);
270 * Print the command to enable the debug for each peer/prefix this debug is
273 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
276 struct bgp_debug_filter
*filter
;
277 struct listnode
*node
, *nnode
;
280 if (list
&& !list_isempty(list
)) {
281 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
283 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
287 if (filter
->p
&& filter
->p
->family
== AF_EVPN
) {
288 bgp_debug_print_evpn_prefix(vty
, desc
,
291 } else if (filter
->p
) {
292 vty_out(vty
, "%s %pFX\n", desc
, filter
->p
);
299 vty_out(vty
, "%s\n", desc
);
306 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
307 const struct prefix
*p
)
309 struct bgp_debug_filter
*filter
;
311 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
312 sizeof(struct bgp_debug_filter
));
315 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
319 filter
->p
= prefix_new();
320 prefix_copy(filter
->p
, p
);
323 listnode_add(list
, filter
);
326 static bool bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
329 struct bgp_debug_filter
*filter
;
330 struct listnode
*node
, *nnode
;
332 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
333 if (host
&& strcmp(filter
->host
, host
) == 0) {
334 listnode_delete(list
, filter
);
335 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
336 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
338 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
339 && prefix_match(filter
->p
, p
)) {
340 listnode_delete(list
, filter
);
341 prefix_free(&filter
->p
);
342 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
350 static bool bgp_debug_list_has_entry(struct list
*list
, const char *host
,
351 const struct prefix
*p
)
353 struct bgp_debug_filter
*filter
;
354 struct listnode
*node
, *nnode
;
356 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
358 if (strcmp(filter
->host
, host
) == 0) {
362 if (filter
->p
->prefixlen
== p
->prefixlen
363 && prefix_match(filter
->p
, p
)) {
372 bool bgp_debug_peer_updout_enabled(char *host
)
374 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
378 /* Dump attribute. */
379 bool bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
381 char addrbuf
[BUFSIZ
];
388 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
389 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
391 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
392 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
393 bgp_origin_str
[attr
->origin
]);
396 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
397 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
398 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
400 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
403 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
404 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
405 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
408 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
409 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
411 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
412 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
413 ", localpref %u", attr
->local_pref
);
415 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AIGP
)))
416 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
417 ", aigp-metric %" PRIu64
,
418 (unsigned long long)bgp_attr_get_aigp_metric(attr
));
420 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
421 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
424 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
425 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
427 community_str(bgp_attr_get_community(attr
), false,
430 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
)))
431 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
432 ", large-community %s",
433 lcommunity_str(bgp_attr_get_lcommunity(attr
), false,
436 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
437 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
439 ecommunity_str(bgp_attr_get_ecommunity(attr
)));
441 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
442 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
443 ", atomic-aggregate");
445 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
446 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
447 ", aggregated by %u %pI4", attr
->aggregator_as
,
448 &attr
->aggregator_addr
);
450 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
451 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
452 ", originator %pI4", &attr
->originator_id
);
454 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
455 struct cluster_list
*cluster
;
458 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
461 cluster
= bgp_attr_get_cluster(attr
);
462 for (i
= 0; i
< cluster
->length
/ 4; i
++)
463 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
464 " %pI4", &cluster
->list
[i
]);
467 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
468 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
469 ", pmsi tnltype %u", bgp_attr_get_pmsi_tnl_type(attr
));
471 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
472 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
473 aspath_print(attr
->aspath
));
475 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
476 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
477 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
478 ", label-index %u", attr
->label_index
);
487 const char *bgp_notify_code_str(char code
)
489 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
492 const char *bgp_notify_subcode_str(char code
, char subcode
)
496 case BGP_NOTIFY_HEADER_ERR
:
497 return lookup_msg(bgp_notify_head_msg
, subcode
,
498 "Unrecognized Error Subcode");
499 case BGP_NOTIFY_OPEN_ERR
:
500 return lookup_msg(bgp_notify_open_msg
, subcode
,
501 "Unrecognized Error Subcode");
502 case BGP_NOTIFY_UPDATE_ERR
:
503 return lookup_msg(bgp_notify_update_msg
, subcode
,
504 "Unrecognized Error Subcode");
505 case BGP_NOTIFY_HOLD_ERR
:
507 case BGP_NOTIFY_FSM_ERR
:
508 return lookup_msg(bgp_notify_fsm_msg
, subcode
,
509 "Unrecognized Error Subcode");
510 case BGP_NOTIFY_CEASE
:
511 return lookup_msg(bgp_notify_cease_msg
, subcode
,
512 "Unrecognized Error Subcode");
513 case BGP_NOTIFY_ROUTE_REFRESH_ERR
:
514 return lookup_msg(bgp_notify_route_refresh_msg
, subcode
,
515 "Unrecognized Error Subcode");
520 /* extract notify admin reason if correctly present */
521 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, uint8_t *data
,
524 if (!data
|| datalen
< 1)
527 uint8_t len
= data
[0];
528 if (!len
|| len
> datalen
- 1)
531 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
534 /* dump notify packet */
535 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
536 const char *direct
, bool hard_reset
)
538 const char *subcode_str
;
539 const char *code_str
;
540 const char *msg_str
= NULL
;
543 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
544 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
545 code_str
= bgp_notify_code_str(bgp_notify
->code
);
546 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
547 bgp_notify
->subcode
);
549 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
550 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
551 || bgp_notify
->subcode
552 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
553 msg_str
= bgp_notify_admin_message(
554 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
560 "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) \"%s\"",
561 hard_reset
? "(Hard Reset)" : "",
562 strcmp(direct
, "received") == 0
565 peer
->host
, bgp_notify
->code
,
566 bgp_notify
->subcode
, code_str
, subcode_str
,
569 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
571 "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) %d bytes %s",
572 hard_reset
? "(Hard Reset)" : "",
573 strcmp(direct
, "received") == 0
576 peer
->host
, bgp_notify
->code
,
577 bgp_notify
->subcode
, code_str
, subcode_str
,
578 bgp_notify
->length
, msg_str
);
583 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
586 bgp
= bgp_get_default();
587 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
590 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
593 char evpn_desc
[PREFIX2STR_BUFFER
+ INET_ADDRSTRLEN
];
594 char buf
[PREFIX2STR_BUFFER
];
595 char buf2
[ETHER_ADDR_STRLEN
];
597 if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_MAC_IP_ROUTE
) {
598 if (is_evpn_prefix_ipaddr_none((struct prefix_evpn
*)p
)) {
600 evpn_desc
, sizeof(evpn_desc
),
601 "l2vpn evpn type macip mac %s",
602 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
603 buf2
, sizeof(buf2
)));
605 uint8_t family
= is_evpn_prefix_ipaddr_v4(
606 (struct prefix_evpn
*)p
) ?
609 evpn_desc
, sizeof(evpn_desc
),
610 "l2vpn evpn type macip mac %s ip %s",
611 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
615 &p
->u
.prefix_evpn
.macip_addr
.ip
.ip
.addr
,
616 buf
, PREFIX2STR_BUFFER
));
618 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IMET_ROUTE
) {
619 snprintfrr(evpn_desc
, sizeof(evpn_desc
),
620 "l2vpn evpn type multicast ip %pI4",
621 &p
->u
.prefix_evpn
.imet_addr
.ip
.ipaddr_v4
);
622 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
623 uint8_t family
= is_evpn_prefix_ipaddr_v4(
624 (struct prefix_evpn
*)p
) ? AF_INET
626 snprintf(evpn_desc
, sizeof(evpn_desc
),
627 "l2vpn evpn type prefix ip %s/%d",
629 &p
->u
.prefix_evpn
.prefix_addr
.ip
.ip
.addr
,
630 buf
, PREFIX2STR_BUFFER
),
631 p
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
);
634 vty_out(vty
, "%s %s\n", desc
, evpn_desc
);
637 static int bgp_debug_parse_evpn_prefix(struct vty
*vty
, struct cmd_token
**argv
,
638 int argc
, struct prefix
**argv_pp
)
640 struct prefix
*argv_p
;
641 struct ethaddr mac
= {};
642 struct ipaddr ip
= {};
649 if (bgp_evpn_cli_parse_type(&evpn_type
, argv
, argc
) < 0)
652 if (evpn_type
== BGP_EVPN_MAC_IP_ROUTE
) {
653 memset(&ip
, 0, sizeof(ip
));
655 if (argv_find(argv
, argc
, "mac", &mac_idx
))
656 if (!prefix_str2mac(argv
[mac_idx
+ 1]->arg
, &mac
)) {
657 vty_out(vty
, "%% Malformed MAC address\n");
661 if (argv_find(argv
, argc
, "ip", &ip_idx
))
662 if (str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
) != 0) {
663 vty_out(vty
, "%% Malformed IP address\n");
667 build_evpn_type2_prefix((struct prefix_evpn
*)argv_p
,
669 } else if (evpn_type
== BGP_EVPN_IMET_ROUTE
) {
670 memset(&ip
, 0, sizeof(ip
));
672 if (argv_find(argv
, argc
, "ip", &ip_idx
))
673 if (str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
) != 0) {
674 vty_out(vty
, "%% Malformed IP address\n");
678 build_evpn_type3_prefix((struct prefix_evpn
*)argv_p
,
680 } else if (evpn_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
681 struct prefix ip_prefix
;
683 memset(&ip_prefix
, 0, sizeof(ip_prefix
));
684 if (argv_find(argv
, argc
, "ip", &ip_idx
)) {
685 (void)str2prefix(argv
[ip_idx
+ 1]->arg
, &ip_prefix
);
686 apply_mask(&ip_prefix
);
688 build_type5_prefix_from_ip_prefix(
689 (struct prefix_evpn
*)argv_p
,
696 /* Debug option setting interface. */
697 unsigned long bgp_debug_option
= 0;
699 int debug(unsigned int option
)
701 return bgp_debug_option
& option
;
704 DEFUN (debug_bgp_as4
,
711 if (vty
->node
== CONFIG_NODE
)
714 TERM_DEBUG_ON(as4
, AS4
);
715 vty_out(vty
, "BGP as4 debugging is on\n");
720 DEFUN (no_debug_bgp_as4
,
721 no_debug_bgp_as4_cmd
,
728 if (vty
->node
== CONFIG_NODE
)
731 TERM_DEBUG_OFF(as4
, AS4
);
732 vty_out(vty
, "BGP as4 debugging is off\n");
737 DEFUN (debug_bgp_as4_segment
,
738 debug_bgp_as4_segment_cmd
,
739 "debug bgp as4 segment",
743 "BGP AS4 aspath segment handling\n")
745 if (vty
->node
== CONFIG_NODE
)
746 DEBUG_ON(as4
, AS4_SEGMENT
);
748 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
749 vty_out(vty
, "BGP as4 segment debugging is on\n");
754 DEFUN (no_debug_bgp_as4_segment
,
755 no_debug_bgp_as4_segment_cmd
,
756 "no debug bgp as4 segment",
761 "BGP AS4 aspath segment handling\n")
763 if (vty
->node
== CONFIG_NODE
)
764 DEBUG_OFF(as4
, AS4_SEGMENT
);
766 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
767 vty_out(vty
, "BGP as4 segment debugging is off\n");
772 /* debug bgp neighbor_events */
773 DEFUN (debug_bgp_neighbor_events
,
774 debug_bgp_neighbor_events_cmd
,
775 "debug bgp neighbor-events",
778 "BGP Neighbor Events\n")
780 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
782 if (vty
->node
== CONFIG_NODE
)
783 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
785 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
786 vty_out(vty
, "BGP neighbor-events debugging is on\n");
791 DEFUN (debug_bgp_neighbor_events_peer
,
792 debug_bgp_neighbor_events_peer_cmd
,
793 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
796 "BGP Neighbor Events\n"
797 "BGP neighbor IP address to debug\n"
798 "BGP IPv6 neighbor to debug\n"
799 "BGP neighbor on interface to debug\n")
802 const char *host
= argv
[idx_peer
]->arg
;
804 if (!bgp_debug_neighbor_events_peers
)
805 bgp_debug_neighbor_events_peers
= list_new();
807 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
810 "BGP neighbor-events debugging is already enabled for %s\n",
815 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
817 if (vty
->node
== CONFIG_NODE
)
818 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
820 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
821 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
827 DEFUN (no_debug_bgp_neighbor_events
,
828 no_debug_bgp_neighbor_events_cmd
,
829 "no debug bgp neighbor-events",
835 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
837 if (vty
->node
== CONFIG_NODE
)
838 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
840 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
841 vty_out(vty
, "BGP neighbor-events debugging is off\n");
846 DEFUN (no_debug_bgp_neighbor_events_peer
,
847 no_debug_bgp_neighbor_events_peer_cmd
,
848 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
853 "BGP neighbor IP address to debug\n"
854 "BGP IPv6 neighbor to debug\n"
855 "BGP neighbor on interface to debug\n")
859 const char *host
= argv
[idx_peer
]->arg
;
861 if (bgp_debug_neighbor_events_peers
862 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
863 found_peer
= bgp_debug_list_remove_entry(
864 bgp_debug_neighbor_events_peers
, host
, NULL
);
866 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
867 if (vty
->node
== CONFIG_NODE
)
868 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
870 TERM_DEBUG_OFF(neighbor_events
,
876 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
880 "BGP neighbor-events debugging was not enabled for %s\n",
887 DEFUN (debug_bgp_nht
,
892 "BGP nexthop tracking events\n")
894 if (vty
->node
== CONFIG_NODE
)
897 TERM_DEBUG_ON(nht
, NHT
);
898 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
903 DEFUN (no_debug_bgp_nht
,
904 no_debug_bgp_nht_cmd
,
909 "BGP nexthop tracking events\n")
911 if (vty
->node
== CONFIG_NODE
)
914 TERM_DEBUG_OFF(nht
, NHT
);
915 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
920 /* debug bgp keepalives */
921 DEFUN (debug_bgp_keepalive
,
922 debug_bgp_keepalive_cmd
,
923 "debug bgp keepalives",
928 bgp_debug_list_free(bgp_debug_keepalive_peers
);
930 if (vty
->node
== CONFIG_NODE
)
931 DEBUG_ON(keepalive
, KEEPALIVE
);
933 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
934 vty_out(vty
, "BGP keepalives debugging is on\n");
939 DEFUN (debug_bgp_keepalive_peer
,
940 debug_bgp_keepalive_peer_cmd
,
941 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
945 "BGP IPv4 neighbor to debug\n"
946 "BGP IPv6 neighbor to debug\n"
947 "BGP neighbor on interface to debug\n")
950 const char *host
= argv
[idx_peer
]->arg
;
952 if (!bgp_debug_keepalive_peers
)
953 bgp_debug_keepalive_peers
= list_new();
955 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
957 "BGP keepalive debugging is already enabled for %s\n",
962 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
964 if (vty
->node
== CONFIG_NODE
)
965 DEBUG_ON(keepalive
, KEEPALIVE
);
967 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
968 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
973 DEFUN (no_debug_bgp_keepalive
,
974 no_debug_bgp_keepalive_cmd
,
975 "no debug bgp keepalives",
981 bgp_debug_list_free(bgp_debug_keepalive_peers
);
983 if (vty
->node
== CONFIG_NODE
)
984 DEBUG_OFF(keepalive
, KEEPALIVE
);
986 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
987 vty_out(vty
, "BGP keepalives debugging is off\n");
992 DEFUN (no_debug_bgp_keepalive_peer
,
993 no_debug_bgp_keepalive_peer_cmd
,
994 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
999 "BGP neighbor IP address to debug\n"
1000 "BGP IPv6 neighbor to debug\n"
1001 "BGP neighbor on interface to debug\n")
1005 const char *host
= argv
[idx_peer
]->arg
;
1007 if (bgp_debug_keepalive_peers
1008 && !list_isempty(bgp_debug_keepalive_peers
)) {
1009 found_peer
= bgp_debug_list_remove_entry(
1010 bgp_debug_keepalive_peers
, host
, NULL
);
1012 if (list_isempty(bgp_debug_keepalive_peers
)) {
1013 if (vty
->node
== CONFIG_NODE
)
1014 DEBUG_OFF(keepalive
, KEEPALIVE
);
1016 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
1021 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
1024 "BGP keepalives debugging was not enabled for %s\n",
1030 /* debug bgp bestpath */
1031 DEFUN (debug_bgp_bestpath_prefix
,
1032 debug_bgp_bestpath_prefix_cmd
,
1033 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1040 struct prefix
*argv_p
;
1041 int idx_ipv4_ipv6_prefixlen
= 3;
1043 argv_p
= prefix_new();
1044 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1047 if (!bgp_debug_bestpath_prefixes
)
1048 bgp_debug_bestpath_prefixes
= list_new();
1050 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
1053 "BGP bestpath debugging is already enabled for %s\n",
1054 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1058 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1060 if (vty
->node
== CONFIG_NODE
) {
1061 DEBUG_ON(bestpath
, BESTPATH
);
1063 TERM_DEBUG_ON(bestpath
, BESTPATH
);
1064 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
1065 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1071 DEFUN (no_debug_bgp_bestpath_prefix
,
1072 no_debug_bgp_bestpath_prefix_cmd
,
1073 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1081 int idx_ipv4_ipv6_prefixlen
= 4;
1082 struct prefix
*argv_p
;
1083 int found_prefix
= 0;
1085 argv_p
= prefix_new();
1086 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1089 if (bgp_debug_bestpath_prefixes
1090 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
1091 found_prefix
= bgp_debug_list_remove_entry(
1092 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1094 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
1095 if (vty
->node
== CONFIG_NODE
) {
1096 DEBUG_OFF(bestpath
, BESTPATH
);
1098 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1100 "BGP bestpath debugging (per prefix) is off\n");
1106 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
1107 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1109 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
1110 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1115 DEFUN (no_debug_bgp_bestpath
,
1116 no_debug_bgp_bestpath_cmd
,
1117 "no debug bgp bestpath",
1123 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1125 if (vty
->node
== CONFIG_NODE
)
1126 DEBUG_OFF(bestpath
, BESTPATH
);
1128 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1129 vty_out(vty
, "BGP bestpath debugging is off\n");
1134 /* debug bgp updates */
1135 DEFUN (debug_bgp_update
,
1136 debug_bgp_update_cmd
,
1137 "debug bgp updates",
1142 bgp_debug_list_free(bgp_debug_update_in_peers
);
1143 bgp_debug_list_free(bgp_debug_update_out_peers
);
1144 bgp_debug_list_free(bgp_debug_update_prefixes
);
1146 if (vty
->node
== CONFIG_NODE
) {
1147 DEBUG_ON(update
, UPDATE_IN
);
1148 DEBUG_ON(update
, UPDATE_OUT
);
1150 TERM_DEBUG_ON(update
, UPDATE_IN
);
1151 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1152 vty_out(vty
, "BGP updates debugging is on\n");
1157 DEFUN (debug_bgp_update_direct
,
1158 debug_bgp_update_direct_cmd
,
1159 "debug bgp updates <in|out>",
1164 "Outbound updates\n")
1168 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1169 bgp_debug_list_free(bgp_debug_update_in_peers
);
1171 bgp_debug_list_free(bgp_debug_update_out_peers
);
1173 if (vty
->node
== CONFIG_NODE
) {
1174 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1175 DEBUG_ON(update
, UPDATE_IN
);
1177 DEBUG_ON(update
, UPDATE_OUT
);
1179 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1180 TERM_DEBUG_ON(update
, UPDATE_IN
);
1181 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1183 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1185 "BGP updates debugging is on (outbound)\n");
1191 DEFUN (debug_bgp_update_direct_peer
,
1192 debug_bgp_update_direct_peer_cmd
,
1193 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1198 "Outbound updates\n"
1199 "BGP neighbor IP address to debug\n"
1200 "BGP IPv6 neighbor to debug\n"
1201 "BGP neighbor on interface to debug\n")
1205 const char *host
= argv
[idx_peer
]->arg
;
1208 if (!bgp_debug_update_in_peers
)
1209 bgp_debug_update_in_peers
= list_new();
1211 if (!bgp_debug_update_out_peers
)
1212 bgp_debug_update_out_peers
= list_new();
1214 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1220 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1223 "BGP inbound update debugging is already enabled for %s\n",
1230 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1233 "BGP outbound update debugging is already enabled for %s\n",
1240 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1243 struct peer_af
*paf
;
1246 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1248 peer
= bgp_find_peer(vty
, host
);
1251 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1253 paf
= peer
->peer_af_array
[afidx
];
1255 if (PAF_SUBGRP(paf
)) {
1265 if (vty
->node
== CONFIG_NODE
) {
1267 DEBUG_ON(update
, UPDATE_IN
);
1269 DEBUG_ON(update
, UPDATE_OUT
);
1272 TERM_DEBUG_ON(update
, UPDATE_IN
);
1274 "BGP updates debugging is on (inbound) for %s\n",
1275 argv
[idx_peer
]->arg
);
1277 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1279 "BGP updates debugging is on (outbound) for %s\n",
1280 argv
[idx_peer
]->arg
);
1286 DEFUN (no_debug_bgp_update_direct
,
1287 no_debug_bgp_update_direct_cmd
,
1288 "no debug bgp updates <in|out>",
1294 "Outbound updates\n")
1297 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1298 bgp_debug_list_free(bgp_debug_update_in_peers
);
1300 if (vty
->node
== CONFIG_NODE
) {
1301 DEBUG_OFF(update
, UPDATE_IN
);
1303 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1305 "BGP updates debugging is off (inbound)\n");
1308 bgp_debug_list_free(bgp_debug_update_out_peers
);
1310 if (vty
->node
== CONFIG_NODE
) {
1311 DEBUG_OFF(update
, UPDATE_OUT
);
1313 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1315 "BGP updates debugging is off (outbound)\n");
1322 DEFUN (no_debug_bgp_update_direct_peer
,
1323 no_debug_bgp_update_direct_peer_cmd
,
1324 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1330 "Outbound updates\n"
1331 "BGP neighbor IP address to debug\n"
1332 "BGP IPv6 neighbor to debug\n"
1333 "BGP neighbor on interface to debug\n")
1339 const char *host
= argv
[idx_peer
]->arg
;
1341 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1346 if (inbound
&& bgp_debug_update_in_peers
1347 && !list_isempty(bgp_debug_update_in_peers
)) {
1348 found_peer
= bgp_debug_list_remove_entry(
1349 bgp_debug_update_in_peers
, host
, NULL
);
1351 if (list_isempty(bgp_debug_update_in_peers
)) {
1352 if (vty
->node
== CONFIG_NODE
)
1353 DEBUG_OFF(update
, UPDATE_IN
);
1355 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1357 "BGP updates debugging (inbound) is off\n");
1362 if (!inbound
&& bgp_debug_update_out_peers
1363 && !list_isempty(bgp_debug_update_out_peers
)) {
1364 found_peer
= bgp_debug_list_remove_entry(
1365 bgp_debug_update_out_peers
, host
, NULL
);
1367 if (list_isempty(bgp_debug_update_out_peers
)) {
1368 if (vty
->node
== CONFIG_NODE
)
1369 DEBUG_OFF(update
, UPDATE_OUT
);
1371 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1373 "BGP updates debugging (outbound) is off\n");
1378 struct peer_af
*paf
;
1380 peer
= bgp_find_peer(vty
, host
);
1383 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1385 paf
= peer
->peer_af_array
[afidx
];
1387 if (PAF_SUBGRP(paf
)) {
1388 UPDGRP_PEER_DBG_DIS(
1400 "BGP updates debugging (inbound) is off for %s\n",
1404 "BGP updates debugging (outbound) is off for %s\n",
1408 "BGP updates debugging (inbound) was not enabled for %s\n",
1412 "BGP updates debugging (outbound) was not enabled for %s\n",
1418 #include "bgpd/bgp_debug_clippy.c"
1420 DEFPY (debug_bgp_update_prefix_afi_safi
,
1421 debug_bgp_update_prefix_afi_safi_cmd
,
1422 "debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>",
1426 "Specify a prefix to debug\n"
1430 EVPN_TYPE_2_HELP_STR
1431 EVPN_TYPE_2_HELP_STR
1432 MAC_STR MAC_STR MAC_STR
1436 EVPN_TYPE_3_HELP_STR
1437 EVPN_TYPE_3_HELP_STR
1441 EVPN_TYPE_5_HELP_STR
1442 EVPN_TYPE_5_HELP_STR
1447 struct prefix
*argv_p
;
1448 int ret
= CMD_SUCCESS
;
1450 argv_p
= prefix_new();
1452 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1453 if (ret
!= CMD_SUCCESS
) {
1454 prefix_free(&argv_p
);
1458 if (!bgp_debug_update_prefixes
)
1459 bgp_debug_update_prefixes
= list_new();
1461 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1463 "BGP updates debugging is already enabled for %pFX\n",
1465 prefix_free(&argv_p
);
1469 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1471 if (vty
->node
== CONFIG_NODE
) {
1472 DEBUG_ON(update
, UPDATE_PREFIX
);
1474 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1475 vty_out(vty
, "BGP updates debugging is on for %pFX\n", argv_p
);
1478 prefix_free(&argv_p
);
1483 DEFPY (no_debug_bgp_update_prefix_afi_safi
,
1484 no_debug_bgp_update_prefix_afi_safi_cmd
,
1485 "no debug bgp updates prefix l2vpn$afi evpn$safi type <<macip|2> mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|<multicast|3> ip <A.B.C.D|X:X::X:X>|<prefix|5> ip <A.B.C.D/M|X:X::X:X/M>>",
1490 "Specify a prefix to debug\n"
1494 EVPN_TYPE_2_HELP_STR
1495 EVPN_TYPE_2_HELP_STR
1496 MAC_STR MAC_STR MAC_STR
1500 EVPN_TYPE_3_HELP_STR
1501 EVPN_TYPE_3_HELP_STR
1505 EVPN_TYPE_5_HELP_STR
1506 EVPN_TYPE_5_HELP_STR
1511 struct prefix
*argv_p
;
1512 bool found_prefix
= false;
1513 int ret
= CMD_SUCCESS
;
1515 argv_p
= prefix_new();
1517 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1518 if (ret
!= CMD_SUCCESS
) {
1519 prefix_free(&argv_p
);
1523 if (bgp_debug_update_prefixes
1524 && !list_isempty(bgp_debug_update_prefixes
)) {
1525 found_prefix
= bgp_debug_list_remove_entry(
1526 bgp_debug_update_prefixes
, NULL
, argv_p
);
1528 if (list_isempty(bgp_debug_update_prefixes
)) {
1529 if (vty
->node
== CONFIG_NODE
) {
1530 DEBUG_OFF(update
, UPDATE_PREFIX
);
1532 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1534 "BGP updates debugging (per prefix) is off\n");
1540 vty_out(vty
, "BGP updates debugging is off for %pFX\n", argv_p
);
1542 vty_out(vty
, "BGP updates debugging was not enabled for %pFX\n",
1545 prefix_free(&argv_p
);
1551 DEFUN (debug_bgp_update_prefix
,
1552 debug_bgp_update_prefix_cmd
,
1553 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1557 "Specify a prefix to debug\n"
1561 int idx_ipv4_ipv6_prefixlen
= 4;
1562 struct prefix
*argv_p
;
1564 argv_p
= prefix_new();
1565 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1568 if (!bgp_debug_update_prefixes
)
1569 bgp_debug_update_prefixes
= list_new();
1571 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1573 "BGP updates debugging is already enabled for %s\n",
1574 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1578 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1580 if (vty
->node
== CONFIG_NODE
) {
1581 DEBUG_ON(update
, UPDATE_PREFIX
);
1583 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1584 vty_out(vty
, "BGP updates debugging is on for %s\n",
1585 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1591 DEFUN (no_debug_bgp_update_prefix
,
1592 no_debug_bgp_update_prefix_cmd
,
1593 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1598 "Specify a prefix to debug\n"
1602 int idx_ipv4_ipv6_prefixlen
= 5;
1603 struct prefix
*argv_p
;
1604 int found_prefix
= 0;
1606 argv_p
= prefix_new();
1607 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1610 if (bgp_debug_update_prefixes
1611 && !list_isempty(bgp_debug_update_prefixes
)) {
1612 found_prefix
= bgp_debug_list_remove_entry(
1613 bgp_debug_update_prefixes
, NULL
, argv_p
);
1615 if (list_isempty(bgp_debug_update_prefixes
)) {
1616 if (vty
->node
== CONFIG_NODE
) {
1617 DEBUG_OFF(update
, UPDATE_PREFIX
);
1619 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1621 "BGP updates debugging (per prefix) is off\n");
1627 vty_out(vty
, "BGP updates debugging is off for %s\n",
1628 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1630 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1631 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1636 DEFUN (no_debug_bgp_update
,
1637 no_debug_bgp_update_cmd
,
1638 "no debug bgp updates",
1644 struct listnode
*ln
;
1647 bgp_debug_list_free(bgp_debug_update_in_peers
);
1648 bgp_debug_list_free(bgp_debug_update_out_peers
);
1649 bgp_debug_list_free(bgp_debug_update_prefixes
);
1651 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1652 bgp_debug_clear_updgrp_update_dbg(bgp
);
1654 if (vty
->node
== CONFIG_NODE
) {
1655 DEBUG_OFF(update
, UPDATE_IN
);
1656 DEBUG_OFF(update
, UPDATE_OUT
);
1657 DEBUG_OFF(update
, UPDATE_PREFIX
);
1659 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1660 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1661 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1662 vty_out(vty
, "BGP updates debugging is off\n");
1667 /* debug bgp zebra */
1668 DEFUN (debug_bgp_zebra
,
1669 debug_bgp_zebra_cmd
,
1673 "BGP Zebra messages\n")
1675 if (vty
->node
== CONFIG_NODE
)
1676 DEBUG_ON(zebra
, ZEBRA
);
1678 TERM_DEBUG_ON(zebra
, ZEBRA
);
1679 vty_out(vty
, "BGP zebra debugging is on\n");
1684 DEFUN (debug_bgp_graceful_restart
,
1685 debug_bgp_graceful_restart_cmd
,
1686 "debug bgp graceful-restart",
1691 if (vty
->node
== CONFIG_NODE
) {
1692 DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1694 TERM_DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1695 vty_out(vty
, "BGP Graceful Restart debugging is on\n");
1701 DEFUN (debug_bgp_zebra_prefix
,
1702 debug_bgp_zebra_prefix_cmd
,
1703 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1706 "BGP Zebra messages\n"
1707 "Specify a prefix to debug\n"
1711 int idx_ipv4_ipv6_prefixlen
= 4;
1712 struct prefix
*argv_p
;
1714 argv_p
= prefix_new();
1715 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1718 if (!bgp_debug_zebra_prefixes
)
1719 bgp_debug_zebra_prefixes
= list_new();
1721 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1722 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1723 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1727 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1729 if (vty
->node
== CONFIG_NODE
)
1730 DEBUG_ON(zebra
, ZEBRA
);
1732 TERM_DEBUG_ON(zebra
, ZEBRA
);
1733 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1734 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1740 DEFUN (no_debug_bgp_zebra
,
1741 no_debug_bgp_zebra_cmd
,
1742 "no debug bgp zebra",
1746 "BGP Zebra messages\n")
1748 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1750 if (vty
->node
== CONFIG_NODE
)
1751 DEBUG_OFF(zebra
, ZEBRA
);
1753 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1754 vty_out(vty
, "BGP zebra debugging is off\n");
1759 DEFUN (no_debug_bgp_graceful_restart
,
1760 no_debug_bgp_graceful_restart_cmd
,
1761 "no debug bgp graceful-restart",
1767 if (vty
->node
== CONFIG_NODE
) {
1768 DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1770 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1771 vty_out(vty
, "BGP Graceful Restart debugging is off\n");
1776 DEFUN (no_debug_bgp_zebra_prefix
,
1777 no_debug_bgp_zebra_prefix_cmd
,
1778 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1782 "BGP Zebra messages\n"
1783 "Specify a prefix to debug\n"
1787 int idx_ipv4_ipv6_prefixlen
= 5;
1788 struct prefix
*argv_p
;
1789 int found_prefix
= 0;
1791 argv_p
= prefix_new();
1792 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1795 if (bgp_debug_zebra_prefixes
1796 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1797 found_prefix
= bgp_debug_list_remove_entry(
1798 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1800 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1801 if (vty
->node
== CONFIG_NODE
)
1802 DEBUG_OFF(zebra
, ZEBRA
);
1804 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1805 vty_out(vty
, "BGP zebra debugging is off\n");
1811 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1812 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1814 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1815 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1820 /* debug bgp update-groups */
1821 DEFUN (debug_bgp_update_groups
,
1822 debug_bgp_update_groups_cmd
,
1823 "debug bgp update-groups",
1826 "BGP update-groups\n")
1828 if (vty
->node
== CONFIG_NODE
)
1829 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1831 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1832 vty_out(vty
, "BGP update-groups debugging is on\n");
1837 DEFUN (no_debug_bgp_update_groups
,
1838 no_debug_bgp_update_groups_cmd
,
1839 "no debug bgp update-groups",
1843 "BGP update-groups\n")
1845 if (vty
->node
== CONFIG_NODE
)
1846 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1848 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1849 vty_out(vty
, "BGP update-groups debugging is off\n");
1854 DEFUN (debug_bgp_vpn
,
1856 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1860 "leaked from vrf to vpn\n"
1861 "leaked to vrf from vpn\n"
1862 "route-map updates\n"
1867 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1868 if (vty
->node
== CONFIG_NODE
)
1869 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1871 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1872 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1873 if (vty
->node
== CONFIG_NODE
)
1874 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1876 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1877 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1878 if (vty
->node
== CONFIG_NODE
)
1879 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1881 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1882 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1883 if (vty
->node
== CONFIG_NODE
)
1884 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1886 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1888 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1889 return CMD_WARNING_CONFIG_FAILED
;
1892 if (vty
->node
!= CONFIG_NODE
)
1893 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1898 DEFUN (no_debug_bgp_vpn
,
1899 no_debug_bgp_vpn_cmd
,
1900 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1905 "leaked from vrf to vpn\n"
1906 "leaked to vrf from vpn\n"
1907 "route-map updates\n"
1912 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1913 if (vty
->node
== CONFIG_NODE
)
1914 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1916 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1918 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1919 if (vty
->node
== CONFIG_NODE
)
1920 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1922 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1923 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1924 if (vty
->node
== CONFIG_NODE
)
1925 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1927 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1928 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1929 if (vty
->node
== CONFIG_NODE
)
1930 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1932 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1934 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1935 return CMD_WARNING_CONFIG_FAILED
;
1938 if (vty
->node
!= CONFIG_NODE
)
1939 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1944 DEFUN (debug_bgp_pbr
,
1946 "debug bgp pbr [error]",
1949 "BGP policy based routing\n"
1954 if (argv_find(argv
, argc
, "error", &idx
)) {
1955 if (vty
->node
== CONFIG_NODE
)
1956 DEBUG_ON(pbr
, PBR_ERROR
);
1958 TERM_DEBUG_ON(pbr
, PBR_ERROR
);
1959 vty_out(vty
, "BGP policy based routing error is on\n");
1963 if (vty
->node
== CONFIG_NODE
)
1966 TERM_DEBUG_ON(pbr
, PBR
);
1967 vty_out(vty
, "BGP policy based routing is on\n");
1972 DEFUN (no_debug_bgp_pbr
,
1973 no_debug_bgp_pbr_cmd
,
1974 "no debug bgp pbr [error]",
1978 "BGP policy based routing\n"
1983 if (argv_find(argv
, argc
, "error", &idx
)) {
1984 if (vty
->node
== CONFIG_NODE
)
1985 DEBUG_OFF(pbr
, PBR_ERROR
);
1987 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1988 vty_out(vty
, "BGP policy based routing error is off\n");
1992 if (vty
->node
== CONFIG_NODE
)
1993 DEBUG_OFF(pbr
, PBR
);
1995 TERM_DEBUG_OFF(pbr
, PBR
);
1996 vty_out(vty
, "BGP policy based routing is off\n");
2001 DEFPY (debug_bgp_evpn_mh
,
2002 debug_bgp_evpn_mh_cmd
,
2003 "[no$no] debug bgp evpn mh <es$es|route$rt>",
2009 "Ethernet Segment debugging\n"
2010 "Route debugging\n")
2013 if (vty
->node
== CONFIG_NODE
) {
2015 DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2017 DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
2020 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2022 "BGP EVPN-MH ES debugging is off\n");
2024 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
2026 "BGP EVPN-MH ES debugging is on\n");
2031 if (vty
->node
== CONFIG_NODE
) {
2033 DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2035 DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
2038 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2040 "BGP EVPN-MH route debugging is off\n");
2042 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
2044 "BGP EVPN-MH route debugging is on\n");
2052 DEFPY (debug_bgp_optimal_route_reflection
,
2053 debug_bgp_optimal_route_reflection_cmd
,
2054 "[no$no] debug bgp optimal-route-reflection",
2060 if (vty
->node
== CONFIG_NODE
) {
2062 DEBUG_OFF(optimal_route_reflection
, ORR
);
2064 DEBUG_ON(optimal_route_reflection
, ORR
);
2067 TERM_DEBUG_OFF(optimal_route_reflection
, ORR
);
2069 "BGP Optimal Route Reflection debugging is off\n");
2071 TERM_DEBUG_ON(optimal_route_reflection
, ORR
);
2073 "BGP Optimal Route Reflection debugging is on\n");
2079 DEFUN (debug_bgp_labelpool
,
2080 debug_bgp_labelpool_cmd
,
2081 "debug bgp labelpool",
2086 if (vty
->node
== CONFIG_NODE
)
2087 DEBUG_ON(labelpool
, LABELPOOL
);
2089 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
2091 if (vty
->node
!= CONFIG_NODE
)
2092 vty_out(vty
, "enabled debug bgp labelpool\n");
2097 DEFUN (no_debug_bgp_labelpool
,
2098 no_debug_bgp_labelpool_cmd
,
2099 "no debug bgp labelpool",
2105 if (vty
->node
== CONFIG_NODE
)
2106 DEBUG_OFF(labelpool
, LABELPOOL
);
2108 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2111 if (vty
->node
!= CONFIG_NODE
)
2112 vty_out(vty
, "disabled debug bgp labelpool\n");
2117 DEFPY(debug_bgp_bfd
, debug_bgp_bfd_cmd
,
2118 "[no] debug bgp bfd",
2122 "Bidirection Forwarding Detection\n")
2124 if (vty
->node
== CONFIG_NODE
) {
2126 DEBUG_OFF(bfd
, BFD_LIB
);
2127 bfd_protocol_integration_set_debug(false);
2129 DEBUG_ON(bfd
, BFD_LIB
);
2130 bfd_protocol_integration_set_debug(true);
2134 TERM_DEBUG_OFF(bfd
, BFD_LIB
);
2135 bfd_protocol_integration_set_debug(false);
2137 TERM_DEBUG_ON(bfd
, BFD_LIB
);
2138 bfd_protocol_integration_set_debug(true);
2145 DEFPY (debug_bgp_cond_adv
,
2146 debug_bgp_cond_adv_cmd
,
2147 "[no$no] debug bgp conditional-advertisement",
2151 "BGP conditional advertisement\n")
2153 if (vty
->node
== CONFIG_NODE
) {
2155 DEBUG_OFF(cond_adv
, COND_ADV
);
2157 DEBUG_ON(cond_adv
, COND_ADV
);
2160 TERM_DEBUG_OFF(cond_adv
, COND_ADV
);
2162 "BGP conditional advertisement debugging is off\n");
2164 TERM_DEBUG_ON(cond_adv
, COND_ADV
);
2166 "BGP conditional advertisement debugging is on\n");
2172 DEFUN (no_debug_bgp
,
2180 struct listnode
*ln
;
2182 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
2183 bgp_debug_list_free(bgp_debug_keepalive_peers
);
2184 bgp_debug_list_free(bgp_debug_update_in_peers
);
2185 bgp_debug_list_free(bgp_debug_update_out_peers
);
2186 bgp_debug_list_free(bgp_debug_update_prefixes
);
2187 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
2188 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
2190 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
2191 bgp_debug_clear_updgrp_update_dbg(bgp
);
2193 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
2194 TERM_DEBUG_OFF(update
, UPDATE_IN
);
2195 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
2196 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
2197 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
2198 TERM_DEBUG_OFF(as4
, AS4
);
2199 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
2200 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
2201 TERM_DEBUG_OFF(zebra
, ZEBRA
);
2202 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
2203 TERM_DEBUG_OFF(nht
, NHT
);
2204 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
2205 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
2206 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
2207 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
2208 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
2209 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2210 TERM_DEBUG_OFF(pbr
, PBR
);
2211 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
2212 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
2213 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2214 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2215 TERM_DEBUG_OFF(bfd
, BFD_LIB
);
2216 TERM_DEBUG_OFF(cond_adv
, COND_ADV
);
2217 TERM_DEBUG_OFF(optimal_route_reflection
, ORR
);
2219 vty_out(vty
, "All possible debugging has been turned off\n");
2224 DEFUN_NOSH (show_debugging_bgp
,
2225 show_debugging_bgp_cmd
,
2226 "show debugging [bgp]",
2231 vty_out(vty
, "BGP debugging status:\n");
2233 if (BGP_DEBUG(as4
, AS4
))
2234 vty_out(vty
, " BGP as4 debugging is on\n");
2236 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
2237 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
2239 if (BGP_DEBUG(bestpath
, BESTPATH
))
2240 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
2241 bgp_debug_bestpath_prefixes
);
2243 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
2244 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
2245 bgp_debug_keepalive_peers
);
2247 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
2248 bgp_debug_list_print(vty
,
2249 " BGP neighbor-events debugging is on",
2250 bgp_debug_neighbor_events_peers
);
2252 if (BGP_DEBUG(nht
, NHT
))
2253 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
2255 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
2256 vty_out(vty
, " BGP update-groups debugging is on\n");
2258 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
2259 bgp_debug_list_print(vty
, " BGP updates debugging is on",
2260 bgp_debug_update_prefixes
);
2262 if (BGP_DEBUG(update
, UPDATE_IN
))
2263 bgp_debug_list_print(vty
,
2264 " BGP updates debugging is on (inbound)",
2265 bgp_debug_update_in_peers
);
2267 if (BGP_DEBUG(update
, UPDATE_OUT
))
2268 bgp_debug_list_print(vty
,
2269 " BGP updates debugging is on (outbound)",
2270 bgp_debug_update_out_peers
);
2272 if (BGP_DEBUG(zebra
, ZEBRA
))
2273 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
2274 bgp_debug_zebra_prefixes
);
2276 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2277 vty_out(vty
, " BGP graceful-restart debugging is on\n");
2279 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
2280 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
2282 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
2284 " BGP route leak from vrf to vpn debugging is on\n");
2285 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
2287 " BGP route leak to vrf from vpn debugging is on\n");
2288 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
2289 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
2290 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
2291 vty_out(vty
, " BGP vpn label event debugging is on\n");
2292 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
2293 vty_out(vty
, " BGP flowspec debugging is on\n");
2294 if (BGP_DEBUG(labelpool
, LABELPOOL
))
2295 vty_out(vty
, " BGP labelpool debugging is on\n");
2297 if (BGP_DEBUG(pbr
, PBR
))
2298 vty_out(vty
, " BGP policy based routing debugging is on\n");
2299 if (BGP_DEBUG(pbr
, PBR_ERROR
))
2300 vty_out(vty
, " BGP policy based routing error debugging is on\n");
2302 if (BGP_DEBUG(evpn_mh
, EVPN_MH_ES
))
2303 vty_out(vty
, " BGP EVPN-MH ES debugging is on\n");
2304 if (BGP_DEBUG(evpn_mh
, EVPN_MH_RT
))
2305 vty_out(vty
, " BGP EVPN-MH route debugging is on\n");
2307 if (BGP_DEBUG(bfd
, BFD_LIB
))
2308 vty_out(vty
, " BGP BFD library debugging is on\n");
2310 if (BGP_DEBUG(cond_adv
, COND_ADV
))
2312 " BGP conditional advertisement debugging is on\n");
2314 if (BGP_DEBUG(optimal_route_reflection
, ORR
))
2316 " BGP Optimal Route Reflection debugging is on\n");
2318 cmd_show_lib_debugs(vty
);
2323 static int bgp_config_write_debug(struct vty
*vty
)
2327 if (CONF_BGP_DEBUG(as4
, AS4
)) {
2328 vty_out(vty
, "debug bgp as4\n");
2332 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
2333 vty_out(vty
, "debug bgp as4 segment\n");
2337 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
2338 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
2339 bgp_debug_bestpath_prefixes
);
2342 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
2343 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
2344 bgp_debug_keepalive_peers
);
2347 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
2348 write
+= bgp_debug_list_conf_print(
2349 vty
, "debug bgp neighbor-events",
2350 bgp_debug_neighbor_events_peers
);
2353 if (CONF_BGP_DEBUG(nht
, NHT
)) {
2354 vty_out(vty
, "debug bgp nht\n");
2358 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
2359 vty_out(vty
, "debug bgp update-groups\n");
2363 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2364 write
+= bgp_debug_list_conf_print(vty
,
2365 "debug bgp updates prefix",
2366 bgp_debug_update_prefixes
);
2369 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
2370 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
2371 bgp_debug_update_in_peers
);
2374 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
2375 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
2376 bgp_debug_update_out_peers
);
2379 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
2380 if (!bgp_debug_zebra_prefixes
2381 || list_isempty(bgp_debug_zebra_prefixes
)) {
2382 vty_out(vty
, "debug bgp zebra\n");
2385 write
+= bgp_debug_list_conf_print(
2386 vty
, "debug bgp zebra prefix",
2387 bgp_debug_zebra_prefixes
);
2391 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
2392 vty_out(vty
, "debug bgp allow-martians\n");
2396 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
2397 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
2400 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
2401 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
2404 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
2405 vty_out(vty
, "debug bgp vpn rmap-event\n");
2408 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
2409 vty_out(vty
, "debug bgp vpn label\n");
2412 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
2413 vty_out(vty
, "debug bgp flowspec\n");
2416 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
2417 vty_out(vty
, "debug bgp labelpool\n");
2421 if (CONF_BGP_DEBUG(pbr
, PBR
)) {
2422 vty_out(vty
, "debug bgp pbr\n");
2425 if (CONF_BGP_DEBUG(pbr
, PBR_ERROR
)) {
2426 vty_out(vty
, "debug bgp pbr error\n");
2430 if (CONF_BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
)) {
2431 vty_out(vty
, "debug bgp graceful-restart\n");
2435 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_ES
)) {
2436 vty_out(vty
, "debug bgp evpn mh es\n");
2439 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_RT
)) {
2440 vty_out(vty
, "debug bgp evpn mh route\n");
2444 if (CONF_BGP_DEBUG(bfd
, BFD_LIB
)) {
2445 vty_out(vty
, "debug bgp bfd\n");
2449 if (CONF_BGP_DEBUG(cond_adv
, COND_ADV
)) {
2450 vty_out(vty
, "debug bgp conditional-advertisement\n");
2454 if (CONF_BGP_DEBUG(optimal_route_reflection
, ORR
)) {
2455 vty_out(vty
, "debug bgp optimal-route-reflection\n");
2462 static int bgp_config_write_debug(struct vty
*vty
);
2463 static struct cmd_node debug_node
= {
2467 .config_write
= bgp_config_write_debug
,
2470 void bgp_debug_init(void)
2472 install_node(&debug_node
);
2474 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
2476 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
2477 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
2478 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
2479 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
2481 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
2482 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
2483 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
2484 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
2485 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
2486 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
2487 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
2488 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
2489 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
2490 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
2491 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
2492 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
2493 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2494 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2496 install_element(ENABLE_NODE
, &debug_bgp_graceful_restart_cmd
);
2497 install_element(CONFIG_NODE
, &debug_bgp_graceful_restart_cmd
);
2499 /* debug bgp updates (in|out) */
2500 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2501 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2502 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2503 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2505 /* debug bgp updates (in|out) A.B.C.D */
2506 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2507 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2508 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2509 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2511 /* debug bgp updates prefix A.B.C.D/M */
2512 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2513 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2514 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2515 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2516 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2517 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2518 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2519 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2521 /* debug bgp zebra prefix A.B.C.D/M */
2522 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2523 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2524 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2525 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2527 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2528 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2529 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2530 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2532 /* debug bgp neighbor-events A.B.C.D */
2533 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2534 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2535 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2536 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2538 /* debug bgp keepalive A.B.C.D */
2539 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2540 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2541 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2542 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2544 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2545 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2546 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2547 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2548 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2549 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2550 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2551 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2552 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2553 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2554 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2555 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2556 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2557 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2558 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2559 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2560 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2562 install_element(ENABLE_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2563 install_element(CONFIG_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2565 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2566 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2567 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2568 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2570 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2571 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2572 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2573 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2576 install_element(ENABLE_NODE
, &debug_bgp_pbr_cmd
);
2577 install_element(CONFIG_NODE
, &debug_bgp_pbr_cmd
);
2578 install_element(ENABLE_NODE
, &no_debug_bgp_pbr_cmd
);
2579 install_element(CONFIG_NODE
, &no_debug_bgp_pbr_cmd
);
2581 install_element(ENABLE_NODE
, &debug_bgp_evpn_mh_cmd
);
2582 install_element(CONFIG_NODE
, &debug_bgp_evpn_mh_cmd
);
2585 install_element(ENABLE_NODE
, &debug_bgp_bfd_cmd
);
2586 install_element(CONFIG_NODE
, &debug_bgp_bfd_cmd
);
2588 /* debug bgp conditional advertisement */
2589 install_element(ENABLE_NODE
, &debug_bgp_cond_adv_cmd
);
2590 install_element(CONFIG_NODE
, &debug_bgp_cond_adv_cmd
);
2592 /* debug bgp optimal route reflection */
2593 install_element(ENABLE_NODE
, &debug_bgp_optimal_route_reflection_cmd
);
2594 install_element(CONFIG_NODE
, &debug_bgp_optimal_route_reflection_cmd
);
2597 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2598 * for BGP_DEBUG_TYPE
2600 static int bgp_debug_per_prefix(const struct prefix
*p
,
2601 unsigned long term_bgp_debug_type
,
2602 unsigned int BGP_DEBUG_TYPE
,
2603 struct list
*per_prefix_list
)
2605 struct bgp_debug_filter
*filter
;
2606 struct listnode
*node
, *nnode
;
2608 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2609 /* We are debugging all prefixes so return true */
2610 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2617 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2619 if (filter
->p
->prefixlen
== p
->prefixlen
2620 && prefix_match(filter
->p
, p
))
2630 /* Return true if this peer is on the per_peer_list of peers to debug
2631 * for BGP_DEBUG_TYPE
2633 static bool bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2634 unsigned int BGP_DEBUG_TYPE
,
2635 struct list
*per_peer_list
)
2637 struct bgp_debug_filter
*filter
;
2638 struct listnode
*node
, *nnode
;
2640 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2641 /* We are debugging all peers so return true */
2642 if (!per_peer_list
|| list_isempty(per_peer_list
))
2649 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2651 if (strcmp(filter
->host
, host
) == 0)
2661 bool bgp_debug_neighbor_events(const struct peer
*peer
)
2668 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2669 BGP_DEBUG_NEIGHBOR_EVENTS
,
2670 bgp_debug_neighbor_events_peers
);
2673 bool bgp_debug_keepalive(const struct peer
*peer
)
2680 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2681 BGP_DEBUG_KEEPALIVE
,
2682 bgp_debug_keepalive_peers
);
2685 bool bgp_debug_update(const struct peer
*peer
, const struct prefix
*p
,
2686 struct update_group
*updgrp
, unsigned int inbound
)
2694 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2695 BGP_DEBUG_UPDATE_IN
,
2696 bgp_debug_update_in_peers
))
2702 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2703 BGP_DEBUG_UPDATE_OUT
,
2704 bgp_debug_update_out_peers
))
2707 /* Check if update debugging implicitly enabled for the group.
2709 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2714 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2715 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2716 BGP_DEBUG_UPDATE_PREFIX
,
2717 bgp_debug_update_prefixes
))
2724 bool bgp_debug_bestpath(struct bgp_dest
*dest
)
2726 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2727 if (bgp_debug_per_prefix(
2728 bgp_dest_get_prefix(dest
), term_bgp_debug_bestpath
,
2729 BGP_DEBUG_BESTPATH
, bgp_debug_bestpath_prefixes
))
2736 bool bgp_debug_zebra(const struct prefix
*p
)
2738 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2739 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2741 bgp_debug_zebra_prefixes
))
2748 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2749 const struct prefix_rd
*prd
,
2750 union prefixconstptr pu
,
2751 mpls_label_t
*label
, uint32_t num_labels
,
2752 int addpath_valid
, uint32_t addpath_id
,
2753 struct bgp_route_evpn
*overlay_index
,
2754 char *str
, int size
)
2757 char overlay_index_buf
[INET6_ADDRSTRLEN
+ 14];
2758 const struct prefix_evpn
*evp
;
2760 /* ' with addpath ID ' 17
2761 * max strlen of uint32 + 10
2762 * +/- (just in case) + 1
2763 * null terminator + 1
2764 * ============================ 29 */
2765 char pathid_buf
[30];
2767 if (size
< BGP_PRD_PATH_STRLEN
)
2770 /* Note: Path-id is created by default, but only included in update
2772 pathid_buf
[0] = '\0';
2774 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2777 overlay_index_buf
[0] = '\0';
2778 if (overlay_index
&& overlay_index
->type
== OVERLAY_INDEX_GATEWAY_IP
) {
2779 char obuf
[INET6_ADDRSTRLEN
];
2783 if (is_evpn_prefix_ipaddr_v4(evp
))
2784 inet_ntop(AF_INET
, &overlay_index
->gw_ip
, obuf
,
2786 else if (is_evpn_prefix_ipaddr_v6(evp
))
2787 inet_ntop(AF_INET6
, &overlay_index
->gw_ip
, obuf
,
2790 snprintf(overlay_index_buf
, sizeof(overlay_index_buf
),
2791 " gateway IP %s", obuf
);
2795 if (bgp_labeled_safi(safi
) && num_labels
) {
2797 if (safi
== SAFI_EVPN
) {
2800 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2801 snprintf(tag_buf
, sizeof(tag_buf
), " label %s",
2804 uint32_t label_value
;
2806 label_value
= decode_label(label
);
2807 snprintf(tag_buf
, sizeof(tag_buf
), " label %u",
2813 snprintfrr(str
, size
, "RD %pRD %pFX%s%s%s %s %s", prd
, pu
.p
,
2814 overlay_index_buf
, tag_buf
, pathid_buf
, afi2str(afi
),
2816 else if (safi
== SAFI_FLOWSPEC
) {
2817 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2818 const struct prefix_fs
*fs
= pu
.fs
;
2820 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2821 fs
->prefix
.prefixlen
,
2823 NLRI_STRING_FORMAT_DEBUG
, NULL
,
2824 family2afi(fs
->prefix
.family
));
2825 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2828 snprintfrr(str
, size
, "%pFX%s%s %s %s", pu
.p
, tag_buf
,
2829 pathid_buf
, afi2str(afi
), safi2str(safi
));