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>
24 #include "lib/printfrr.h"
30 #include "sockunion.h"
35 #include "bgpd/bgpd.h"
36 #include "bgpd/bgp_aspath.h"
37 #include "bgpd/bgp_route.h"
38 #include "bgpd/bgp_attr.h"
39 #include "bgpd/bgp_debug.h"
40 #include "bgpd/bgp_community.h"
41 #include "bgpd/bgp_updgrp.h"
42 #include "bgpd/bgp_mplsvpn.h"
43 #include "bgpd/bgp_ecommunity.h"
44 #include "bgpd/bgp_label.h"
45 #include "bgpd/bgp_evpn.h"
46 #include "bgpd/bgp_evpn_private.h"
47 #include "bgpd/bgp_evpn_vty.h"
48 #include "bgpd/bgp_vty.h"
49 #include "bgpd/bgp_flowspec.h"
51 unsigned long conf_bgp_debug_as4
;
52 unsigned long conf_bgp_debug_neighbor_events
;
53 unsigned long conf_bgp_debug_events
;
54 unsigned long conf_bgp_debug_packet
;
55 unsigned long conf_bgp_debug_filter
;
56 unsigned long conf_bgp_debug_keepalive
;
57 unsigned long conf_bgp_debug_update
;
58 unsigned long conf_bgp_debug_bestpath
;
59 unsigned long conf_bgp_debug_zebra
;
60 unsigned long conf_bgp_debug_allow_martians
;
61 unsigned long conf_bgp_debug_nht
;
62 unsigned long conf_bgp_debug_update_groups
;
63 unsigned long conf_bgp_debug_vpn
;
64 unsigned long conf_bgp_debug_flowspec
;
65 unsigned long conf_bgp_debug_labelpool
;
66 unsigned long conf_bgp_debug_pbr
;
67 unsigned long conf_bgp_debug_graceful_restart
;
68 unsigned long conf_bgp_debug_evpn_mh
;
70 unsigned long term_bgp_debug_as4
;
71 unsigned long term_bgp_debug_neighbor_events
;
72 unsigned long term_bgp_debug_events
;
73 unsigned long term_bgp_debug_packet
;
74 unsigned long term_bgp_debug_filter
;
75 unsigned long term_bgp_debug_keepalive
;
76 unsigned long term_bgp_debug_update
;
77 unsigned long term_bgp_debug_bestpath
;
78 unsigned long term_bgp_debug_zebra
;
79 unsigned long term_bgp_debug_allow_martians
;
80 unsigned long term_bgp_debug_nht
;
81 unsigned long term_bgp_debug_update_groups
;
82 unsigned long term_bgp_debug_vpn
;
83 unsigned long term_bgp_debug_flowspec
;
84 unsigned long term_bgp_debug_labelpool
;
85 unsigned long term_bgp_debug_pbr
;
86 unsigned long term_bgp_debug_graceful_restart
;
87 unsigned long term_bgp_debug_evpn_mh
;
89 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
90 struct list
*bgp_debug_keepalive_peers
= NULL
;
91 struct list
*bgp_debug_update_out_peers
= NULL
;
92 struct list
*bgp_debug_update_in_peers
= NULL
;
93 struct list
*bgp_debug_update_prefixes
= NULL
;
94 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
95 struct list
*bgp_debug_zebra_prefixes
= NULL
;
97 /* messages for BGP-4 status */
98 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
101 {OpenSent
, "OpenSent"},
102 {OpenConfirm
, "OpenConfirm"},
103 {Established
, "Established"},
104 {Clearing
, "Clearing"},
105 {Deleted
, "Deleted"},
108 /* BGP message type string. */
109 const char *const bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
110 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
113 /* message for BGP-4 Notify */
114 static const struct message bgp_notify_msg
[] = {
115 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
116 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
117 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
118 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
119 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
120 {BGP_NOTIFY_CEASE
, "Cease"},
121 {BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
124 static const struct message bgp_notify_head_msg
[] = {
125 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
126 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
127 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
130 static const struct message bgp_notify_open_msg
[] = {
131 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
132 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
133 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
134 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
135 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
136 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
137 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
138 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
141 static const struct message bgp_notify_update_msg
[] = {
142 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
143 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
144 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
145 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
146 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
147 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
148 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
149 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
150 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
151 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
152 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
153 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
156 static const struct message bgp_notify_cease_msg
[] = {
157 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
158 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
159 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
160 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
161 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
162 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
163 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
164 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
165 "/Connection collision resolution"},
166 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
169 static const struct message bgp_notify_capability_msg
[] = {
170 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
171 {BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value"},
172 {BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
173 {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
176 static const struct message bgp_notify_fsm_msg
[] = {
177 {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC
, "/Unspecific"},
178 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT
,
179 "/Receive Unexpected Message in OpenSent State"},
180 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM
,
181 "/Receive Unexpected Message in OpenConfirm State"},
182 {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED
,
183 "/Receive Unexpected Message in Established State"},
186 /* Origin strings. */
187 const char *const bgp_origin_str
[] = {"i", "e", "?"};
188 const char *const bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
190 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
192 /* Given a string return a pointer the corresponding peer structure */
193 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
195 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
203 ret
= str2sockunion(peer_str
, &su
);
207 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
210 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
214 return peer_lookup(bgp
, &su
);
217 static void bgp_debug_list_free(struct list
*list
)
219 struct bgp_debug_filter
*filter
;
220 struct listnode
*node
, *nnode
;
223 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
224 listnode_delete(list
, filter
);
225 prefix_free(&filter
->p
);
226 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
227 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
232 * Print the desc along with a list of peers/prefixes this debug is
235 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
238 struct bgp_debug_filter
*filter
;
239 struct listnode
*node
, *nnode
;
241 vty_out(vty
, "%s", desc
);
243 if (list
&& !list_isempty(list
)) {
244 vty_out(vty
, " for");
245 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
247 vty_out(vty
, " %s", filter
->host
);
249 if (filter
->p
&& filter
->p
->family
== AF_EVPN
)
250 bgp_debug_print_evpn_prefix(vty
, "", filter
->p
);
252 vty_out(vty
, " %pFX", filter
->p
);
260 * Print the command to enable the debug for each peer/prefix this debug is
263 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
266 struct bgp_debug_filter
*filter
;
267 struct listnode
*node
, *nnode
;
270 if (list
&& !list_isempty(list
)) {
271 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
273 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
277 if (filter
->p
&& filter
->p
->family
== AF_EVPN
) {
278 bgp_debug_print_evpn_prefix(vty
, desc
,
281 } else if (filter
->p
) {
282 vty_out(vty
, "%s %pFX\n", desc
, filter
->p
);
289 vty_out(vty
, "%s\n", desc
);
296 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
297 const struct prefix
*p
)
299 struct bgp_debug_filter
*filter
;
301 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
302 sizeof(struct bgp_debug_filter
));
305 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
309 filter
->p
= prefix_new();
310 prefix_copy(filter
->p
, p
);
313 listnode_add(list
, filter
);
316 static bool bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
319 struct bgp_debug_filter
*filter
;
320 struct listnode
*node
, *nnode
;
322 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
323 if (host
&& strcmp(filter
->host
, host
) == 0) {
324 listnode_delete(list
, filter
);
325 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
326 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
328 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
329 && prefix_match(filter
->p
, p
)) {
330 listnode_delete(list
, filter
);
331 prefix_free(&filter
->p
);
332 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
340 static bool bgp_debug_list_has_entry(struct list
*list
, const char *host
,
341 const struct prefix
*p
)
343 struct bgp_debug_filter
*filter
;
344 struct listnode
*node
, *nnode
;
346 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
348 if (strcmp(filter
->host
, host
) == 0) {
352 if (filter
->p
->prefixlen
== p
->prefixlen
353 && prefix_match(filter
->p
, p
)) {
362 bool bgp_debug_peer_updout_enabled(char *host
)
364 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
368 /* Dump attribute. */
369 bool bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
371 char addrbuf
[BUFSIZ
];
378 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
379 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
381 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
382 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
383 bgp_origin_str
[attr
->origin
]);
386 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
387 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
388 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
390 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
393 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
394 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
395 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
398 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
399 snprintfrr(buf
, size
, "nexthop %pI4", &attr
->nexthop
);
401 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
402 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
403 ", localpref %u", attr
->local_pref
);
405 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
406 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
409 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
410 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
412 community_str(attr
->community
, false));
414 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
415 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
416 ", extcommunity %s", ecommunity_str(attr
->ecommunity
));
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_CAPABILITY_ERR
:
491 return lookup_msg(bgp_notify_capability_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
> 128 || 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
,
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 neighbor %s %d/%d (%s%s) \"%s\"",
538 strcmp(direct
, "received") == 0
541 peer
->host
, bgp_notify
->code
,
542 bgp_notify
->subcode
, code_str
, subcode_str
,
545 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
547 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
548 strcmp(direct
, "received") == 0
551 peer
->host
, bgp_notify
->code
,
552 bgp_notify
->subcode
, code_str
, subcode_str
,
553 bgp_notify
->length
, msg_str
);
558 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
561 bgp
= bgp_get_default();
562 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
565 static void bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
568 char evpn_desc
[PREFIX2STR_BUFFER
+ INET_ADDRSTRLEN
];
569 char buf
[PREFIX2STR_BUFFER
];
570 char buf2
[ETHER_ADDR_STRLEN
];
572 if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_MAC_IP_ROUTE
) {
573 if (is_evpn_prefix_ipaddr_none((struct prefix_evpn
*)p
)) {
575 evpn_desc
, sizeof(evpn_desc
),
576 "l2vpn evpn type macip mac %s",
577 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
578 buf2
, sizeof(buf2
)));
580 uint8_t family
= is_evpn_prefix_ipaddr_v4(
581 (struct prefix_evpn
*)p
) ?
584 evpn_desc
, sizeof(evpn_desc
),
585 "l2vpn evpn type macip mac %s ip %s",
586 prefix_mac2str(&p
->u
.prefix_evpn
.macip_addr
.mac
,
590 &p
->u
.prefix_evpn
.macip_addr
.ip
.ip
.addr
,
591 buf
, PREFIX2STR_BUFFER
));
593 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IMET_ROUTE
) {
594 snprintfrr(evpn_desc
, sizeof(evpn_desc
),
595 "l2vpn evpn type multicast ip %pI4",
596 &p
->u
.prefix_evpn
.imet_addr
.ip
.ipaddr_v4
);
597 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
598 uint8_t family
= is_evpn_prefix_ipaddr_v4(
599 (struct prefix_evpn
*)p
) ? AF_INET
601 snprintf(evpn_desc
, sizeof(evpn_desc
),
602 "l2vpn evpn type prefix ip %s/%d",
604 &p
->u
.prefix_evpn
.prefix_addr
.ip
.ip
.addr
,
605 buf
, PREFIX2STR_BUFFER
),
606 p
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
);
609 vty_out(vty
, "%s %s\n", desc
, evpn_desc
);
612 static int bgp_debug_parse_evpn_prefix(struct vty
*vty
, struct cmd_token
**argv
,
613 int argc
, struct prefix
**argv_pp
)
615 struct prefix
*argv_p
;
624 if (bgp_evpn_cli_parse_type(&evpn_type
, argv
, argc
) < 0)
627 if (evpn_type
== BGP_EVPN_MAC_IP_ROUTE
) {
628 memset(&ip
, 0, sizeof(struct ipaddr
));
630 argv_find(argv
, argc
, "mac", &mac_idx
);
631 (void)prefix_str2mac(argv
[mac_idx
+ 1]->arg
, &mac
);
633 argv_find(argv
, argc
, "ip", &ip_idx
);
634 str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
);
636 build_evpn_type2_prefix((struct prefix_evpn
*)argv_p
,
638 } else if (evpn_type
== BGP_EVPN_IMET_ROUTE
) {
639 memset(&ip
, 0, sizeof(struct ipaddr
));
641 argv_find(argv
, argc
, "ip", &ip_idx
);
642 str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
);
644 build_evpn_type3_prefix((struct prefix_evpn
*)argv_p
,
646 } else if (evpn_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
647 struct prefix ip_prefix
;
649 memset(&ip_prefix
, 0, sizeof(struct prefix
));
650 if (argv_find(argv
, argc
, "ip", &ip_idx
)) {
651 (void)str2prefix(argv
[ip_idx
+ 1]->arg
, &ip_prefix
);
652 apply_mask(&ip_prefix
);
654 build_type5_prefix_from_ip_prefix(
655 (struct prefix_evpn
*)argv_p
,
662 /* Debug option setting interface. */
663 unsigned long bgp_debug_option
= 0;
665 int debug(unsigned int option
)
667 return bgp_debug_option
& option
;
670 DEFUN (debug_bgp_as4
,
677 if (vty
->node
== CONFIG_NODE
)
680 TERM_DEBUG_ON(as4
, AS4
);
681 vty_out(vty
, "BGP as4 debugging is on\n");
686 DEFUN (no_debug_bgp_as4
,
687 no_debug_bgp_as4_cmd
,
694 if (vty
->node
== CONFIG_NODE
)
697 TERM_DEBUG_OFF(as4
, AS4
);
698 vty_out(vty
, "BGP as4 debugging is off\n");
703 DEFUN (debug_bgp_as4_segment
,
704 debug_bgp_as4_segment_cmd
,
705 "debug bgp as4 segment",
709 "BGP AS4 aspath segment handling\n")
711 if (vty
->node
== CONFIG_NODE
)
712 DEBUG_ON(as4
, AS4_SEGMENT
);
714 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
715 vty_out(vty
, "BGP as4 segment debugging is on\n");
720 DEFUN (no_debug_bgp_as4_segment
,
721 no_debug_bgp_as4_segment_cmd
,
722 "no debug bgp as4 segment",
727 "BGP AS4 aspath segment handling\n")
729 if (vty
->node
== CONFIG_NODE
)
730 DEBUG_OFF(as4
, AS4_SEGMENT
);
732 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
733 vty_out(vty
, "BGP as4 segment debugging is off\n");
738 /* debug bgp neighbor_events */
739 DEFUN (debug_bgp_neighbor_events
,
740 debug_bgp_neighbor_events_cmd
,
741 "debug bgp neighbor-events",
744 "BGP Neighbor Events\n")
746 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
748 if (vty
->node
== CONFIG_NODE
)
749 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
751 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
752 vty_out(vty
, "BGP neighbor-events debugging is on\n");
757 DEFUN (debug_bgp_neighbor_events_peer
,
758 debug_bgp_neighbor_events_peer_cmd
,
759 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
762 "BGP Neighbor Events\n"
763 "BGP neighbor IP address to debug\n"
764 "BGP IPv6 neighbor to debug\n"
765 "BGP neighbor on interface to debug\n")
768 const char *host
= argv
[idx_peer
]->arg
;
770 if (!bgp_debug_neighbor_events_peers
)
771 bgp_debug_neighbor_events_peers
= list_new();
773 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
776 "BGP neighbor-events debugging is already enabled for %s\n",
781 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
783 if (vty
->node
== CONFIG_NODE
)
784 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
786 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
787 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
793 DEFUN (no_debug_bgp_neighbor_events
,
794 no_debug_bgp_neighbor_events_cmd
,
795 "no debug bgp neighbor-events",
801 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
803 if (vty
->node
== CONFIG_NODE
)
804 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
806 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
807 vty_out(vty
, "BGP neighbor-events debugging is off\n");
812 DEFUN (no_debug_bgp_neighbor_events_peer
,
813 no_debug_bgp_neighbor_events_peer_cmd
,
814 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
819 "BGP neighbor IP address to debug\n"
820 "BGP IPv6 neighbor to debug\n"
821 "BGP neighbor on interface to debug\n")
825 const char *host
= argv
[idx_peer
]->arg
;
827 if (bgp_debug_neighbor_events_peers
828 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
829 found_peer
= bgp_debug_list_remove_entry(
830 bgp_debug_neighbor_events_peers
, host
, NULL
);
832 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
833 if (vty
->node
== CONFIG_NODE
)
834 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
836 TERM_DEBUG_OFF(neighbor_events
,
842 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
846 "BGP neighbor-events debugging was not enabled for %s\n",
853 DEFUN (debug_bgp_nht
,
858 "BGP nexthop tracking events\n")
860 if (vty
->node
== CONFIG_NODE
)
863 TERM_DEBUG_ON(nht
, NHT
);
864 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
869 DEFUN (no_debug_bgp_nht
,
870 no_debug_bgp_nht_cmd
,
875 "BGP nexthop tracking events\n")
877 if (vty
->node
== CONFIG_NODE
)
880 TERM_DEBUG_OFF(nht
, NHT
);
881 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
886 /* debug bgp keepalives */
887 DEFUN (debug_bgp_keepalive
,
888 debug_bgp_keepalive_cmd
,
889 "debug bgp keepalives",
894 bgp_debug_list_free(bgp_debug_keepalive_peers
);
896 if (vty
->node
== CONFIG_NODE
)
897 DEBUG_ON(keepalive
, KEEPALIVE
);
899 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
900 vty_out(vty
, "BGP keepalives debugging is on\n");
905 DEFUN (debug_bgp_keepalive_peer
,
906 debug_bgp_keepalive_peer_cmd
,
907 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
911 "BGP IPv4 neighbor to debug\n"
912 "BGP IPv6 neighbor to debug\n"
913 "BGP neighbor on interface to debug\n")
916 const char *host
= argv
[idx_peer
]->arg
;
918 if (!bgp_debug_keepalive_peers
)
919 bgp_debug_keepalive_peers
= list_new();
921 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
923 "BGP keepalive debugging is already enabled for %s\n",
928 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
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 for %s\n", host
);
939 DEFUN (no_debug_bgp_keepalive
,
940 no_debug_bgp_keepalive_cmd
,
941 "no debug bgp keepalives",
947 bgp_debug_list_free(bgp_debug_keepalive_peers
);
949 if (vty
->node
== CONFIG_NODE
)
950 DEBUG_OFF(keepalive
, KEEPALIVE
);
952 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
953 vty_out(vty
, "BGP keepalives debugging is off\n");
958 DEFUN (no_debug_bgp_keepalive_peer
,
959 no_debug_bgp_keepalive_peer_cmd
,
960 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
965 "BGP neighbor IP address to debug\n"
966 "BGP IPv6 neighbor to debug\n"
967 "BGP neighbor on interface to debug\n")
971 const char *host
= argv
[idx_peer
]->arg
;
973 if (bgp_debug_keepalive_peers
974 && !list_isempty(bgp_debug_keepalive_peers
)) {
975 found_peer
= bgp_debug_list_remove_entry(
976 bgp_debug_keepalive_peers
, host
, NULL
);
978 if (list_isempty(bgp_debug_keepalive_peers
)) {
979 if (vty
->node
== CONFIG_NODE
)
980 DEBUG_OFF(keepalive
, KEEPALIVE
);
982 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
987 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
990 "BGP keepalives debugging was not enabled for %s\n",
996 /* debug bgp bestpath */
997 DEFUN (debug_bgp_bestpath_prefix
,
998 debug_bgp_bestpath_prefix_cmd
,
999 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1006 struct prefix
*argv_p
;
1007 int idx_ipv4_ipv6_prefixlen
= 3;
1009 argv_p
= prefix_new();
1010 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1013 if (!bgp_debug_bestpath_prefixes
)
1014 bgp_debug_bestpath_prefixes
= list_new();
1016 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
1019 "BGP bestpath debugging is already enabled for %s\n",
1020 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1024 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1026 if (vty
->node
== CONFIG_NODE
) {
1027 DEBUG_ON(bestpath
, BESTPATH
);
1029 TERM_DEBUG_ON(bestpath
, BESTPATH
);
1030 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
1031 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1037 DEFUN (no_debug_bgp_bestpath_prefix
,
1038 no_debug_bgp_bestpath_prefix_cmd
,
1039 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1047 int idx_ipv4_ipv6_prefixlen
= 4;
1048 struct prefix
*argv_p
;
1049 int found_prefix
= 0;
1051 argv_p
= prefix_new();
1052 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1055 if (bgp_debug_bestpath_prefixes
1056 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
1057 found_prefix
= bgp_debug_list_remove_entry(
1058 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1060 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
1061 if (vty
->node
== CONFIG_NODE
) {
1062 DEBUG_OFF(bestpath
, BESTPATH
);
1064 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1066 "BGP bestpath debugging (per prefix) is off\n");
1072 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
1073 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1075 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
1076 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1081 DEFUN (no_debug_bgp_bestpath
,
1082 no_debug_bgp_bestpath_cmd
,
1083 "no debug bgp bestpath",
1089 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1091 if (vty
->node
== CONFIG_NODE
)
1092 DEBUG_OFF(bestpath
, BESTPATH
);
1094 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1095 vty_out(vty
, "BGP bestpath debugging is off\n");
1100 /* debug bgp updates */
1101 DEFUN (debug_bgp_update
,
1102 debug_bgp_update_cmd
,
1103 "debug bgp updates",
1108 bgp_debug_list_free(bgp_debug_update_in_peers
);
1109 bgp_debug_list_free(bgp_debug_update_out_peers
);
1110 bgp_debug_list_free(bgp_debug_update_prefixes
);
1112 if (vty
->node
== CONFIG_NODE
) {
1113 DEBUG_ON(update
, UPDATE_IN
);
1114 DEBUG_ON(update
, UPDATE_OUT
);
1116 TERM_DEBUG_ON(update
, UPDATE_IN
);
1117 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1118 vty_out(vty
, "BGP updates debugging is on\n");
1123 DEFUN (debug_bgp_update_direct
,
1124 debug_bgp_update_direct_cmd
,
1125 "debug bgp updates <in|out>",
1130 "Outbound updates\n")
1134 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1135 bgp_debug_list_free(bgp_debug_update_in_peers
);
1137 bgp_debug_list_free(bgp_debug_update_out_peers
);
1139 if (vty
->node
== CONFIG_NODE
) {
1140 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1141 DEBUG_ON(update
, UPDATE_IN
);
1143 DEBUG_ON(update
, UPDATE_OUT
);
1145 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1146 TERM_DEBUG_ON(update
, UPDATE_IN
);
1147 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1149 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1151 "BGP updates debugging is on (outbound)\n");
1157 DEFUN (debug_bgp_update_direct_peer
,
1158 debug_bgp_update_direct_peer_cmd
,
1159 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1164 "Outbound updates\n"
1165 "BGP neighbor IP address to debug\n"
1166 "BGP IPv6 neighbor to debug\n"
1167 "BGP neighbor on interface to debug\n")
1171 const char *host
= argv
[idx_peer
]->arg
;
1174 if (!bgp_debug_update_in_peers
)
1175 bgp_debug_update_in_peers
= list_new();
1177 if (!bgp_debug_update_out_peers
)
1178 bgp_debug_update_out_peers
= list_new();
1180 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1186 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1189 "BGP inbound update debugging is already enabled for %s\n",
1196 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1199 "BGP outbound update debugging is already enabled for %s\n",
1206 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1209 struct peer_af
*paf
;
1212 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1214 peer
= bgp_find_peer(vty
, host
);
1217 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1219 paf
= peer
->peer_af_array
[afidx
];
1221 if (PAF_SUBGRP(paf
)) {
1231 if (vty
->node
== CONFIG_NODE
) {
1233 DEBUG_ON(update
, UPDATE_IN
);
1235 DEBUG_ON(update
, UPDATE_OUT
);
1238 TERM_DEBUG_ON(update
, UPDATE_IN
);
1240 "BGP updates debugging is on (inbound) for %s\n",
1241 argv
[idx_peer
]->arg
);
1243 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1245 "BGP updates debugging is on (outbound) for %s\n",
1246 argv
[idx_peer
]->arg
);
1252 DEFUN (no_debug_bgp_update_direct
,
1253 no_debug_bgp_update_direct_cmd
,
1254 "no debug bgp updates <in|out>",
1260 "Outbound updates\n")
1263 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1264 bgp_debug_list_free(bgp_debug_update_in_peers
);
1266 if (vty
->node
== CONFIG_NODE
) {
1267 DEBUG_OFF(update
, UPDATE_IN
);
1269 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1271 "BGP updates debugging is off (inbound)\n");
1274 bgp_debug_list_free(bgp_debug_update_out_peers
);
1276 if (vty
->node
== CONFIG_NODE
) {
1277 DEBUG_OFF(update
, UPDATE_OUT
);
1279 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1281 "BGP updates debugging is off (outbound)\n");
1288 DEFUN (no_debug_bgp_update_direct_peer
,
1289 no_debug_bgp_update_direct_peer_cmd
,
1290 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1296 "Outbound updates\n"
1297 "BGP neighbor IP address to debug\n"
1298 "BGP IPv6 neighbor to debug\n"
1299 "BGP neighbor on interface to debug\n")
1305 const char *host
= argv
[idx_peer
]->arg
;
1307 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1312 if (inbound
&& bgp_debug_update_in_peers
1313 && !list_isempty(bgp_debug_update_in_peers
)) {
1314 found_peer
= bgp_debug_list_remove_entry(
1315 bgp_debug_update_in_peers
, host
, NULL
);
1317 if (list_isempty(bgp_debug_update_in_peers
)) {
1318 if (vty
->node
== CONFIG_NODE
)
1319 DEBUG_OFF(update
, UPDATE_IN
);
1321 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1323 "BGP updates debugging (inbound) is off\n");
1328 if (!inbound
&& bgp_debug_update_out_peers
1329 && !list_isempty(bgp_debug_update_out_peers
)) {
1330 found_peer
= bgp_debug_list_remove_entry(
1331 bgp_debug_update_out_peers
, host
, NULL
);
1333 if (list_isempty(bgp_debug_update_out_peers
)) {
1334 if (vty
->node
== CONFIG_NODE
)
1335 DEBUG_OFF(update
, UPDATE_OUT
);
1337 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1339 "BGP updates debugging (outbound) is off\n");
1344 struct peer_af
*paf
;
1346 peer
= bgp_find_peer(vty
, host
);
1349 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1351 paf
= peer
->peer_af_array
[afidx
];
1353 if (PAF_SUBGRP(paf
)) {
1354 UPDGRP_PEER_DBG_DIS(
1366 "BGP updates debugging (inbound) is off for %s\n",
1370 "BGP updates debugging (outbound) is off for %s\n",
1374 "BGP updates debugging (inbound) was not enabled for %s\n",
1378 "BGP updates debugging (outbound) was not enabled for %s\n",
1384 #ifndef VTYSH_EXTRACT_PL
1385 #include "bgpd/bgp_debug_clippy.c"
1388 DEFPY (debug_bgp_update_prefix_afi_safi
,
1389 debug_bgp_update_prefix_afi_safi_cmd
,
1390 "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>>",
1394 "Specify a prefix to debug\n"
1398 EVPN_TYPE_2_HELP_STR
1399 EVPN_TYPE_2_HELP_STR
1400 MAC_STR MAC_STR MAC_STR
1404 EVPN_TYPE_3_HELP_STR
1405 EVPN_TYPE_3_HELP_STR
1409 EVPN_TYPE_5_HELP_STR
1410 EVPN_TYPE_5_HELP_STR
1415 struct prefix
*argv_p
;
1416 int ret
= CMD_SUCCESS
;
1418 argv_p
= prefix_new();
1420 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1421 if (ret
!= CMD_SUCCESS
) {
1422 prefix_free(&argv_p
);
1426 if (!bgp_debug_update_prefixes
)
1427 bgp_debug_update_prefixes
= list_new();
1429 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1431 "BGP updates debugging is already enabled for %pFX\n",
1433 prefix_free(&argv_p
);
1437 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1439 if (vty
->node
== CONFIG_NODE
) {
1440 DEBUG_ON(update
, UPDATE_PREFIX
);
1442 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1443 vty_out(vty
, "BGP updates debugging is on for %pFX\n", argv_p
);
1446 prefix_free(&argv_p
);
1451 DEFPY (no_debug_bgp_update_prefix_afi_safi
,
1452 no_debug_bgp_update_prefix_afi_safi_cmd
,
1453 "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>>",
1458 "Specify a prefix to debug\n"
1462 EVPN_TYPE_2_HELP_STR
1463 EVPN_TYPE_2_HELP_STR
1464 MAC_STR MAC_STR MAC_STR
1468 EVPN_TYPE_3_HELP_STR
1469 EVPN_TYPE_3_HELP_STR
1473 EVPN_TYPE_5_HELP_STR
1474 EVPN_TYPE_5_HELP_STR
1479 struct prefix
*argv_p
;
1480 bool found_prefix
= false;
1481 int ret
= CMD_SUCCESS
;
1483 argv_p
= prefix_new();
1485 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1486 if (ret
!= CMD_SUCCESS
) {
1487 prefix_free(&argv_p
);
1491 if (bgp_debug_update_prefixes
1492 && !list_isempty(bgp_debug_update_prefixes
)) {
1493 found_prefix
= bgp_debug_list_remove_entry(
1494 bgp_debug_update_prefixes
, NULL
, argv_p
);
1496 if (list_isempty(bgp_debug_update_prefixes
)) {
1497 if (vty
->node
== CONFIG_NODE
) {
1498 DEBUG_OFF(update
, UPDATE_PREFIX
);
1500 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1502 "BGP updates debugging (per prefix) is off\n");
1508 vty_out(vty
, "BGP updates debugging is off for %pFX\n", argv_p
);
1510 vty_out(vty
, "BGP updates debugging was not enabled for %pFX\n",
1513 prefix_free(&argv_p
);
1519 DEFUN (debug_bgp_update_prefix
,
1520 debug_bgp_update_prefix_cmd
,
1521 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1525 "Specify a prefix to debug\n"
1529 int idx_ipv4_ipv6_prefixlen
= 4;
1530 struct prefix
*argv_p
;
1532 argv_p
= prefix_new();
1533 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1536 if (!bgp_debug_update_prefixes
)
1537 bgp_debug_update_prefixes
= list_new();
1539 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1541 "BGP updates debugging is already enabled for %s\n",
1542 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1546 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1548 if (vty
->node
== CONFIG_NODE
) {
1549 DEBUG_ON(update
, UPDATE_PREFIX
);
1551 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1552 vty_out(vty
, "BGP updates debugging is on for %s\n",
1553 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1559 DEFUN (no_debug_bgp_update_prefix
,
1560 no_debug_bgp_update_prefix_cmd
,
1561 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1566 "Specify a prefix to debug\n"
1570 int idx_ipv4_ipv6_prefixlen
= 5;
1571 struct prefix
*argv_p
;
1572 int found_prefix
= 0;
1574 argv_p
= prefix_new();
1575 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1578 if (bgp_debug_update_prefixes
1579 && !list_isempty(bgp_debug_update_prefixes
)) {
1580 found_prefix
= bgp_debug_list_remove_entry(
1581 bgp_debug_update_prefixes
, NULL
, argv_p
);
1583 if (list_isempty(bgp_debug_update_prefixes
)) {
1584 if (vty
->node
== CONFIG_NODE
) {
1585 DEBUG_OFF(update
, UPDATE_PREFIX
);
1587 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1589 "BGP updates debugging (per prefix) is off\n");
1595 vty_out(vty
, "BGP updates debugging is off for %s\n",
1596 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1598 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1599 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1604 DEFUN (no_debug_bgp_update
,
1605 no_debug_bgp_update_cmd
,
1606 "no debug bgp updates",
1612 struct listnode
*ln
;
1615 bgp_debug_list_free(bgp_debug_update_in_peers
);
1616 bgp_debug_list_free(bgp_debug_update_out_peers
);
1617 bgp_debug_list_free(bgp_debug_update_prefixes
);
1619 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1620 bgp_debug_clear_updgrp_update_dbg(bgp
);
1622 if (vty
->node
== CONFIG_NODE
) {
1623 DEBUG_OFF(update
, UPDATE_IN
);
1624 DEBUG_OFF(update
, UPDATE_OUT
);
1625 DEBUG_OFF(update
, UPDATE_PREFIX
);
1627 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1628 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1629 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1630 vty_out(vty
, "BGP updates debugging is off\n");
1635 /* debug bgp zebra */
1636 DEFUN (debug_bgp_zebra
,
1637 debug_bgp_zebra_cmd
,
1641 "BGP Zebra messages\n")
1643 if (vty
->node
== CONFIG_NODE
)
1644 DEBUG_ON(zebra
, ZEBRA
);
1646 TERM_DEBUG_ON(zebra
, ZEBRA
);
1647 vty_out(vty
, "BGP zebra debugging is on\n");
1652 DEFUN (debug_bgp_graceful_restart
,
1653 debug_bgp_graceful_restart_cmd
,
1654 "debug bgp graceful-restart",
1659 if (vty
->node
== CONFIG_NODE
) {
1660 DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1662 TERM_DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1663 vty_out(vty
, "BGP Graceful Restart debugging is on\n");
1669 DEFUN (debug_bgp_zebra_prefix
,
1670 debug_bgp_zebra_prefix_cmd
,
1671 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1674 "BGP Zebra messages\n"
1675 "Specify a prefix to debug\n"
1679 int idx_ipv4_ipv6_prefixlen
= 4;
1680 struct prefix
*argv_p
;
1682 argv_p
= prefix_new();
1683 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1686 if (!bgp_debug_zebra_prefixes
)
1687 bgp_debug_zebra_prefixes
= list_new();
1689 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1690 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1691 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1695 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1697 if (vty
->node
== CONFIG_NODE
)
1698 DEBUG_ON(zebra
, ZEBRA
);
1700 TERM_DEBUG_ON(zebra
, ZEBRA
);
1701 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1702 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1708 DEFUN (no_debug_bgp_zebra
,
1709 no_debug_bgp_zebra_cmd
,
1710 "no debug bgp zebra",
1714 "BGP Zebra messages\n")
1716 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1718 if (vty
->node
== CONFIG_NODE
)
1719 DEBUG_OFF(zebra
, ZEBRA
);
1721 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1722 vty_out(vty
, "BGP zebra debugging is off\n");
1727 DEFUN (no_debug_bgp_graceful_restart
,
1728 no_debug_bgp_graceful_restart_cmd
,
1729 "no debug bgp graceful-restart",
1735 if (vty
->node
== CONFIG_NODE
) {
1736 DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1738 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1739 vty_out(vty
, "BGP Graceful Restart debugging is off\n");
1744 DEFUN (no_debug_bgp_zebra_prefix
,
1745 no_debug_bgp_zebra_prefix_cmd
,
1746 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1750 "BGP Zebra messages\n"
1751 "Specify a prefix to debug\n"
1755 int idx_ipv4_ipv6_prefixlen
= 5;
1756 struct prefix
*argv_p
;
1757 int found_prefix
= 0;
1759 argv_p
= prefix_new();
1760 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1763 if (bgp_debug_zebra_prefixes
1764 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1765 found_prefix
= bgp_debug_list_remove_entry(
1766 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1768 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1769 if (vty
->node
== CONFIG_NODE
)
1770 DEBUG_OFF(zebra
, ZEBRA
);
1772 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1773 vty_out(vty
, "BGP zebra debugging is off\n");
1779 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1780 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1782 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1783 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1788 DEFUN (debug_bgp_allow_martians
,
1789 debug_bgp_allow_martians_cmd
,
1790 "debug bgp allow-martians",
1793 "BGP allow martian next hops\n")
1795 if (vty
->node
== CONFIG_NODE
)
1796 DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1798 TERM_DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1799 vty_out(vty
, "BGP allow_martian next hop debugging is on\n");
1804 DEFUN (no_debug_bgp_allow_martians
,
1805 no_debug_bgp_allow_martians_cmd
,
1806 "no debug bgp allow-martians",
1810 "BGP allow martian next hops\n")
1812 if (vty
->node
== CONFIG_NODE
)
1813 DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1815 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1816 vty_out(vty
, "BGP allow martian next hop debugging is off\n");
1822 /* debug bgp update-groups */
1823 DEFUN (debug_bgp_update_groups
,
1824 debug_bgp_update_groups_cmd
,
1825 "debug bgp update-groups",
1828 "BGP update-groups\n")
1830 if (vty
->node
== CONFIG_NODE
)
1831 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1833 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1834 vty_out(vty
, "BGP update-groups debugging is on\n");
1839 DEFUN (no_debug_bgp_update_groups
,
1840 no_debug_bgp_update_groups_cmd
,
1841 "no debug bgp update-groups",
1845 "BGP update-groups\n")
1847 if (vty
->node
== CONFIG_NODE
)
1848 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1850 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1851 vty_out(vty
, "BGP update-groups debugging is off\n");
1856 DEFUN (debug_bgp_vpn
,
1858 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1862 "leaked from vrf to vpn\n"
1863 "leaked to vrf from vpn\n"
1864 "route-map updates\n"
1869 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1870 if (vty
->node
== CONFIG_NODE
)
1871 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1873 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1874 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1875 if (vty
->node
== CONFIG_NODE
)
1876 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1878 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1879 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1880 if (vty
->node
== CONFIG_NODE
)
1881 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1883 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1884 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1885 if (vty
->node
== CONFIG_NODE
)
1886 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1888 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1890 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1891 return CMD_WARNING_CONFIG_FAILED
;
1894 if (vty
->node
!= CONFIG_NODE
)
1895 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1900 DEFUN (no_debug_bgp_vpn
,
1901 no_debug_bgp_vpn_cmd
,
1902 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1907 "leaked from vrf to vpn\n"
1908 "leaked to vrf from vpn\n"
1909 "route-map updates\n"
1914 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1915 if (vty
->node
== CONFIG_NODE
)
1916 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1918 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1920 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1921 if (vty
->node
== CONFIG_NODE
)
1922 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1924 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1925 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1926 if (vty
->node
== CONFIG_NODE
)
1927 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1929 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1930 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1931 if (vty
->node
== CONFIG_NODE
)
1932 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1934 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1936 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1937 return CMD_WARNING_CONFIG_FAILED
;
1940 if (vty
->node
!= CONFIG_NODE
)
1941 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1946 DEFUN (debug_bgp_pbr
,
1948 "debug bgp pbr [error]",
1951 "BGP policy based routing\n"
1956 if (argv_find(argv
, argc
, "error", &idx
)) {
1957 if (vty
->node
== CONFIG_NODE
)
1958 DEBUG_ON(pbr
, PBR_ERROR
);
1960 TERM_DEBUG_ON(pbr
, PBR_ERROR
);
1961 vty_out(vty
, "BGP policy based routing error is on\n");
1965 if (vty
->node
== CONFIG_NODE
)
1968 TERM_DEBUG_ON(pbr
, PBR
);
1969 vty_out(vty
, "BGP policy based routing is on\n");
1974 DEFUN (no_debug_bgp_pbr
,
1975 no_debug_bgp_pbr_cmd
,
1976 "no debug bgp pbr [error]",
1980 "BGP policy based routing\n"
1985 if (argv_find(argv
, argc
, "error", &idx
)) {
1986 if (vty
->node
== CONFIG_NODE
)
1987 DEBUG_OFF(pbr
, PBR_ERROR
);
1989 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1990 vty_out(vty
, "BGP policy based routing error is off\n");
1994 if (vty
->node
== CONFIG_NODE
)
1995 DEBUG_OFF(pbr
, PBR
);
1997 TERM_DEBUG_OFF(pbr
, PBR
);
1998 vty_out(vty
, "BGP policy based routing is off\n");
2003 DEFPY (debug_bgp_evpn_mh
,
2004 debug_bgp_evpn_mh_cmd
,
2005 "[no$no] debug bgp evpn mh <es$es|route$rt>",
2011 "Ethernet Segment debugging\n"
2012 "Route debugging\n")
2015 if (vty
->node
== CONFIG_NODE
) {
2017 DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2019 DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
2022 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2024 "BGP EVPN-MH ES debugging is off\n");
2026 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_ES
);
2028 "BGP EVPN-MH ES debugging is on\n");
2033 if (vty
->node
== CONFIG_NODE
) {
2035 DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2037 DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
2040 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2042 "BGP EVPN-MH route debugging is off\n");
2044 TERM_DEBUG_ON(evpn_mh
, EVPN_MH_RT
);
2046 "BGP EVPN-MH route debugging is on\n");
2054 DEFUN (debug_bgp_labelpool
,
2055 debug_bgp_labelpool_cmd
,
2056 "debug bgp labelpool",
2061 if (vty
->node
== CONFIG_NODE
)
2062 DEBUG_ON(labelpool
, LABELPOOL
);
2064 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
2066 if (vty
->node
!= CONFIG_NODE
)
2067 vty_out(vty
, "enabled debug bgp labelpool\n");
2072 DEFUN (no_debug_bgp_labelpool
,
2073 no_debug_bgp_labelpool_cmd
,
2074 "no debug bgp labelpool",
2080 if (vty
->node
== CONFIG_NODE
)
2081 DEBUG_OFF(labelpool
, LABELPOOL
);
2083 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2086 if (vty
->node
!= CONFIG_NODE
)
2087 vty_out(vty
, "disabled debug bgp labelpool\n");
2092 DEFUN (no_debug_bgp
,
2100 struct listnode
*ln
;
2102 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
2103 bgp_debug_list_free(bgp_debug_keepalive_peers
);
2104 bgp_debug_list_free(bgp_debug_update_in_peers
);
2105 bgp_debug_list_free(bgp_debug_update_out_peers
);
2106 bgp_debug_list_free(bgp_debug_update_prefixes
);
2107 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
2108 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
2110 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
2111 bgp_debug_clear_updgrp_update_dbg(bgp
);
2113 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
2114 TERM_DEBUG_OFF(update
, UPDATE_IN
);
2115 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
2116 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
2117 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
2118 TERM_DEBUG_OFF(as4
, AS4
);
2119 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
2120 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
2121 TERM_DEBUG_OFF(zebra
, ZEBRA
);
2122 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
2123 TERM_DEBUG_OFF(nht
, NHT
);
2124 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
2125 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
2126 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
2127 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
2128 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
2129 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2130 TERM_DEBUG_OFF(pbr
, PBR
);
2131 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
2132 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
2133 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_ES
);
2134 TERM_DEBUG_OFF(evpn_mh
, EVPN_MH_RT
);
2136 vty_out(vty
, "All possible debugging has been turned off\n");
2141 DEFUN_NOSH (show_debugging_bgp
,
2142 show_debugging_bgp_cmd
,
2143 "show debugging [bgp]",
2148 vty_out(vty
, "BGP debugging status:\n");
2150 if (BGP_DEBUG(as4
, AS4
))
2151 vty_out(vty
, " BGP as4 debugging is on\n");
2153 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
2154 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
2156 if (BGP_DEBUG(bestpath
, BESTPATH
))
2157 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
2158 bgp_debug_bestpath_prefixes
);
2160 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
2161 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
2162 bgp_debug_keepalive_peers
);
2164 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
2165 bgp_debug_list_print(vty
,
2166 " BGP neighbor-events debugging is on",
2167 bgp_debug_neighbor_events_peers
);
2169 if (BGP_DEBUG(nht
, NHT
))
2170 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
2172 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
2173 vty_out(vty
, " BGP update-groups debugging is on\n");
2175 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
2176 bgp_debug_list_print(vty
, " BGP updates debugging is on",
2177 bgp_debug_update_prefixes
);
2179 if (BGP_DEBUG(update
, UPDATE_IN
))
2180 bgp_debug_list_print(vty
,
2181 " BGP updates debugging is on (inbound)",
2182 bgp_debug_update_in_peers
);
2184 if (BGP_DEBUG(update
, UPDATE_OUT
))
2185 bgp_debug_list_print(vty
,
2186 " BGP updates debugging is on (outbound)",
2187 bgp_debug_update_out_peers
);
2189 if (BGP_DEBUG(zebra
, ZEBRA
))
2190 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
2191 bgp_debug_zebra_prefixes
);
2193 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2194 vty_out(vty
, " BGP graceful-restart debugging is on\n");
2196 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
2197 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
2199 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
2201 " BGP route leak from vrf to vpn debugging is on\n");
2202 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
2204 " BGP route leak to vrf from vpn debugging is on\n");
2205 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
2206 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
2207 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
2208 vty_out(vty
, " BGP vpn label event debugging is on\n");
2209 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
2210 vty_out(vty
, " BGP flowspec debugging is on\n");
2211 if (BGP_DEBUG(labelpool
, LABELPOOL
))
2212 vty_out(vty
, " BGP labelpool debugging is on\n");
2214 if (BGP_DEBUG(pbr
, PBR
))
2215 vty_out(vty
, " BGP policy based routing debugging is on\n");
2216 if (BGP_DEBUG(pbr
, PBR_ERROR
))
2217 vty_out(vty
, " BGP policy based routing error debugging is on\n");
2219 if (BGP_DEBUG(evpn_mh
, EVPN_MH_ES
))
2220 vty_out(vty
, " BGP EVPN-MH ES debugging is on\n");
2221 if (BGP_DEBUG(evpn_mh
, EVPN_MH_RT
))
2222 vty_out(vty
, " BGP EVPN-MH route debugging is on\n");
2228 static int bgp_config_write_debug(struct vty
*vty
)
2232 if (CONF_BGP_DEBUG(as4
, AS4
)) {
2233 vty_out(vty
, "debug bgp as4\n");
2237 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
2238 vty_out(vty
, "debug bgp as4 segment\n");
2242 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
2243 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
2244 bgp_debug_bestpath_prefixes
);
2247 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
2248 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
2249 bgp_debug_keepalive_peers
);
2252 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
2253 write
+= bgp_debug_list_conf_print(
2254 vty
, "debug bgp neighbor-events",
2255 bgp_debug_neighbor_events_peers
);
2258 if (CONF_BGP_DEBUG(nht
, NHT
)) {
2259 vty_out(vty
, "debug bgp nht\n");
2263 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
2264 vty_out(vty
, "debug bgp update-groups\n");
2268 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2269 write
+= bgp_debug_list_conf_print(vty
,
2270 "debug bgp updates prefix",
2271 bgp_debug_update_prefixes
);
2274 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
2275 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
2276 bgp_debug_update_in_peers
);
2279 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
2280 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
2281 bgp_debug_update_out_peers
);
2284 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
2285 if (!bgp_debug_zebra_prefixes
2286 || list_isempty(bgp_debug_zebra_prefixes
)) {
2287 vty_out(vty
, "debug bgp zebra\n");
2290 write
+= bgp_debug_list_conf_print(
2291 vty
, "debug bgp zebra prefix",
2292 bgp_debug_zebra_prefixes
);
2296 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
2297 vty_out(vty
, "debug bgp allow-martians\n");
2301 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
2302 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
2305 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
2306 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
2309 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
2310 vty_out(vty
, "debug bgp vpn rmap-event\n");
2313 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
2314 vty_out(vty
, "debug bgp vpn label\n");
2317 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
2318 vty_out(vty
, "debug bgp flowspec\n");
2321 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
2322 vty_out(vty
, "debug bgp labelpool\n");
2326 if (CONF_BGP_DEBUG(pbr
, PBR
)) {
2327 vty_out(vty
, "debug bgp pbr\n");
2330 if (CONF_BGP_DEBUG(pbr
, PBR_ERROR
)) {
2331 vty_out(vty
, "debug bgp pbr error\n");
2335 if (CONF_BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
)) {
2336 vty_out(vty
, "debug bgp graceful-restart\n");
2340 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_ES
)) {
2341 vty_out(vty
, "debug bgp evpn mh es\n");
2344 if (CONF_BGP_DEBUG(evpn_mh
, EVPN_MH_RT
)) {
2345 vty_out(vty
, "debug bgp evpn mh route\n");
2352 static int bgp_config_write_debug(struct vty
*vty
);
2353 static struct cmd_node debug_node
= {
2357 .config_write
= bgp_config_write_debug
,
2360 void bgp_debug_init(void)
2362 install_node(&debug_node
);
2364 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
2366 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
2367 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
2368 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
2369 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
2371 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
2372 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
2373 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
2374 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
2375 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
2376 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
2377 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
2378 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
2379 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
2380 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
2381 install_element(ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
2382 install_element(CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
2383 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
2384 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
2385 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2386 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2388 install_element(ENABLE_NODE
, &debug_bgp_graceful_restart_cmd
);
2389 install_element(CONFIG_NODE
, &debug_bgp_graceful_restart_cmd
);
2391 /* debug bgp updates (in|out) */
2392 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2393 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2394 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2395 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2397 /* debug bgp updates (in|out) A.B.C.D */
2398 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2399 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2400 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2401 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2403 /* debug bgp updates prefix A.B.C.D/M */
2404 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2405 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2406 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2407 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2408 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2409 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2410 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2411 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2413 /* debug bgp zebra prefix A.B.C.D/M */
2414 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2415 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2416 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2417 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2419 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2420 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2421 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2422 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2424 /* debug bgp neighbor-events A.B.C.D */
2425 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2426 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2427 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2428 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2430 /* debug bgp keepalive A.B.C.D */
2431 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2432 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2433 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2434 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2436 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2437 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2438 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2439 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2440 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2441 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2442 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2443 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2444 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2445 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2446 install_element(ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
2447 install_element(CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
2448 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2449 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2450 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2451 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2452 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2453 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2454 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2456 install_element(ENABLE_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2457 install_element(CONFIG_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2459 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2460 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2461 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2462 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2464 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2465 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2466 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2467 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2470 install_element(ENABLE_NODE
, &debug_bgp_pbr_cmd
);
2471 install_element(CONFIG_NODE
, &debug_bgp_pbr_cmd
);
2472 install_element(ENABLE_NODE
, &no_debug_bgp_pbr_cmd
);
2473 install_element(CONFIG_NODE
, &no_debug_bgp_pbr_cmd
);
2475 install_element(ENABLE_NODE
, &debug_bgp_evpn_mh_cmd
);
2476 install_element(CONFIG_NODE
, &debug_bgp_evpn_mh_cmd
);
2479 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2480 * for BGP_DEBUG_TYPE
2482 static int bgp_debug_per_prefix(const struct prefix
*p
,
2483 unsigned long term_bgp_debug_type
,
2484 unsigned int BGP_DEBUG_TYPE
,
2485 struct list
*per_prefix_list
)
2487 struct bgp_debug_filter
*filter
;
2488 struct listnode
*node
, *nnode
;
2490 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2491 /* We are debugging all prefixes so return true */
2492 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2499 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2501 if (filter
->p
->prefixlen
== p
->prefixlen
2502 && prefix_match(filter
->p
, p
))
2512 /* Return true if this peer is on the per_peer_list of peers to debug
2513 * for BGP_DEBUG_TYPE
2515 static int bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2516 unsigned int BGP_DEBUG_TYPE
,
2517 struct list
*per_peer_list
)
2519 struct bgp_debug_filter
*filter
;
2520 struct listnode
*node
, *nnode
;
2522 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2523 /* We are debugging all peers so return true */
2524 if (!per_peer_list
|| list_isempty(per_peer_list
))
2531 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2533 if (strcmp(filter
->host
, host
) == 0)
2543 int bgp_debug_neighbor_events(struct peer
*peer
)
2550 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2551 BGP_DEBUG_NEIGHBOR_EVENTS
,
2552 bgp_debug_neighbor_events_peers
);
2555 int bgp_debug_keepalive(struct peer
*peer
)
2562 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2563 BGP_DEBUG_KEEPALIVE
,
2564 bgp_debug_keepalive_peers
);
2567 bool bgp_debug_update(struct peer
*peer
, const struct prefix
*p
,
2568 struct update_group
*updgrp
, unsigned int inbound
)
2576 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2577 BGP_DEBUG_UPDATE_IN
,
2578 bgp_debug_update_in_peers
))
2584 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2585 BGP_DEBUG_UPDATE_OUT
,
2586 bgp_debug_update_out_peers
))
2589 /* Check if update debugging implicitly enabled for the group.
2591 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2596 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2597 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2598 BGP_DEBUG_UPDATE_PREFIX
,
2599 bgp_debug_update_prefixes
))
2606 bool bgp_debug_bestpath(struct bgp_dest
*dest
)
2608 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2609 if (bgp_debug_per_prefix(
2610 bgp_dest_get_prefix(dest
), term_bgp_debug_bestpath
,
2611 BGP_DEBUG_BESTPATH
, bgp_debug_bestpath_prefixes
))
2618 bool bgp_debug_zebra(const struct prefix
*p
)
2620 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2621 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2623 bgp_debug_zebra_prefixes
))
2630 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2631 const struct prefix_rd
*prd
,
2632 union prefixconstptr pu
,
2633 mpls_label_t
*label
, uint32_t num_labels
,
2634 int addpath_valid
, uint32_t addpath_id
,
2635 char *str
, int size
)
2637 char rd_buf
[RD_ADDRSTRLEN
];
2639 /* ' with addpath ID ' 17
2640 * max strlen of uint32 + 10
2641 * +/- (just in case) + 1
2642 * null terminator + 1
2643 * ============================ 29 */
2644 char pathid_buf
[30];
2646 if (size
< BGP_PRD_PATH_STRLEN
)
2649 /* Note: Path-id is created by default, but only included in update
2651 pathid_buf
[0] = '\0';
2653 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2657 if (bgp_labeled_safi(safi
) && num_labels
) {
2659 if (safi
== SAFI_EVPN
) {
2662 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2663 snprintf(tag_buf
, sizeof(tag_buf
), " label %s",
2666 uint32_t label_value
;
2668 label_value
= decode_label(label
);
2669 snprintf(tag_buf
, sizeof(tag_buf
), " label %u",
2675 snprintfrr(str
, size
, "RD %s %pFX%s%s %s %s",
2676 prefix_rd2str(prd
, rd_buf
, sizeof(rd_buf
)), pu
.p
,
2677 tag_buf
, pathid_buf
, afi2str(afi
), safi2str(safi
));
2678 else if (safi
== SAFI_FLOWSPEC
) {
2679 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2680 const struct prefix_fs
*fs
= pu
.fs
;
2682 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2683 fs
->prefix
.prefixlen
,
2685 NLRI_STRING_FORMAT_DEBUG
, NULL
,
2686 family2afi(fs
->prefix
.family
));
2687 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2690 snprintfrr(str
, size
, "%pFX%s%s %s %s", pu
.p
, tag_buf
,
2691 pathid_buf
, afi2str(afi
), safi2str(safi
));