1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP-4, BGP-4+ packet debug routine
3 * Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
9 #include "lib/printfrr.h"
15 #include "sockunion.h"
20 #include "bgpd/bgpd.h"
21 #include "bgpd/bgp_aspath.h"
22 #include "bgpd/bgp_route.h"
23 #include "bgpd/bgp_attr.h"
24 #include "bgpd/bgp_debug.h"
25 #include "bgpd/bgp_community.h"
26 #include "bgpd/bgp_lcommunity.h"
27 #include "bgpd/bgp_updgrp.h"
28 #include "bgpd/bgp_mplsvpn.h"
29 #include "bgpd/bgp_ecommunity.h"
30 #include "bgpd/bgp_label.h"
31 #include "bgpd/bgp_evpn.h"
32 #include "bgpd/bgp_evpn_private.h"
33 #include "bgpd/bgp_evpn_vty.h"
34 #include "bgpd/bgp_vty.h"
35 #include "bgpd/bgp_flowspec.h"
36 #include "bgpd/bgp_packet.h"
38 #include "bgpd/bgp_debug_clippy.c"
40 unsigned long conf_bgp_debug_as4
;
41 unsigned long conf_bgp_debug_neighbor_events
;
42 unsigned long conf_bgp_debug_events
;
43 unsigned long conf_bgp_debug_packet
;
44 unsigned long conf_bgp_debug_filter
;
45 unsigned long conf_bgp_debug_keepalive
;
46 unsigned long conf_bgp_debug_update
;
47 unsigned long conf_bgp_debug_bestpath
;
48 unsigned long conf_bgp_debug_zebra
;
49 unsigned long conf_bgp_debug_allow_martians
;
50 unsigned long conf_bgp_debug_nht
;
51 unsigned long conf_bgp_debug_update_groups
;
52 unsigned long conf_bgp_debug_vpn
;
53 unsigned long conf_bgp_debug_flowspec
;
54 unsigned long conf_bgp_debug_labelpool
;
55 unsigned long conf_bgp_debug_pbr
;
56 unsigned long conf_bgp_debug_graceful_restart
;
57 unsigned long conf_bgp_debug_evpn_mh
;
58 unsigned long conf_bgp_debug_bfd
;
59 unsigned long conf_bgp_debug_cond_adv
;
61 unsigned long term_bgp_debug_as4
;
62 unsigned long term_bgp_debug_neighbor_events
;
63 unsigned long term_bgp_debug_events
;
64 unsigned long term_bgp_debug_packet
;
65 unsigned long term_bgp_debug_filter
;
66 unsigned long term_bgp_debug_keepalive
;
67 unsigned long term_bgp_debug_update
;
68 unsigned long term_bgp_debug_bestpath
;
69 unsigned long term_bgp_debug_zebra
;
70 unsigned long term_bgp_debug_allow_martians
;
71 unsigned long term_bgp_debug_nht
;
72 unsigned long term_bgp_debug_update_groups
;
73 unsigned long term_bgp_debug_vpn
;
74 unsigned long term_bgp_debug_flowspec
;
75 unsigned long term_bgp_debug_labelpool
;
76 unsigned long term_bgp_debug_pbr
;
77 unsigned long term_bgp_debug_graceful_restart
;
78 unsigned long term_bgp_debug_evpn_mh
;
79 unsigned long term_bgp_debug_bfd
;
80 unsigned long term_bgp_debug_cond_adv
;
82 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
83 struct list
*bgp_debug_keepalive_peers
= NULL
;
84 struct list
*bgp_debug_update_out_peers
= NULL
;
85 struct list
*bgp_debug_update_in_peers
= NULL
;
86 struct list
*bgp_debug_update_prefixes
= NULL
;
87 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
88 struct list
*bgp_debug_zebra_prefixes
= NULL
;
90 /* messages for BGP-4 status */
91 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
94 {OpenSent
, "OpenSent"},
95 {OpenConfirm
, "OpenConfirm"},
96 {Established
, "Established"},
97 {Clearing
, "Clearing"},
101 /* BGP message type string. */
102 const char *const bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
103 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
106 /* message for BGP-4 Notify */
107 static const struct message bgp_notify_msg
[] = {
108 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
109 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
110 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
111 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
112 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
113 {BGP_NOTIFY_CEASE
, "Cease"},
114 {BGP_NOTIFY_ROUTE_REFRESH_ERR
, "ROUTE-REFRESH Message Error"},
117 static const struct message bgp_notify_head_msg
[] = {
118 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
119 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
120 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
123 static const struct message bgp_notify_open_msg
[] = {
124 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
125 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
126 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
127 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
128 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
129 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
130 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
131 {BGP_NOTIFY_OPEN_ROLE_MISMATCH
, "/Role Mismatch"},
134 static const struct message bgp_notify_update_msg
[] = {
135 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
136 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
137 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
138 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
139 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
140 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
141 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
142 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
143 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
144 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
145 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
148 static const struct message bgp_notify_cease_msg
[] = {
149 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
150 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
151 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administrative Shutdown"},
152 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer De-configured"},
153 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administrative Reset"},
154 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
155 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
156 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
157 "/Connection Collision Resolution"},
158 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resources"},
159 {BGP_NOTIFY_CEASE_HARD_RESET
, "/Hard Reset"},
160 {BGP_NOTIFY_CEASE_BFD_DOWN
, "/BFD Down"},
163 static const struct message bgp_notify_route_refresh_msg
[] = {
164 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
165 {BGP_NOTIFY_ROUTE_REFRESH_INVALID_MSG_LEN
, "/Invalid Message Length"},
168 static const struct message bgp_notify_fsm_msg
[] = {
169 {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC
, "/Unspecific"},
170 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT
,
171 "/Receive Unexpected Message in OpenSent State"},
172 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM
,
173 "/Receive Unexpected Message in OpenConfirm State"},
174 {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED
,
175 "/Receive Unexpected Message in Established State"},
178 /* Origin strings. */
179 const char *const bgp_origin_str
[] = {"i", "e", "?"};
180 const char *const bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
182 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
184 /* Given a string return a pointer the corresponding peer structure */
185 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
187 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
195 ret
= str2sockunion(peer_str
, &su
);
199 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
202 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
206 return peer_lookup(bgp
, &su
);
209 static void bgp_debug_list_free(struct list
*list
)
211 struct bgp_debug_filter
*filter
;
212 struct listnode
*node
, *nnode
;
215 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
216 listnode_delete(list
, filter
);
217 prefix_free(&filter
->p
);
218 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
219 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
224 * Print the desc along with a list of peers/prefixes this debug is
227 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
230 struct bgp_debug_filter
*filter
;
231 struct listnode
*node
, *nnode
;
233 vty_out(vty
, "%s", desc
);
235 if (list
&& !list_isempty(list
)) {
236 vty_out(vty
, " for");
237 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
239 vty_out(vty
, " %s", filter
->host
);
241 if (filter
->p
&& filter
->p
->family
== AF_EVPN
)
242 bgp_debug_print_evpn_prefix(vty
, "", filter
->p
);
244 vty_out(vty
, " %pFX", filter
->p
);
252 * Print the command to enable the debug for each peer/prefix this debug is
255 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
258 struct bgp_debug_filter
*filter
;
259 struct listnode
*node
, *nnode
;
262 if (list
&& !list_isempty(list
)) {
263 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
265 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
269 if (filter
->p
&& filter
->p
->family
== AF_EVPN
) {
270 bgp_debug_print_evpn_prefix(vty
, desc
,
273 } else if (filter
->p
) {
274 vty_out(vty
, "%s %pFX\n", desc
, filter
->p
);
281 vty_out(vty
, "%s\n", desc
);
288 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
289 const struct prefix
*p
)
291 struct bgp_debug_filter
*filter
;
293 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
294 sizeof(struct bgp_debug_filter
));
297 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
301 filter
->p
= prefix_new();
302 prefix_copy(filter
->p
, p
);
305 listnode_add(list
, filter
);
308 static bool bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
309 const struct prefix
*p
)
311 struct bgp_debug_filter
*filter
;
312 struct listnode
*node
, *nnode
;
314 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
315 if (host
&& strcmp(filter
->host
, host
) == 0) {
316 listnode_delete(list
, filter
);
317 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
318 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
320 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
321 && prefix_match(filter
->p
, p
)) {
322 listnode_delete(list
, filter
);
323 prefix_free(&filter
->p
);
324 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
332 static bool bgp_debug_list_has_entry(struct list
*list
, const char *host
,
333 const struct prefix
*p
)
335 struct bgp_debug_filter
*filter
;
336 struct listnode
*node
, *nnode
;
338 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
340 if (strcmp(filter
->host
, host
) == 0) {
344 if (filter
->p
->prefixlen
== p
->prefixlen
345 && prefix_match(filter
->p
, p
)) {
354 bool bgp_debug_peer_updout_enabled(char *host
)
356 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
360 /* Dump attribute. */
361 bool bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
368 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
369 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
371 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
372 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
373 bgp_origin_str
[attr
->origin
]);
376 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
377 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
378 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
379 ", mp_nexthop %pI6", &attr
->mp_nexthop_global
);
381 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
382 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
), "(%pI6)",
383 &attr
->mp_nexthop_local
);
385 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
386 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
388 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
389 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
390 ", localpref %u", attr
->local_pref
);
392 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AIGP
)))
393 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
394 ", aigp-metric %" PRIu64
,
395 (unsigned long long)bgp_attr_get_aigp_metric(attr
));
397 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
398 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
401 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
402 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
404 community_str(bgp_attr_get_community(attr
), false,
407 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
)))
408 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
409 ", large-community %s",
410 lcommunity_str(bgp_attr_get_lcommunity(attr
), false,
413 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
414 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
416 ecommunity_str(bgp_attr_get_ecommunity(attr
)));
418 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
419 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
420 ", atomic-aggregate");
422 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
423 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
424 ", aggregated by %u %pI4", attr
->aggregator_as
,
425 &attr
->aggregator_addr
);
427 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
428 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
429 ", originator %pI4", &attr
->originator_id
);
431 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
432 struct cluster_list
*cluster
;
435 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
438 cluster
= bgp_attr_get_cluster(attr
);
439 for (i
= 0; i
< cluster
->length
/ 4; i
++)
440 snprintfrr(buf
+ strlen(buf
), size
- strlen(buf
),
441 " %pI4", &cluster
->list
[i
]);
444 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
445 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
446 ", pmsi tnltype %u", bgp_attr_get_pmsi_tnl_type(attr
));
448 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
449 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
450 aspath_print(attr
->aspath
));
452 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
453 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
454 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
455 ", label-index %u", attr
->label_index
);
464 const char *bgp_notify_code_str(char code
)
466 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
469 const char *bgp_notify_subcode_str(char code
, char subcode
)
473 case BGP_NOTIFY_HEADER_ERR
:
474 return lookup_msg(bgp_notify_head_msg
, subcode
,
475 "Unrecognized Error Subcode");
476 case BGP_NOTIFY_OPEN_ERR
:
477 return lookup_msg(bgp_notify_open_msg
, subcode
,
478 "Unrecognized Error Subcode");
479 case BGP_NOTIFY_UPDATE_ERR
:
480 return lookup_msg(bgp_notify_update_msg
, subcode
,
481 "Unrecognized Error Subcode");
482 case BGP_NOTIFY_HOLD_ERR
:
484 case BGP_NOTIFY_FSM_ERR
:
485 return lookup_msg(bgp_notify_fsm_msg
, subcode
,
486 "Unrecognized Error Subcode");
487 case BGP_NOTIFY_CEASE
:
488 return lookup_msg(bgp_notify_cease_msg
, subcode
,
489 "Unrecognized Error Subcode");
490 case BGP_NOTIFY_ROUTE_REFRESH_ERR
:
491 return lookup_msg(bgp_notify_route_refresh_msg
, subcode
,
492 "Unrecognized Error Subcode");
497 /* extract notify admin reason if correctly present */
498 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, uint8_t *data
,
501 if (!data
|| datalen
< 1)
504 uint8_t len
= data
[0];
505 if (!len
|| len
> datalen
- 1)
508 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
511 /* dump notify packet */
512 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
513 const char *direct
, bool hard_reset
)
515 const char *subcode_str
;
516 const char *code_str
;
517 const char *msg_str
= NULL
;
520 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
521 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
522 code_str
= bgp_notify_code_str(bgp_notify
->code
);
523 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
524 bgp_notify
->subcode
);
526 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
527 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
528 || bgp_notify
->subcode
529 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
530 msg_str
= bgp_notify_admin_message(
531 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
537 "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) \"%s\"",
538 hard_reset
? "(Hard Reset)" : "",
539 strcmp(direct
, "received") == 0
542 peer
->host
, bgp_notify
->code
,
543 bgp_notify
->subcode
, code_str
, subcode_str
,
546 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
548 "%%NOTIFICATION%s: %s neighbor %s %d/%d (%s%s) %d bytes %s",
549 hard_reset
? "(Hard Reset)" : "",
550 strcmp(direct
, "received") == 0
553 peer
->host
, bgp_notify
->code
,
554 bgp_notify
->subcode
, code_str
, subcode_str
,
555 bgp_notify
->length
, msg_str
);
560 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
563 bgp
= bgp_get_default();
564 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
567 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
570 char evpn_desc
[PREFIX2STR_BUFFER
+ INET_ADDRSTRLEN
];
571 char buf
[PREFIX2STR_BUFFER
];
572 char buf2
[ETHER_ADDR_STRLEN
];
574 if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_MAC_IP_ROUTE
) {
575 if (is_evpn_prefix_ipaddr_none((struct prefix_evpn
*)p
)) {
577 evpn_desc
, sizeof(evpn_desc
),
578 "l2vpn evpn type macip mac %s",
579 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
580 buf2
, sizeof(buf2
)));
582 uint8_t family
= is_evpn_prefix_ipaddr_v4(
583 (struct prefix_evpn
*)p
) ?
586 evpn_desc
, sizeof(evpn_desc
),
587 "l2vpn evpn type macip mac %s ip %s",
588 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
592 &p
->u
.prefix_evpn
.macip_addr
.ip
.ip
.addr
,
593 buf
, PREFIX2STR_BUFFER
));
595 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IMET_ROUTE
) {
596 snprintfrr(evpn_desc
, sizeof(evpn_desc
),
597 "l2vpn evpn type multicast ip %pI4",
598 &p
->u
.prefix_evpn
.imet_addr
.ip
.ipaddr_v4
);
599 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
600 uint8_t family
= is_evpn_prefix_ipaddr_v4(
601 (struct prefix_evpn
*)p
) ? AF_INET
603 snprintf(evpn_desc
, sizeof(evpn_desc
),
604 "l2vpn evpn type prefix ip %s/%d",
606 &p
->u
.prefix_evpn
.prefix_addr
.ip
.ip
.addr
,
607 buf
, PREFIX2STR_BUFFER
),
608 p
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
);
611 vty_out(vty
, "%s %s\n", desc
, evpn_desc
);
614 static int bgp_debug_parse_evpn_prefix(struct vty
*vty
, struct cmd_token
**argv
,
615 int argc
, struct prefix
*argv_p
)
617 struct ethaddr mac
= {};
618 struct ipaddr ip
= {};
623 if (bgp_evpn_cli_parse_type(&evpn_type
, argv
, argc
) < 0)
626 if (evpn_type
== BGP_EVPN_MAC_IP_ROUTE
) {
627 memset(&ip
, 0, sizeof(ip
));
629 if (argv_find(argv
, argc
, "mac", &mac_idx
))
630 if (!prefix_str2mac(argv
[mac_idx
+ 1]->arg
, &mac
)) {
631 vty_out(vty
, "%% Malformed MAC address\n");
635 if (argv_find(argv
, argc
, "ip", &ip_idx
))
636 if (str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
) != 0) {
637 vty_out(vty
, "%% Malformed IP address\n");
641 build_evpn_type2_prefix((struct prefix_evpn
*)argv_p
,
643 } else if (evpn_type
== BGP_EVPN_IMET_ROUTE
) {
644 memset(&ip
, 0, sizeof(ip
));
646 if (argv_find(argv
, argc
, "ip", &ip_idx
))
647 if (str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
) != 0) {
648 vty_out(vty
, "%% Malformed IP address\n");
652 build_evpn_type3_prefix((struct prefix_evpn
*)argv_p
,
654 } else if (evpn_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
655 struct prefix ip_prefix
;
657 memset(&ip_prefix
, 0, sizeof(ip_prefix
));
658 if (argv_find(argv
, argc
, "ip", &ip_idx
)) {
659 (void)str2prefix(argv
[ip_idx
+ 1]->arg
, &ip_prefix
);
660 apply_mask(&ip_prefix
);
662 build_type5_prefix_from_ip_prefix(
663 (struct prefix_evpn
*)argv_p
,
670 /* Debug option setting interface. */
671 unsigned long bgp_debug_option
= 0;
673 int debug(unsigned int option
)
675 return bgp_debug_option
& option
;
678 DEFUN (debug_bgp_as4
,
685 if (vty
->node
== CONFIG_NODE
)
688 TERM_DEBUG_ON(as4
, AS4
);
689 vty_out(vty
, "BGP as4 debugging is on\n");
694 DEFUN (no_debug_bgp_as4
,
695 no_debug_bgp_as4_cmd
,
702 if (vty
->node
== CONFIG_NODE
)
705 TERM_DEBUG_OFF(as4
, AS4
);
706 vty_out(vty
, "BGP as4 debugging is off\n");
711 DEFUN (debug_bgp_as4_segment
,
712 debug_bgp_as4_segment_cmd
,
713 "debug bgp as4 segment",
717 "BGP AS4 aspath segment handling\n")
719 if (vty
->node
== CONFIG_NODE
)
720 DEBUG_ON(as4
, AS4_SEGMENT
);
722 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
723 vty_out(vty
, "BGP as4 segment debugging is on\n");
728 DEFUN (no_debug_bgp_as4_segment
,
729 no_debug_bgp_as4_segment_cmd
,
730 "no debug bgp as4 segment",
735 "BGP AS4 aspath segment handling\n")
737 if (vty
->node
== CONFIG_NODE
)
738 DEBUG_OFF(as4
, AS4_SEGMENT
);
740 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
741 vty_out(vty
, "BGP as4 segment debugging is off\n");
746 /* debug bgp neighbor_events */
747 DEFUN (debug_bgp_neighbor_events
,
748 debug_bgp_neighbor_events_cmd
,
749 "debug bgp neighbor-events",
752 "BGP Neighbor Events\n")
754 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
756 if (vty
->node
== CONFIG_NODE
)
757 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
759 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
760 vty_out(vty
, "BGP neighbor-events debugging is on\n");
765 DEFUN (debug_bgp_neighbor_events_peer
,
766 debug_bgp_neighbor_events_peer_cmd
,
767 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
770 "BGP Neighbor Events\n"
771 "BGP neighbor IP address to debug\n"
772 "BGP IPv6 neighbor to debug\n"
773 "BGP neighbor on interface to debug\n")
776 const char *host
= argv
[idx_peer
]->arg
;
778 if (!bgp_debug_neighbor_events_peers
)
779 bgp_debug_neighbor_events_peers
= list_new();
781 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
784 "BGP neighbor-events debugging is already enabled for %s\n",
789 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
791 if (vty
->node
== CONFIG_NODE
)
792 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
794 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
795 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
801 DEFUN (no_debug_bgp_neighbor_events
,
802 no_debug_bgp_neighbor_events_cmd
,
803 "no debug bgp neighbor-events",
809 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
811 if (vty
->node
== CONFIG_NODE
)
812 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
814 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
815 vty_out(vty
, "BGP neighbor-events debugging is off\n");
820 DEFUN (no_debug_bgp_neighbor_events_peer
,
821 no_debug_bgp_neighbor_events_peer_cmd
,
822 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
827 "BGP neighbor IP address to debug\n"
828 "BGP IPv6 neighbor to debug\n"
829 "BGP neighbor on interface to debug\n")
833 const char *host
= argv
[idx_peer
]->arg
;
835 if (bgp_debug_neighbor_events_peers
836 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
837 found_peer
= bgp_debug_list_remove_entry(
838 bgp_debug_neighbor_events_peers
, host
, NULL
);
840 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
841 if (vty
->node
== CONFIG_NODE
)
842 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
844 TERM_DEBUG_OFF(neighbor_events
,
850 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
854 "BGP neighbor-events debugging was not enabled for %s\n",
861 DEFUN (debug_bgp_nht
,
866 "BGP nexthop tracking events\n")
868 if (vty
->node
== CONFIG_NODE
)
871 TERM_DEBUG_ON(nht
, NHT
);
872 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
877 DEFUN (no_debug_bgp_nht
,
878 no_debug_bgp_nht_cmd
,
883 "BGP nexthop tracking events\n")
885 if (vty
->node
== CONFIG_NODE
)
888 TERM_DEBUG_OFF(nht
, NHT
);
889 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
894 /* debug bgp keepalives */
895 DEFUN (debug_bgp_keepalive
,
896 debug_bgp_keepalive_cmd
,
897 "debug bgp keepalives",
902 bgp_debug_list_free(bgp_debug_keepalive_peers
);
904 if (vty
->node
== CONFIG_NODE
)
905 DEBUG_ON(keepalive
, KEEPALIVE
);
907 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
908 vty_out(vty
, "BGP keepalives debugging is on\n");
913 DEFUN (debug_bgp_keepalive_peer
,
914 debug_bgp_keepalive_peer_cmd
,
915 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
919 "BGP IPv4 neighbor to debug\n"
920 "BGP IPv6 neighbor to debug\n"
921 "BGP neighbor on interface to debug\n")
924 const char *host
= argv
[idx_peer
]->arg
;
926 if (!bgp_debug_keepalive_peers
)
927 bgp_debug_keepalive_peers
= list_new();
929 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
931 "BGP keepalive debugging is already enabled for %s\n",
936 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
938 if (vty
->node
== CONFIG_NODE
)
939 DEBUG_ON(keepalive
, KEEPALIVE
);
941 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
942 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
947 DEFUN (no_debug_bgp_keepalive
,
948 no_debug_bgp_keepalive_cmd
,
949 "no debug bgp keepalives",
955 bgp_debug_list_free(bgp_debug_keepalive_peers
);
957 if (vty
->node
== CONFIG_NODE
)
958 DEBUG_OFF(keepalive
, KEEPALIVE
);
960 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
961 vty_out(vty
, "BGP keepalives debugging is off\n");
966 DEFUN (no_debug_bgp_keepalive_peer
,
967 no_debug_bgp_keepalive_peer_cmd
,
968 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
973 "BGP neighbor IP address to debug\n"
974 "BGP IPv6 neighbor to debug\n"
975 "BGP neighbor on interface to debug\n")
979 const char *host
= argv
[idx_peer
]->arg
;
981 if (bgp_debug_keepalive_peers
982 && !list_isempty(bgp_debug_keepalive_peers
)) {
983 found_peer
= bgp_debug_list_remove_entry(
984 bgp_debug_keepalive_peers
, host
, NULL
);
986 if (list_isempty(bgp_debug_keepalive_peers
)) {
987 if (vty
->node
== CONFIG_NODE
)
988 DEBUG_OFF(keepalive
, KEEPALIVE
);
990 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
995 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
998 "BGP keepalives debugging was not enabled for %s\n",
1004 /* debug bgp bestpath */
1005 DEFPY (debug_bgp_bestpath_prefix
,
1006 debug_bgp_bestpath_prefix_cmd
,
1007 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>$prefix",
1014 if (!bgp_debug_bestpath_prefixes
)
1015 bgp_debug_bestpath_prefixes
= list_new();
1017 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
1020 "BGP bestpath debugging is already enabled for %s\n",
1025 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, prefix
);
1027 if (vty
->node
== CONFIG_NODE
) {
1028 DEBUG_ON(bestpath
, BESTPATH
);
1030 TERM_DEBUG_ON(bestpath
, BESTPATH
);
1031 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
1038 DEFPY (no_debug_bgp_bestpath_prefix
,
1039 no_debug_bgp_bestpath_prefix_cmd
,
1040 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>$prefix",
1048 bool found_prefix
= false;
1050 if (bgp_debug_bestpath_prefixes
1051 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
1052 found_prefix
= bgp_debug_list_remove_entry(
1053 bgp_debug_bestpath_prefixes
, NULL
, prefix
);
1055 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
1056 if (vty
->node
== CONFIG_NODE
) {
1057 DEBUG_OFF(bestpath
, BESTPATH
);
1059 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1061 "BGP bestpath debugging (per prefix) is off\n");
1067 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
1070 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
1076 DEFUN (no_debug_bgp_bestpath
,
1077 no_debug_bgp_bestpath_cmd
,
1078 "no debug bgp bestpath",
1084 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1086 if (vty
->node
== CONFIG_NODE
)
1087 DEBUG_OFF(bestpath
, BESTPATH
);
1089 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1090 vty_out(vty
, "BGP bestpath debugging is off\n");
1095 /* debug bgp updates */
1096 DEFUN (debug_bgp_update
,
1097 debug_bgp_update_cmd
,
1098 "debug bgp updates",
1103 bgp_debug_list_free(bgp_debug_update_in_peers
);
1104 bgp_debug_list_free(bgp_debug_update_out_peers
);
1105 bgp_debug_list_free(bgp_debug_update_prefixes
);
1107 if (vty
->node
== CONFIG_NODE
) {
1108 DEBUG_ON(update
, UPDATE_IN
);
1109 DEBUG_ON(update
, UPDATE_OUT
);
1111 TERM_DEBUG_ON(update
, UPDATE_IN
);
1112 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1113 vty_out(vty
, "BGP updates debugging is on\n");
1118 DEFUN (debug_bgp_update_direct
,
1119 debug_bgp_update_direct_cmd
,
1120 "debug bgp updates <in|out>",
1125 "Outbound updates\n")
1129 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1130 bgp_debug_list_free(bgp_debug_update_in_peers
);
1132 bgp_debug_list_free(bgp_debug_update_out_peers
);
1134 if (vty
->node
== CONFIG_NODE
) {
1135 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1136 DEBUG_ON(update
, UPDATE_IN
);
1138 DEBUG_ON(update
, UPDATE_OUT
);
1140 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1141 TERM_DEBUG_ON(update
, UPDATE_IN
);
1142 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1144 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1146 "BGP updates debugging is on (outbound)\n");
1152 DEFUN (debug_bgp_update_direct_peer
,
1153 debug_bgp_update_direct_peer_cmd
,
1154 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1159 "Outbound updates\n"
1160 "BGP neighbor IP address to debug\n"
1161 "BGP IPv6 neighbor to debug\n"
1162 "BGP neighbor on interface to debug\n")
1166 const char *host
= argv
[idx_peer
]->arg
;
1169 if (!bgp_debug_update_in_peers
)
1170 bgp_debug_update_in_peers
= list_new();
1172 if (!bgp_debug_update_out_peers
)
1173 bgp_debug_update_out_peers
= list_new();
1175 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1181 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1184 "BGP inbound update debugging is already enabled for %s\n",
1191 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1194 "BGP outbound update debugging is already enabled for %s\n",
1201 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1204 struct peer_af
*paf
;
1207 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1209 peer
= bgp_find_peer(vty
, host
);
1212 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1214 paf
= peer
->peer_af_array
[afidx
];
1216 if (PAF_SUBGRP(paf
)) {
1226 if (vty
->node
== CONFIG_NODE
) {
1228 DEBUG_ON(update
, UPDATE_IN
);
1230 DEBUG_ON(update
, UPDATE_OUT
);
1233 TERM_DEBUG_ON(update
, UPDATE_IN
);
1235 "BGP updates debugging is on (inbound) for %s\n",
1236 argv
[idx_peer
]->arg
);
1238 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1240 "BGP updates debugging is on (outbound) for %s\n",
1241 argv
[idx_peer
]->arg
);
1247 DEFUN (no_debug_bgp_update_direct
,
1248 no_debug_bgp_update_direct_cmd
,
1249 "no debug bgp updates <in|out>",
1255 "Outbound updates\n")
1258 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1259 bgp_debug_list_free(bgp_debug_update_in_peers
);
1261 if (vty
->node
== CONFIG_NODE
) {
1262 DEBUG_OFF(update
, UPDATE_IN
);
1264 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1266 "BGP updates debugging is off (inbound)\n");
1269 bgp_debug_list_free(bgp_debug_update_out_peers
);
1271 if (vty
->node
== CONFIG_NODE
) {
1272 DEBUG_OFF(update
, UPDATE_OUT
);
1274 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1276 "BGP updates debugging is off (outbound)\n");
1283 DEFUN (no_debug_bgp_update_direct_peer
,
1284 no_debug_bgp_update_direct_peer_cmd
,
1285 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1291 "Outbound updates\n"
1292 "BGP neighbor IP address to debug\n"
1293 "BGP IPv6 neighbor to debug\n"
1294 "BGP neighbor on interface to debug\n")
1300 const char *host
= argv
[idx_peer
]->arg
;
1302 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1307 if (inbound
&& bgp_debug_update_in_peers
1308 && !list_isempty(bgp_debug_update_in_peers
)) {
1309 found_peer
= bgp_debug_list_remove_entry(
1310 bgp_debug_update_in_peers
, host
, NULL
);
1312 if (list_isempty(bgp_debug_update_in_peers
)) {
1313 if (vty
->node
== CONFIG_NODE
)
1314 DEBUG_OFF(update
, UPDATE_IN
);
1316 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1318 "BGP updates debugging (inbound) is off\n");
1323 if (!inbound
&& bgp_debug_update_out_peers
1324 && !list_isempty(bgp_debug_update_out_peers
)) {
1325 found_peer
= bgp_debug_list_remove_entry(
1326 bgp_debug_update_out_peers
, host
, NULL
);
1328 if (list_isempty(bgp_debug_update_out_peers
)) {
1329 if (vty
->node
== CONFIG_NODE
)
1330 DEBUG_OFF(update
, UPDATE_OUT
);
1332 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1334 "BGP updates debugging (outbound) is off\n");
1339 struct peer_af
*paf
;
1341 peer
= bgp_find_peer(vty
, host
);
1344 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1346 paf
= peer
->peer_af_array
[afidx
];
1348 if (PAF_SUBGRP(paf
)) {
1349 UPDGRP_PEER_DBG_DIS(
1361 "BGP updates debugging (inbound) is off for %s\n",
1365 "BGP updates debugging (outbound) is off for %s\n",
1369 "BGP updates debugging (inbound) was not enabled for %s\n",
1373 "BGP updates debugging (outbound) was not enabled for %s\n",
1379 DEFPY (debug_bgp_update_prefix_afi_safi
,
1380 debug_bgp_update_prefix_afi_safi_cmd
,
1381 "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>>",
1385 "Specify a prefix to debug\n"
1389 EVPN_TYPE_2_HELP_STR
1390 EVPN_TYPE_2_HELP_STR
1391 MAC_STR MAC_STR MAC_STR
1395 EVPN_TYPE_3_HELP_STR
1396 EVPN_TYPE_3_HELP_STR
1400 EVPN_TYPE_5_HELP_STR
1401 EVPN_TYPE_5_HELP_STR
1406 struct prefix argv_p
;
1407 int ret
= CMD_SUCCESS
;
1409 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1410 if (ret
!= CMD_SUCCESS
)
1413 if (!bgp_debug_update_prefixes
)
1414 bgp_debug_update_prefixes
= list_new();
1416 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
,
1419 "BGP updates debugging is already enabled for %pFX\n",
1424 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, &argv_p
);
1426 if (vty
->node
== CONFIG_NODE
) {
1427 DEBUG_ON(update
, UPDATE_PREFIX
);
1429 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1430 vty_out(vty
, "BGP updates debugging is on for %pFX\n", &argv_p
);
1436 DEFPY (no_debug_bgp_update_prefix_afi_safi
,
1437 no_debug_bgp_update_prefix_afi_safi_cmd
,
1438 "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>>",
1443 "Specify a prefix to debug\n"
1447 EVPN_TYPE_2_HELP_STR
1448 EVPN_TYPE_2_HELP_STR
1449 MAC_STR MAC_STR MAC_STR
1453 EVPN_TYPE_3_HELP_STR
1454 EVPN_TYPE_3_HELP_STR
1458 EVPN_TYPE_5_HELP_STR
1459 EVPN_TYPE_5_HELP_STR
1464 struct prefix argv_p
;
1465 bool found_prefix
= false;
1466 int ret
= CMD_SUCCESS
;
1468 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1469 if (ret
!= CMD_SUCCESS
)
1472 if (bgp_debug_update_prefixes
1473 && !list_isempty(bgp_debug_update_prefixes
)) {
1474 found_prefix
= bgp_debug_list_remove_entry(
1475 bgp_debug_update_prefixes
, NULL
, &argv_p
);
1477 if (list_isempty(bgp_debug_update_prefixes
)) {
1478 if (vty
->node
== CONFIG_NODE
) {
1479 DEBUG_OFF(update
, UPDATE_PREFIX
);
1481 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1483 "BGP updates debugging (per prefix) is off\n");
1489 vty_out(vty
, "BGP updates debugging is off for %pFX\n",
1492 vty_out(vty
, "BGP updates debugging was not enabled for %pFX\n",
1499 DEFPY (debug_bgp_update_prefix
,
1500 debug_bgp_update_prefix_cmd
,
1501 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>$prefix",
1505 "Specify a prefix to debug\n"
1509 if (!bgp_debug_update_prefixes
)
1510 bgp_debug_update_prefixes
= list_new();
1512 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, prefix
)) {
1514 "BGP updates debugging is already enabled for %s\n",
1519 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, prefix
);
1521 if (vty
->node
== CONFIG_NODE
) {
1522 DEBUG_ON(update
, UPDATE_PREFIX
);
1524 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1525 vty_out(vty
, "BGP updates debugging is on for %s\n",
1532 DEFPY (no_debug_bgp_update_prefix
,
1533 no_debug_bgp_update_prefix_cmd
,
1534 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>$prefix",
1539 "Specify a prefix to debug\n"
1543 bool found_prefix
= false;
1545 if (bgp_debug_update_prefixes
1546 && !list_isempty(bgp_debug_update_prefixes
)) {
1547 found_prefix
= bgp_debug_list_remove_entry(
1548 bgp_debug_update_prefixes
, NULL
, prefix
);
1550 if (list_isempty(bgp_debug_update_prefixes
)) {
1551 if (vty
->node
== CONFIG_NODE
) {
1552 DEBUG_OFF(update
, UPDATE_PREFIX
);
1554 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1556 "BGP updates debugging (per prefix) is off\n");
1562 vty_out(vty
, "BGP updates debugging is off for %s\n",
1565 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1571 DEFUN (no_debug_bgp_update
,
1572 no_debug_bgp_update_cmd
,
1573 "no debug bgp updates",
1579 struct listnode
*ln
;
1582 bgp_debug_list_free(bgp_debug_update_in_peers
);
1583 bgp_debug_list_free(bgp_debug_update_out_peers
);
1584 bgp_debug_list_free(bgp_debug_update_prefixes
);
1586 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1587 bgp_debug_clear_updgrp_update_dbg(bgp
);
1589 if (vty
->node
== CONFIG_NODE
) {
1590 DEBUG_OFF(update
, UPDATE_IN
);
1591 DEBUG_OFF(update
, UPDATE_OUT
);
1592 DEBUG_OFF(update
, UPDATE_PREFIX
);
1594 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1595 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1596 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1597 vty_out(vty
, "BGP updates debugging is off\n");
1602 /* debug bgp zebra */
1603 DEFUN (debug_bgp_zebra
,
1604 debug_bgp_zebra_cmd
,
1608 "BGP Zebra messages\n")
1610 if (vty
->node
== CONFIG_NODE
)
1611 DEBUG_ON(zebra
, ZEBRA
);
1613 TERM_DEBUG_ON(zebra
, ZEBRA
);
1614 vty_out(vty
, "BGP zebra debugging is on\n");
1619 DEFUN (debug_bgp_graceful_restart
,
1620 debug_bgp_graceful_restart_cmd
,
1621 "debug bgp graceful-restart",
1626 if (vty
->node
== CONFIG_NODE
) {
1627 DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1629 TERM_DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1630 vty_out(vty
, "BGP Graceful Restart debugging is on\n");
1636 DEFPY (debug_bgp_zebra_prefix
,
1637 debug_bgp_zebra_prefix_cmd
,
1638 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>$prefix",
1641 "BGP Zebra messages\n"
1642 "Specify a prefix to debug\n"
1646 if (!bgp_debug_zebra_prefixes
)
1647 bgp_debug_zebra_prefixes
= list_new();
1649 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, prefix
)) {
1650 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1655 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, prefix
);
1657 if (vty
->node
== CONFIG_NODE
)
1658 DEBUG_ON(zebra
, ZEBRA
);
1660 TERM_DEBUG_ON(zebra
, ZEBRA
);
1661 vty_out(vty
, "BGP zebra debugging is on for %s\n", prefix_str
);
1667 DEFUN (no_debug_bgp_zebra
,
1668 no_debug_bgp_zebra_cmd
,
1669 "no debug bgp zebra",
1673 "BGP Zebra messages\n")
1675 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1677 if (vty
->node
== CONFIG_NODE
)
1678 DEBUG_OFF(zebra
, ZEBRA
);
1680 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1681 vty_out(vty
, "BGP zebra debugging is off\n");
1686 DEFUN (no_debug_bgp_graceful_restart
,
1687 no_debug_bgp_graceful_restart_cmd
,
1688 "no debug bgp graceful-restart",
1694 if (vty
->node
== CONFIG_NODE
) {
1695 DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1697 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1698 vty_out(vty
, "BGP Graceful Restart debugging is off\n");
1703 DEFPY (no_debug_bgp_zebra_prefix
,
1704 no_debug_bgp_zebra_prefix_cmd
,
1705 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>$prefix",
1709 "BGP Zebra messages\n"
1710 "Specify a prefix to debug\n"
1714 bool found_prefix
= false;
1716 if (bgp_debug_zebra_prefixes
1717 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1718 found_prefix
= bgp_debug_list_remove_entry(
1719 bgp_debug_zebra_prefixes
, NULL
, prefix
);
1721 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1722 if (vty
->node
== CONFIG_NODE
)
1723 DEBUG_OFF(zebra
, ZEBRA
);
1725 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1726 vty_out(vty
, "BGP zebra debugging is off\n");
1732 vty_out(vty
, "BGP zebra debugging is off for %s\n", prefix_str
);
1734 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1740 /* debug bgp update-groups */
1741 DEFUN (debug_bgp_update_groups
,
1742 debug_bgp_update_groups_cmd
,
1743 "debug bgp update-groups",
1746 "BGP update-groups\n")
1748 if (vty
->node
== CONFIG_NODE
)
1749 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1751 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1752 vty_out(vty
, "BGP update-groups debugging is on\n");
1757 DEFUN (no_debug_bgp_update_groups
,
1758 no_debug_bgp_update_groups_cmd
,
1759 "no debug bgp update-groups",
1763 "BGP update-groups\n")
1765 if (vty
->node
== CONFIG_NODE
)
1766 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1768 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1769 vty_out(vty
, "BGP update-groups debugging is off\n");
1774 DEFUN (debug_bgp_vpn
,
1776 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1780 "leaked from vrf to vpn\n"
1781 "leaked to vrf from vpn\n"
1782 "route-map updates\n"
1787 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1788 if (vty
->node
== CONFIG_NODE
)
1789 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1791 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1792 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1793 if (vty
->node
== CONFIG_NODE
)
1794 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1796 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1797 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1798 if (vty
->node
== CONFIG_NODE
)
1799 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1801 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1802 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1803 if (vty
->node
== CONFIG_NODE
)
1804 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1806 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1808 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1809 return CMD_WARNING_CONFIG_FAILED
;
1812 if (vty
->node
!= CONFIG_NODE
)
1813 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1818 DEFUN (no_debug_bgp_vpn
,
1819 no_debug_bgp_vpn_cmd
,
1820 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1825 "leaked from vrf to vpn\n"
1826 "leaked to vrf from vpn\n"
1827 "route-map updates\n"
1832 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1833 if (vty
->node
== CONFIG_NODE
)
1834 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1836 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1838 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1839 if (vty
->node
== CONFIG_NODE
)
1840 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1842 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1843 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1844 if (vty
->node
== CONFIG_NODE
)
1845 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1847 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1848 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1849 if (vty
->node
== CONFIG_NODE
)
1850 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1852 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1854 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1855 return CMD_WARNING_CONFIG_FAILED
;
1858 if (vty
->node
!= CONFIG_NODE
)
1859 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1864 DEFUN (debug_bgp_pbr
,
1866 "debug bgp pbr [error]",
1869 "BGP policy based routing\n"
1874 if (argv_find(argv
, argc
, "error", &idx
)) {
1875 if (vty
->node
== CONFIG_NODE
)
1876 DEBUG_ON(pbr
, PBR_ERROR
);
1878 TERM_DEBUG_ON(pbr
, PBR_ERROR
);
1879 vty_out(vty
, "BGP policy based routing error is on\n");
1883 if (vty
->node
== CONFIG_NODE
)
1886 TERM_DEBUG_ON(pbr
, PBR
);
1887 vty_out(vty
, "BGP policy based routing is on\n");
1892 DEFUN (no_debug_bgp_pbr
,
1893 no_debug_bgp_pbr_cmd
,
1894 "no debug bgp pbr [error]",
1898 "BGP policy based routing\n"
1903 if (argv_find(argv
, argc
, "error", &idx
)) {
1904 if (vty
->node
== CONFIG_NODE
)
1905 DEBUG_OFF(pbr
, PBR_ERROR
);
1907 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1908 vty_out(vty
, "BGP policy based routing error is off\n");
1912 if (vty
->node
== CONFIG_NODE
)
1913 DEBUG_OFF(pbr
, PBR
);
1915 TERM_DEBUG_OFF(pbr
, PBR
);
1916 vty_out(vty
, "BGP policy based routing is off\n");
1921 DEFPY (debug_bgp_evpn_mh
,
1922 debug_bgp_evpn_mh_cmd
,
1923 "[no$no] debug bgp evpn mh <es$es|route$rt>",
1929 "Ethernet Segment debugging\n"
1930 "Route debugging\n")
1933 if (vty
->node
== CONFIG_NODE
) {
1935 DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
1937 DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
1940 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
1942 "BGP EVPN-MH ES debugging is off\n");
1944 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
1946 "BGP EVPN-MH ES debugging is on\n");
1951 if (vty
->node
== CONFIG_NODE
) {
1953 DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
1955 DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
1958 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
1960 "BGP EVPN-MH route debugging is off\n");
1962 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
1964 "BGP EVPN-MH route debugging is on\n");
1972 DEFUN (debug_bgp_labelpool
,
1973 debug_bgp_labelpool_cmd
,
1974 "debug bgp labelpool",
1979 if (vty
->node
== CONFIG_NODE
)
1980 DEBUG_ON(labelpool
, LABELPOOL
);
1982 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
1984 if (vty
->node
!= CONFIG_NODE
)
1985 vty_out(vty
, "enabled debug bgp labelpool\n");
1990 DEFUN (no_debug_bgp_labelpool
,
1991 no_debug_bgp_labelpool_cmd
,
1992 "no debug bgp labelpool",
1998 if (vty
->node
== CONFIG_NODE
)
1999 DEBUG_OFF(labelpool
, LABELPOOL
);
2001 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2004 if (vty
->node
!= CONFIG_NODE
)
2005 vty_out(vty
, "disabled debug bgp labelpool\n");
2010 DEFPY(debug_bgp_bfd
, debug_bgp_bfd_cmd
,
2011 "[no] debug bgp bfd",
2015 "Bidirection Forwarding Detection\n")
2017 if (vty
->node
== CONFIG_NODE
) {
2019 DEBUG_OFF(bfd
, BFD_LIB
);
2020 bfd_protocol_integration_set_debug(false);
2022 DEBUG_ON(bfd
, BFD_LIB
);
2023 bfd_protocol_integration_set_debug(true);
2027 TERM_DEBUG_OFF(bfd
, BFD_LIB
);
2028 bfd_protocol_integration_set_debug(false);
2030 TERM_DEBUG_ON(bfd
, BFD_LIB
);
2031 bfd_protocol_integration_set_debug(true);
2038 DEFPY (debug_bgp_cond_adv
,
2039 debug_bgp_cond_adv_cmd
,
2040 "[no$no] debug bgp conditional-advertisement",
2044 "BGP conditional advertisement\n")
2046 if (vty
->node
== CONFIG_NODE
) {
2048 DEBUG_OFF(cond_adv
, COND_ADV
);
2050 DEBUG_ON(cond_adv
, COND_ADV
);
2053 TERM_DEBUG_OFF(cond_adv
, COND_ADV
);
2055 "BGP conditional advertisement debugging is off\n");
2057 TERM_DEBUG_ON(cond_adv
, COND_ADV
);
2059 "BGP conditional advertisement debugging is on\n");
2065 DEFUN (no_debug_bgp
,
2073 struct listnode
*ln
;
2075 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
2076 bgp_debug_list_free(bgp_debug_keepalive_peers
);
2077 bgp_debug_list_free(bgp_debug_update_in_peers
);
2078 bgp_debug_list_free(bgp_debug_update_out_peers
);
2079 bgp_debug_list_free(bgp_debug_update_prefixes
);
2080 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
2081 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
2083 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
2084 bgp_debug_clear_updgrp_update_dbg(bgp
);
2086 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
2087 TERM_DEBUG_OFF(update
, UPDATE_IN
);
2088 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
2089 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
2090 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
2091 TERM_DEBUG_OFF(as4
, AS4
);
2092 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
2093 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
2094 TERM_DEBUG_OFF(zebra
, ZEBRA
);
2095 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
2096 TERM_DEBUG_OFF(nht
, NHT
);
2097 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
2098 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
2099 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
2100 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
2101 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
2102 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2103 TERM_DEBUG_OFF(pbr
, PBR
);
2104 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
2105 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
2106 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2107 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2108 TERM_DEBUG_OFF(bfd
, BFD_LIB
);
2109 TERM_DEBUG_OFF(cond_adv
, COND_ADV
);
2111 vty_out(vty
, "All possible debugging has been turned off\n");
2116 DEFUN_NOSH (show_debugging_bgp
,
2117 show_debugging_bgp_cmd
,
2118 "show debugging [bgp]",
2123 vty_out(vty
, "BGP debugging status:\n");
2125 if (BGP_DEBUG(as4
, AS4
))
2126 vty_out(vty
, " BGP as4 debugging is on\n");
2128 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
2129 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
2131 if (BGP_DEBUG(bestpath
, BESTPATH
))
2132 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
2133 bgp_debug_bestpath_prefixes
);
2135 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
2136 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
2137 bgp_debug_keepalive_peers
);
2139 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
2140 bgp_debug_list_print(vty
,
2141 " BGP neighbor-events debugging is on",
2142 bgp_debug_neighbor_events_peers
);
2144 if (BGP_DEBUG(nht
, NHT
))
2145 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
2147 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
2148 vty_out(vty
, " BGP update-groups debugging is on\n");
2150 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
2151 bgp_debug_list_print(vty
, " BGP updates debugging is on",
2152 bgp_debug_update_prefixes
);
2154 if (BGP_DEBUG(update
, UPDATE_IN
))
2155 bgp_debug_list_print(vty
,
2156 " BGP updates debugging is on (inbound)",
2157 bgp_debug_update_in_peers
);
2159 if (BGP_DEBUG(update
, UPDATE_OUT
))
2160 bgp_debug_list_print(vty
,
2161 " BGP updates debugging is on (outbound)",
2162 bgp_debug_update_out_peers
);
2164 if (BGP_DEBUG(zebra
, ZEBRA
))
2165 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
2166 bgp_debug_zebra_prefixes
);
2168 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2169 vty_out(vty
, " BGP graceful-restart debugging is on\n");
2171 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
2172 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
2174 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
2176 " BGP route leak from vrf to vpn debugging is on\n");
2177 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
2179 " BGP route leak to vrf from vpn debugging is on\n");
2180 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
2181 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
2182 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
2183 vty_out(vty
, " BGP vpn label event debugging is on\n");
2184 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
2185 vty_out(vty
, " BGP flowspec debugging is on\n");
2186 if (BGP_DEBUG(labelpool
, LABELPOOL
))
2187 vty_out(vty
, " BGP labelpool debugging is on\n");
2189 if (BGP_DEBUG(pbr
, PBR
))
2190 vty_out(vty
, " BGP policy based routing debugging is on\n");
2191 if (BGP_DEBUG(pbr
, PBR_ERROR
))
2192 vty_out(vty
, " BGP policy based routing error debugging is on\n");
2194 if (BGP_DEBUG(evpn_mh
, EVPN_MH_ES
))
2195 vty_out(vty
, " BGP EVPN-MH ES debugging is on\n");
2196 if (BGP_DEBUG(evpn_mh
, EVPN_MH_RT
))
2197 vty_out(vty
, " BGP EVPN-MH route debugging is on\n");
2199 if (BGP_DEBUG(bfd
, BFD_LIB
))
2200 vty_out(vty
, " BGP BFD library debugging is on\n");
2202 if (BGP_DEBUG(cond_adv
, COND_ADV
))
2204 " BGP conditional advertisement debugging is on\n");
2206 cmd_show_lib_debugs(vty
);
2211 static int bgp_config_write_debug(struct vty
*vty
)
2215 if (CONF_BGP_DEBUG(as4
, AS4
)) {
2216 vty_out(vty
, "debug bgp as4\n");
2220 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
2221 vty_out(vty
, "debug bgp as4 segment\n");
2225 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
2226 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
2227 bgp_debug_bestpath_prefixes
);
2230 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
2231 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
2232 bgp_debug_keepalive_peers
);
2235 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
2236 write
+= bgp_debug_list_conf_print(
2237 vty
, "debug bgp neighbor-events",
2238 bgp_debug_neighbor_events_peers
);
2241 if (CONF_BGP_DEBUG(nht
, NHT
)) {
2242 vty_out(vty
, "debug bgp nht\n");
2246 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
2247 vty_out(vty
, "debug bgp update-groups\n");
2251 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2252 write
+= bgp_debug_list_conf_print(vty
,
2253 "debug bgp updates prefix",
2254 bgp_debug_update_prefixes
);
2257 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
2258 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
2259 bgp_debug_update_in_peers
);
2262 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
2263 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
2264 bgp_debug_update_out_peers
);
2267 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
2268 if (!bgp_debug_zebra_prefixes
2269 || list_isempty(bgp_debug_zebra_prefixes
)) {
2270 vty_out(vty
, "debug bgp zebra\n");
2273 write
+= bgp_debug_list_conf_print(
2274 vty
, "debug bgp zebra prefix",
2275 bgp_debug_zebra_prefixes
);
2279 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
2280 vty_out(vty
, "debug bgp allow-martians\n");
2284 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
2285 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
2288 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
2289 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
2292 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
2293 vty_out(vty
, "debug bgp vpn rmap-event\n");
2296 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
2297 vty_out(vty
, "debug bgp vpn label\n");
2300 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
2301 vty_out(vty
, "debug bgp flowspec\n");
2304 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
2305 vty_out(vty
, "debug bgp labelpool\n");
2309 if (CONF_BGP_DEBUG(pbr
, PBR
)) {
2310 vty_out(vty
, "debug bgp pbr\n");
2313 if (CONF_BGP_DEBUG(pbr
, PBR_ERROR
)) {
2314 vty_out(vty
, "debug bgp pbr error\n");
2318 if (CONF_BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
)) {
2319 vty_out(vty
, "debug bgp graceful-restart\n");
2323 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_ES
)) {
2324 vty_out(vty
, "debug bgp evpn mh es\n");
2327 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_RT
)) {
2328 vty_out(vty
, "debug bgp evpn mh route\n");
2332 if (CONF_BGP_DEBUG(bfd
, BFD_LIB
)) {
2333 vty_out(vty
, "debug bgp bfd\n");
2337 if (CONF_BGP_DEBUG(cond_adv
, COND_ADV
)) {
2338 vty_out(vty
, "debug bgp conditional-advertisement\n");
2345 static int bgp_config_write_debug(struct vty
*vty
);
2346 static struct cmd_node debug_node
= {
2350 .config_write
= bgp_config_write_debug
,
2353 void bgp_debug_init(void)
2355 install_node(&debug_node
);
2357 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
2359 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
2360 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
2361 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
2362 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
2364 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
2365 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
2366 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
2367 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
2368 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
2369 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
2370 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
2371 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
2372 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
2373 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
2374 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
2375 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
2376 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2377 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2379 install_element(ENABLE_NODE
, &debug_bgp_graceful_restart_cmd
);
2380 install_element(CONFIG_NODE
, &debug_bgp_graceful_restart_cmd
);
2382 /* debug bgp updates (in|out) */
2383 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2384 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2385 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2386 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2388 /* debug bgp updates (in|out) A.B.C.D */
2389 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2390 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2391 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2392 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2394 /* debug bgp updates prefix A.B.C.D/M */
2395 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2396 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2397 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2398 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2399 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2400 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2401 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2402 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2404 /* debug bgp zebra prefix A.B.C.D/M */
2405 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2406 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2407 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2408 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2410 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2411 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2412 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2413 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2415 /* debug bgp neighbor-events A.B.C.D */
2416 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2417 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2418 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2419 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2421 /* debug bgp keepalive A.B.C.D */
2422 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2423 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2424 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2425 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2427 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2428 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2429 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2430 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2431 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2432 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2433 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2434 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2435 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2436 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2437 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2438 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2439 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2440 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2441 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2442 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2443 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2445 install_element(ENABLE_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2446 install_element(CONFIG_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2448 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2449 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2450 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2451 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2453 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2454 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2455 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2456 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2459 install_element(ENABLE_NODE
, &debug_bgp_pbr_cmd
);
2460 install_element(CONFIG_NODE
, &debug_bgp_pbr_cmd
);
2461 install_element(ENABLE_NODE
, &no_debug_bgp_pbr_cmd
);
2462 install_element(CONFIG_NODE
, &no_debug_bgp_pbr_cmd
);
2464 install_element(ENABLE_NODE
, &debug_bgp_evpn_mh_cmd
);
2465 install_element(CONFIG_NODE
, &debug_bgp_evpn_mh_cmd
);
2468 install_element(ENABLE_NODE
, &debug_bgp_bfd_cmd
);
2469 install_element(CONFIG_NODE
, &debug_bgp_bfd_cmd
);
2471 /* debug bgp conditional advertisement */
2472 install_element(ENABLE_NODE
, &debug_bgp_cond_adv_cmd
);
2473 install_element(CONFIG_NODE
, &debug_bgp_cond_adv_cmd
);
2476 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2477 * for BGP_DEBUG_TYPE
2479 static int bgp_debug_per_prefix(const struct prefix
*p
,
2480 unsigned long term_bgp_debug_type
,
2481 unsigned int BGP_DEBUG_TYPE
,
2482 struct list
*per_prefix_list
)
2484 struct bgp_debug_filter
*filter
;
2485 struct listnode
*node
, *nnode
;
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
))
2496 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2498 if (filter
->p
->prefixlen
== p
->prefixlen
2499 && prefix_match(filter
->p
, p
))
2509 /* Return true if this peer is on the per_peer_list of peers to debug
2510 * for BGP_DEBUG_TYPE
2512 static bool bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2513 unsigned int BGP_DEBUG_TYPE
,
2514 struct list
*per_peer_list
)
2516 struct bgp_debug_filter
*filter
;
2517 struct listnode
*node
, *nnode
;
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
))
2528 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2530 if (strcmp(filter
->host
, host
) == 0)
2540 bool bgp_debug_neighbor_events(const struct peer
*peer
)
2547 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2548 BGP_DEBUG_NEIGHBOR_EVENTS
,
2549 bgp_debug_neighbor_events_peers
);
2552 bool bgp_debug_keepalive(const struct peer
*peer
)
2559 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2560 BGP_DEBUG_KEEPALIVE
,
2561 bgp_debug_keepalive_peers
);
2564 bool bgp_debug_update(const struct peer
*peer
, const struct prefix
*p
,
2565 struct update_group
*updgrp
, unsigned int inbound
)
2573 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2574 BGP_DEBUG_UPDATE_IN
,
2575 bgp_debug_update_in_peers
))
2581 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2582 BGP_DEBUG_UPDATE_OUT
,
2583 bgp_debug_update_out_peers
))
2586 /* Check if update debugging implicitly enabled for the group.
2588 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
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
))
2603 bool bgp_debug_bestpath(struct bgp_dest
*dest
)
2605 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2606 if (bgp_debug_per_prefix(
2607 bgp_dest_get_prefix(dest
), term_bgp_debug_bestpath
,
2608 BGP_DEBUG_BESTPATH
, bgp_debug_bestpath_prefixes
))
2615 bool bgp_debug_zebra(const struct prefix
*p
)
2617 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2618 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2620 bgp_debug_zebra_prefixes
))
2627 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2628 const struct prefix_rd
*prd
,
2629 union prefixconstptr pu
,
2630 mpls_label_t
*label
, uint32_t num_labels
,
2631 int addpath_valid
, uint32_t addpath_id
,
2632 struct bgp_route_evpn
*overlay_index
,
2633 char *str
, int size
)
2636 char overlay_index_buf
[INET6_ADDRSTRLEN
+ 14];
2637 const struct prefix_evpn
*evp
;
2640 /* ' with addpath ID ' 17
2641 * max strlen of uint32 + 10
2642 * +/- (just in case) + 1
2643 * null terminator + 1
2644 * ============================ 29 */
2645 char pathid_buf
[30];
2647 if (size
< BGP_PRD_PATH_STRLEN
)
2650 /* Note: Path-id is created by default, but only included in update
2652 pathid_buf
[0] = '\0';
2654 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2657 overlay_index_buf
[0] = '\0';
2658 if (overlay_index
&& overlay_index
->type
== OVERLAY_INDEX_GATEWAY_IP
) {
2659 char obuf
[INET6_ADDRSTRLEN
];
2663 if (is_evpn_prefix_ipaddr_v4(evp
))
2664 inet_ntop(AF_INET
, &overlay_index
->gw_ip
, obuf
,
2666 else if (is_evpn_prefix_ipaddr_v6(evp
))
2667 inet_ntop(AF_INET6
, &overlay_index
->gw_ip
, obuf
,
2670 snprintf(overlay_index_buf
, sizeof(overlay_index_buf
),
2671 " gateway IP %s", obuf
);
2675 if (bgp_labeled_safi(safi
) && num_labels
) {
2677 if (safi
== SAFI_EVPN
) {
2680 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2681 snprintf(tag_buf
, sizeof(tag_buf
), " label %s",
2684 uint32_t label_value
;
2686 label_value
= decode_label(label
);
2687 snprintf(tag_buf
, sizeof(tag_buf
), " label %u",
2693 len
+= snprintfrr(str
+ len
, size
- len
, "RD ");
2694 len
+= snprintfrr(str
+ len
, size
- len
,
2695 BGP_RD_AS_FORMAT(bgp_get_asnotation(NULL
)),
2697 snprintfrr(str
+ len
, size
- len
, " %pFX%s%s%s %s %s", pu
.p
,
2698 overlay_index_buf
, tag_buf
, pathid_buf
, afi2str(afi
),
2700 } else if (safi
== SAFI_FLOWSPEC
) {
2701 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2702 const struct prefix_fs
*fs
= pu
.fs
;
2704 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2705 fs
->prefix
.prefixlen
,
2707 NLRI_STRING_FORMAT_DEBUG
, NULL
,
2708 family2afi(fs
->prefix
.family
));
2709 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2712 snprintfrr(str
, size
, "%pFX%s%s %s %s", pu
.p
, tag_buf
,
2713 pathid_buf
, afi2str(afi
), safi2str(safi
));