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>
29 #include "sockunion.h"
34 #include "bgpd/bgpd.h"
35 #include "bgpd/bgp_aspath.h"
36 #include "bgpd/bgp_route.h"
37 #include "bgpd/bgp_attr.h"
38 #include "bgpd/bgp_debug.h"
39 #include "bgpd/bgp_community.h"
40 #include "bgpd/bgp_updgrp.h"
41 #include "bgpd/bgp_mplsvpn.h"
42 #include "bgpd/bgp_ecommunity.h"
43 #include "bgpd/bgp_label.h"
44 #include "bgpd/bgp_evpn.h"
45 #include "bgpd/bgp_evpn_private.h"
46 #include "bgpd/bgp_evpn_vty.h"
47 #include "bgpd/bgp_vty.h"
48 #include "bgpd/bgp_flowspec.h"
50 unsigned long conf_bgp_debug_as4
;
51 unsigned long conf_bgp_debug_neighbor_events
;
52 unsigned long conf_bgp_debug_events
;
53 unsigned long conf_bgp_debug_packet
;
54 unsigned long conf_bgp_debug_filter
;
55 unsigned long conf_bgp_debug_keepalive
;
56 unsigned long conf_bgp_debug_update
;
57 unsigned long conf_bgp_debug_bestpath
;
58 unsigned long conf_bgp_debug_zebra
;
59 unsigned long conf_bgp_debug_allow_martians
;
60 unsigned long conf_bgp_debug_nht
;
61 unsigned long conf_bgp_debug_update_groups
;
62 unsigned long conf_bgp_debug_vpn
;
63 unsigned long conf_bgp_debug_flowspec
;
64 unsigned long conf_bgp_debug_labelpool
;
65 unsigned long conf_bgp_debug_pbr
;
66 unsigned long conf_bgp_debug_graceful_restart
;
68 unsigned long term_bgp_debug_as4
;
69 unsigned long term_bgp_debug_neighbor_events
;
70 unsigned long term_bgp_debug_events
;
71 unsigned long term_bgp_debug_packet
;
72 unsigned long term_bgp_debug_filter
;
73 unsigned long term_bgp_debug_keepalive
;
74 unsigned long term_bgp_debug_update
;
75 unsigned long term_bgp_debug_bestpath
;
76 unsigned long term_bgp_debug_zebra
;
77 unsigned long term_bgp_debug_allow_martians
;
78 unsigned long term_bgp_debug_nht
;
79 unsigned long term_bgp_debug_update_groups
;
80 unsigned long term_bgp_debug_vpn
;
81 unsigned long term_bgp_debug_flowspec
;
82 unsigned long term_bgp_debug_labelpool
;
83 unsigned long term_bgp_debug_pbr
;
84 unsigned long term_bgp_debug_graceful_restart
;
86 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
87 struct list
*bgp_debug_keepalive_peers
= NULL
;
88 struct list
*bgp_debug_update_out_peers
= NULL
;
89 struct list
*bgp_debug_update_in_peers
= NULL
;
90 struct list
*bgp_debug_update_prefixes
= NULL
;
91 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
92 struct list
*bgp_debug_zebra_prefixes
= NULL
;
94 /* messages for BGP-4 status */
95 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
98 {OpenSent
, "OpenSent"},
99 {OpenConfirm
, "OpenConfirm"},
100 {Established
, "Established"},
101 {Clearing
, "Clearing"},
102 {Deleted
, "Deleted"},
105 /* BGP message type string. */
106 const char *const bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
107 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
110 /* message for BGP-4 Notify */
111 static const struct message bgp_notify_msg
[] = {
112 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
113 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
114 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
115 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
116 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
117 {BGP_NOTIFY_CEASE
, "Cease"},
118 {BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
121 static const struct message bgp_notify_head_msg
[] = {
122 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
123 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
124 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
127 static const struct message bgp_notify_open_msg
[] = {
128 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
129 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
130 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
131 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
132 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
133 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
134 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
135 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
138 static const struct message bgp_notify_update_msg
[] = {
139 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
140 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
141 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
142 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
143 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
144 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
145 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
146 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
147 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
148 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
149 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
150 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
153 static const struct message bgp_notify_cease_msg
[] = {
154 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
155 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
156 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
157 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
158 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
159 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
160 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
161 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
162 "/Connection collision resolution"},
163 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
166 static const struct message bgp_notify_capability_msg
[] = {
167 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
168 {BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value"},
169 {BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
170 {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
173 static const struct message bgp_notify_fsm_msg
[] = {
174 {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC
, "/Unspecific"},
175 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT
,
176 "/Receive Unexpected Message in OpenSent State"},
177 {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM
,
178 "/Receive Unexpected Message in OpenConfirm State"},
179 {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED
,
180 "/Receive Unexpected Message in Established State"},
183 /* Origin strings. */
184 const char *const bgp_origin_str
[] = {"i", "e", "?"};
185 const char *const bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
187 static int bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
189 /* Given a string return a pointer the corresponding peer structure */
190 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
192 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
200 ret
= str2sockunion(peer_str
, &su
);
204 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
207 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
211 return peer_lookup(bgp
, &su
);
214 static void bgp_debug_list_free(struct list
*list
)
216 struct bgp_debug_filter
*filter
;
217 struct listnode
*node
, *nnode
;
220 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
221 listnode_delete(list
, filter
);
222 prefix_free(&filter
->p
);
223 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
224 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
229 * Print the desc along with a list of peers/prefixes this debug is
232 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
235 struct bgp_debug_filter
*filter
;
236 struct listnode
*node
, *nnode
;
237 char buf
[PREFIX2STR_BUFFER
];
239 vty_out(vty
, "%s", desc
);
241 if (list
&& !list_isempty(list
)) {
242 vty_out(vty
, " for");
243 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
245 vty_out(vty
, " %s", filter
->host
);
247 if (filter
->p
&& filter
->p
->family
== AF_EVPN
)
248 bgp_debug_print_evpn_prefix(vty
, "", filter
->p
);
249 else if (filter
->p
) {
250 prefix2str(filter
->p
, buf
, sizeof(buf
));
251 vty_out(vty
, " %s", buf
);
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
;
268 char buf
[PREFIX2STR_BUFFER
];
271 if (list
&& !list_isempty(list
)) {
272 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
274 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
278 if (filter
->p
&& filter
->p
->family
== AF_EVPN
) {
279 bgp_debug_print_evpn_prefix(vty
, desc
,
282 } else if (filter
->p
) {
283 prefix2str(filter
->p
, buf
, sizeof(buf
));
284 vty_out(vty
, "%s %s\n", desc
, buf
);
291 vty_out(vty
, "%s\n", desc
);
298 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
299 const struct prefix
*p
)
301 struct bgp_debug_filter
*filter
;
303 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
304 sizeof(struct bgp_debug_filter
));
307 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
311 filter
->p
= prefix_new();
312 prefix_copy(filter
->p
, p
);
315 listnode_add(list
, filter
);
318 static int bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
321 struct bgp_debug_filter
*filter
;
322 struct listnode
*node
, *nnode
;
324 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
325 if (host
&& strcmp(filter
->host
, host
) == 0) {
326 listnode_delete(list
, filter
);
327 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
328 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
330 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
331 && prefix_match(filter
->p
, p
)) {
332 listnode_delete(list
, filter
);
333 prefix_free(&filter
->p
);
334 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
342 static int bgp_debug_list_has_entry(struct list
*list
, const char *host
,
343 const struct prefix
*p
)
345 struct bgp_debug_filter
*filter
;
346 struct listnode
*node
, *nnode
;
348 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
350 if (strcmp(filter
->host
, host
) == 0) {
354 if (filter
->p
->prefixlen
== p
->prefixlen
355 && prefix_match(filter
->p
, p
)) {
364 int bgp_debug_peer_updout_enabled(char *host
)
366 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
370 /* Dump attribute. */
371 int bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
373 char addrbuf
[BUFSIZ
];
380 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
381 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
383 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
384 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
385 bgp_origin_str
[attr
->origin
]);
388 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
389 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
390 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
392 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
395 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
396 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
397 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
400 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
401 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
403 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
404 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
405 ", localpref %u", attr
->local_pref
);
407 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
408 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
411 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
412 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
414 community_str(attr
->community
, false));
416 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
417 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
418 ", extcommunity %s", ecommunity_str(attr
->ecommunity
));
420 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
421 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
422 ", atomic-aggregate");
424 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
425 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
426 ", aggregated by %u %s", attr
->aggregator_as
,
427 inet_ntoa(attr
->aggregator_addr
));
429 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
430 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
431 ", originator %s", inet_ntoa(attr
->originator_id
));
433 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
436 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
438 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
439 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), " %s",
440 inet_ntoa(attr
->cluster
->list
[i
]));
443 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
444 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
445 ", pmsi tnltype %u", attr
->pmsi_tnl_type
);
447 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
448 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
449 aspath_print(attr
->aspath
));
451 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
452 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
453 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
454 ", label-index %u", attr
->label_index
);
463 const char *bgp_notify_code_str(char code
)
465 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
468 const char *bgp_notify_subcode_str(char code
, char subcode
)
472 case BGP_NOTIFY_HEADER_ERR
:
473 return lookup_msg(bgp_notify_head_msg
, subcode
,
474 "Unrecognized Error Subcode");
475 case BGP_NOTIFY_OPEN_ERR
:
476 return lookup_msg(bgp_notify_open_msg
, subcode
,
477 "Unrecognized Error Subcode");
478 case BGP_NOTIFY_UPDATE_ERR
:
479 return lookup_msg(bgp_notify_update_msg
, subcode
,
480 "Unrecognized Error Subcode");
481 case BGP_NOTIFY_HOLD_ERR
:
483 case BGP_NOTIFY_FSM_ERR
:
484 return lookup_msg(bgp_notify_fsm_msg
, subcode
,
485 "Unrecognized Error Subcode");
486 case BGP_NOTIFY_CEASE
:
487 return lookup_msg(bgp_notify_cease_msg
, subcode
,
488 "Unrecognized Error Subcode");
489 case BGP_NOTIFY_CAPABILITY_ERR
:
490 return lookup_msg(bgp_notify_capability_msg
, subcode
,
491 "Unrecognized Error Subcode");
496 /* extract notify admin reason if correctly present */
497 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, uint8_t *data
,
500 if (!data
|| datalen
< 1)
503 uint8_t len
= data
[0];
504 if (len
> 128 || len
> datalen
- 1)
507 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
510 /* dump notify packet */
511 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
514 const char *subcode_str
;
515 const char *code_str
;
516 const char *msg_str
= NULL
;
519 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
520 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
521 code_str
= bgp_notify_code_str(bgp_notify
->code
);
522 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
523 bgp_notify
->subcode
);
525 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
526 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
527 || bgp_notify
->subcode
528 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
529 msg_str
= bgp_notify_admin_message(
530 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
536 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) \"%s\"",
537 strcmp(direct
, "received") == 0
540 peer
->host
, bgp_notify
->code
,
541 bgp_notify
->subcode
, code_str
, subcode_str
,
544 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
546 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
547 strcmp(direct
, "received") == 0
550 peer
->host
, bgp_notify
->code
,
551 bgp_notify
->subcode
, code_str
, subcode_str
,
552 bgp_notify
->length
, msg_str
);
557 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
560 bgp
= bgp_get_default();
561 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
564 static int bgp_debug_print_evpn_prefix(struct vty
*vty
, const char *desc
,
567 char evpn_desc
[PREFIX2STR_BUFFER
+ INET_ADDRSTRLEN
];
568 char buf
[PREFIX2STR_BUFFER
];
569 char buf2
[ETHER_ADDR_STRLEN
];
571 if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_MAC_IP_ROUTE
) {
572 if (is_evpn_prefix_ipaddr_none((struct prefix_evpn
*)p
)) {
573 sprintf(evpn_desc
, "l2vpn evpn type macip mac %s",
575 &p
->u
.prefix_evpn
.macip_addr
.mac
,
576 buf2
, sizeof(buf2
)));
578 uint8_t family
= is_evpn_prefix_ipaddr_v4(
579 (struct prefix_evpn
*)p
) ?
581 sprintf(evpn_desc
, "l2vpn evpn type macip mac %s ip %s",
583 &p
->u
.prefix_evpn
.macip_addr
.mac
,
586 &p
->u
.prefix_evpn
.macip_addr
.ip
.ip
.addr
,
587 buf
, PREFIX2STR_BUFFER
));
589 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IMET_ROUTE
) {
590 sprintf(evpn_desc
, "l2vpn evpn type multicast ip %s",
591 inet_ntoa(p
->u
.prefix_evpn
.imet_addr
.ip
.ipaddr_v4
));
592 } else if (p
->u
.prefix_evpn
.route_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
593 uint8_t family
= is_evpn_prefix_ipaddr_v4(
594 (struct prefix_evpn
*)p
) ? AF_INET
596 sprintf(evpn_desc
, "l2vpn evpn type prefix ip %s/%d",
598 &p
->u
.prefix_evpn
.prefix_addr
.ip
.ip
.addr
, buf
,
600 p
->u
.prefix_evpn
.prefix_addr
.ip_prefix_length
);
603 vty_out(vty
, "%s %s\n", desc
, evpn_desc
);
608 static int bgp_debug_parse_evpn_prefix(struct vty
*vty
, struct cmd_token
**argv
,
609 int argc
, struct prefix
**argv_pp
)
611 struct prefix
*argv_p
;
621 if (argv_find(argv
, argc
, "macip", &type_idx
))
622 evpn_type
= BGP_EVPN_MAC_IP_ROUTE
;
623 else if (argv_find(argv
, argc
, "multicast", &type_idx
))
624 evpn_type
= BGP_EVPN_IMET_ROUTE
;
625 else if (argv_find(argv
, argc
, "prefix", &type_idx
))
626 evpn_type
= BGP_EVPN_IP_PREFIX_ROUTE
;
630 if (evpn_type
== BGP_EVPN_MAC_IP_ROUTE
) {
631 memset(&ip
, 0, sizeof(struct ipaddr
));
633 argv_find(argv
, argc
, "mac", &mac_idx
);
634 (void)prefix_str2mac(argv
[mac_idx
+ 1]->arg
, &mac
);
636 argv_find(argv
, argc
, "ip", &ip_idx
);
637 str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
);
639 build_evpn_type2_prefix((struct prefix_evpn
*)argv_p
,
641 } else if (evpn_type
== BGP_EVPN_IMET_ROUTE
) {
642 memset(&ip
, 0, sizeof(struct ipaddr
));
644 argv_find(argv
, argc
, "ip", &ip_idx
);
645 str2ipaddr(argv
[ip_idx
+ 1]->arg
, &ip
);
647 build_evpn_type3_prefix((struct prefix_evpn
*)argv_p
,
649 } else if (evpn_type
== BGP_EVPN_IP_PREFIX_ROUTE
) {
650 struct prefix ip_prefix
;
652 memset(&ip_prefix
, 0, sizeof(struct prefix
));
653 if (argv_find(argv
, argc
, "ip", &ip_idx
)) {
654 (void)str2prefix(argv
[ip_idx
+ 1]->arg
, &ip_prefix
);
655 apply_mask(&ip_prefix
);
657 build_type5_prefix_from_ip_prefix(
658 (struct prefix_evpn
*)argv_p
,
665 /* Debug option setting interface. */
666 unsigned long bgp_debug_option
= 0;
668 int debug(unsigned int option
)
670 return bgp_debug_option
& option
;
673 DEFUN (debug_bgp_as4
,
680 if (vty
->node
== CONFIG_NODE
)
683 TERM_DEBUG_ON(as4
, AS4
);
684 vty_out(vty
, "BGP as4 debugging is on\n");
689 DEFUN (no_debug_bgp_as4
,
690 no_debug_bgp_as4_cmd
,
697 if (vty
->node
== CONFIG_NODE
)
700 TERM_DEBUG_OFF(as4
, AS4
);
701 vty_out(vty
, "BGP as4 debugging is off\n");
706 DEFUN (debug_bgp_as4_segment
,
707 debug_bgp_as4_segment_cmd
,
708 "debug bgp as4 segment",
712 "BGP AS4 aspath segment handling\n")
714 if (vty
->node
== CONFIG_NODE
)
715 DEBUG_ON(as4
, AS4_SEGMENT
);
717 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
718 vty_out(vty
, "BGP as4 segment debugging is on\n");
723 DEFUN (no_debug_bgp_as4_segment
,
724 no_debug_bgp_as4_segment_cmd
,
725 "no debug bgp as4 segment",
730 "BGP AS4 aspath segment handling\n")
732 if (vty
->node
== CONFIG_NODE
)
733 DEBUG_OFF(as4
, AS4_SEGMENT
);
735 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
736 vty_out(vty
, "BGP as4 segment debugging is off\n");
741 /* debug bgp neighbor_events */
742 DEFUN (debug_bgp_neighbor_events
,
743 debug_bgp_neighbor_events_cmd
,
744 "debug bgp neighbor-events",
747 "BGP Neighbor Events\n")
749 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
751 if (vty
->node
== CONFIG_NODE
)
752 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
754 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
755 vty_out(vty
, "BGP neighbor-events debugging is on\n");
760 DEFUN (debug_bgp_neighbor_events_peer
,
761 debug_bgp_neighbor_events_peer_cmd
,
762 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
765 "BGP Neighbor Events\n"
766 "BGP neighbor IP address to debug\n"
767 "BGP IPv6 neighbor to debug\n"
768 "BGP neighbor on interface to debug\n")
771 const char *host
= argv
[idx_peer
]->arg
;
773 if (!bgp_debug_neighbor_events_peers
)
774 bgp_debug_neighbor_events_peers
= list_new();
776 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
779 "BGP neighbor-events debugging is already enabled for %s\n",
784 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
786 if (vty
->node
== CONFIG_NODE
)
787 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
789 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
790 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
796 DEFUN (no_debug_bgp_neighbor_events
,
797 no_debug_bgp_neighbor_events_cmd
,
798 "no debug bgp neighbor-events",
804 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
806 if (vty
->node
== CONFIG_NODE
)
807 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
809 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
810 vty_out(vty
, "BGP neighbor-events debugging is off\n");
815 DEFUN (no_debug_bgp_neighbor_events_peer
,
816 no_debug_bgp_neighbor_events_peer_cmd
,
817 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
822 "BGP neighbor IP address to debug\n"
823 "BGP IPv6 neighbor to debug\n"
824 "BGP neighbor on interface to debug\n")
828 const char *host
= argv
[idx_peer
]->arg
;
830 if (bgp_debug_neighbor_events_peers
831 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
832 found_peer
= bgp_debug_list_remove_entry(
833 bgp_debug_neighbor_events_peers
, host
, NULL
);
835 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
836 if (vty
->node
== CONFIG_NODE
)
837 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
839 TERM_DEBUG_OFF(neighbor_events
,
845 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
849 "BGP neighbor-events debugging was not enabled for %s\n",
856 DEFUN (debug_bgp_nht
,
861 "BGP nexthop tracking events\n")
863 if (vty
->node
== CONFIG_NODE
)
866 TERM_DEBUG_ON(nht
, NHT
);
867 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
872 DEFUN (no_debug_bgp_nht
,
873 no_debug_bgp_nht_cmd
,
878 "BGP nexthop tracking events\n")
880 if (vty
->node
== CONFIG_NODE
)
883 TERM_DEBUG_OFF(nht
, NHT
);
884 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
889 /* debug bgp keepalives */
890 DEFUN (debug_bgp_keepalive
,
891 debug_bgp_keepalive_cmd
,
892 "debug bgp keepalives",
897 bgp_debug_list_free(bgp_debug_keepalive_peers
);
899 if (vty
->node
== CONFIG_NODE
)
900 DEBUG_ON(keepalive
, KEEPALIVE
);
902 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
903 vty_out(vty
, "BGP keepalives debugging is on\n");
908 DEFUN (debug_bgp_keepalive_peer
,
909 debug_bgp_keepalive_peer_cmd
,
910 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
913 "BGP Neighbor Events\n"
914 "BGP neighbor IP address to debug\n"
915 "BGP IPv6 neighbor to debug\n"
916 "BGP neighbor on interface to debug\n")
919 const char *host
= argv
[idx_peer
]->arg
;
921 if (!bgp_debug_keepalive_peers
)
922 bgp_debug_keepalive_peers
= list_new();
924 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
926 "BGP keepalive debugging is already enabled for %s\n",
931 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
933 if (vty
->node
== CONFIG_NODE
)
934 DEBUG_ON(keepalive
, KEEPALIVE
);
936 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
937 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
942 DEFUN (no_debug_bgp_keepalive
,
943 no_debug_bgp_keepalive_cmd
,
944 "no debug bgp keepalives",
950 bgp_debug_list_free(bgp_debug_keepalive_peers
);
952 if (vty
->node
== CONFIG_NODE
)
953 DEBUG_OFF(keepalive
, KEEPALIVE
);
955 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
956 vty_out(vty
, "BGP keepalives debugging is off\n");
961 DEFUN (no_debug_bgp_keepalive_peer
,
962 no_debug_bgp_keepalive_peer_cmd
,
963 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
968 "BGP neighbor IP address to debug\n"
969 "BGP IPv6 neighbor to debug\n"
970 "BGP neighbor on interface to debug\n")
974 const char *host
= argv
[idx_peer
]->arg
;
976 if (bgp_debug_keepalive_peers
977 && !list_isempty(bgp_debug_keepalive_peers
)) {
978 found_peer
= bgp_debug_list_remove_entry(
979 bgp_debug_keepalive_peers
, host
, NULL
);
981 if (list_isempty(bgp_debug_keepalive_peers
)) {
982 if (vty
->node
== CONFIG_NODE
)
983 DEBUG_OFF(keepalive
, KEEPALIVE
);
985 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
990 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
993 "BGP keepalives debugging was not enabled for %s\n",
999 /* debug bgp bestpath */
1000 DEFUN (debug_bgp_bestpath_prefix
,
1001 debug_bgp_bestpath_prefix_cmd
,
1002 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1009 struct prefix
*argv_p
;
1010 int idx_ipv4_ipv6_prefixlen
= 3;
1012 argv_p
= prefix_new();
1013 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1016 if (!bgp_debug_bestpath_prefixes
)
1017 bgp_debug_bestpath_prefixes
= list_new();
1019 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
1022 "BGP bestpath debugging is already enabled for %s\n",
1023 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1027 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1029 if (vty
->node
== CONFIG_NODE
) {
1030 DEBUG_ON(bestpath
, BESTPATH
);
1032 TERM_DEBUG_ON(bestpath
, BESTPATH
);
1033 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
1034 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1040 DEFUN (no_debug_bgp_bestpath_prefix
,
1041 no_debug_bgp_bestpath_prefix_cmd
,
1042 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
1050 int idx_ipv4_ipv6_prefixlen
= 4;
1051 struct prefix
*argv_p
;
1052 int found_prefix
= 0;
1054 argv_p
= prefix_new();
1055 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1058 if (bgp_debug_bestpath_prefixes
1059 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
1060 found_prefix
= bgp_debug_list_remove_entry(
1061 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
1063 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
1064 if (vty
->node
== CONFIG_NODE
) {
1065 DEBUG_OFF(bestpath
, BESTPATH
);
1067 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1069 "BGP bestpath debugging (per prefix) is off\n");
1075 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
1076 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1078 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
1079 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1084 DEFUN (no_debug_bgp_bestpath
,
1085 no_debug_bgp_bestpath_cmd
,
1086 "no debug bgp bestpath",
1092 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1094 if (vty
->node
== CONFIG_NODE
)
1095 DEBUG_OFF(bestpath
, BESTPATH
);
1097 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1098 vty_out(vty
, "BGP bestpath debugging is off\n");
1103 /* debug bgp updates */
1104 DEFUN (debug_bgp_update
,
1105 debug_bgp_update_cmd
,
1106 "debug bgp updates",
1111 bgp_debug_list_free(bgp_debug_update_in_peers
);
1112 bgp_debug_list_free(bgp_debug_update_out_peers
);
1113 bgp_debug_list_free(bgp_debug_update_prefixes
);
1115 if (vty
->node
== CONFIG_NODE
) {
1116 DEBUG_ON(update
, UPDATE_IN
);
1117 DEBUG_ON(update
, UPDATE_OUT
);
1119 TERM_DEBUG_ON(update
, UPDATE_IN
);
1120 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1121 vty_out(vty
, "BGP updates debugging is on\n");
1126 DEFUN (debug_bgp_update_direct
,
1127 debug_bgp_update_direct_cmd
,
1128 "debug bgp updates <in|out>",
1133 "Outbound updates\n")
1137 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1138 bgp_debug_list_free(bgp_debug_update_in_peers
);
1140 bgp_debug_list_free(bgp_debug_update_out_peers
);
1142 if (vty
->node
== CONFIG_NODE
) {
1143 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1144 DEBUG_ON(update
, UPDATE_IN
);
1146 DEBUG_ON(update
, UPDATE_OUT
);
1148 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1149 TERM_DEBUG_ON(update
, UPDATE_IN
);
1150 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1152 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1154 "BGP updates debugging is on (outbound)\n");
1160 DEFUN (debug_bgp_update_direct_peer
,
1161 debug_bgp_update_direct_peer_cmd
,
1162 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1167 "Outbound updates\n"
1168 "BGP neighbor IP address to debug\n"
1169 "BGP IPv6 neighbor to debug\n"
1170 "BGP neighbor on interface to debug\n")
1174 const char *host
= argv
[idx_peer
]->arg
;
1177 if (!bgp_debug_update_in_peers
)
1178 bgp_debug_update_in_peers
= list_new();
1180 if (!bgp_debug_update_out_peers
)
1181 bgp_debug_update_out_peers
= list_new();
1183 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1189 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1192 "BGP inbound update debugging is already enabled for %s\n",
1199 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1202 "BGP outbound update debugging is already enabled for %s\n",
1209 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1212 struct peer_af
*paf
;
1215 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1217 peer
= bgp_find_peer(vty
, host
);
1220 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1222 paf
= peer
->peer_af_array
[afidx
];
1224 if (PAF_SUBGRP(paf
)) {
1234 if (vty
->node
== CONFIG_NODE
) {
1236 DEBUG_ON(update
, UPDATE_IN
);
1238 DEBUG_ON(update
, UPDATE_OUT
);
1241 TERM_DEBUG_ON(update
, UPDATE_IN
);
1243 "BGP updates debugging is on (inbound) for %s\n",
1244 argv
[idx_peer
]->arg
);
1246 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1248 "BGP updates debugging is on (outbound) for %s\n",
1249 argv
[idx_peer
]->arg
);
1255 DEFUN (no_debug_bgp_update_direct
,
1256 no_debug_bgp_update_direct_cmd
,
1257 "no debug bgp updates <in|out>",
1263 "Outbound updates\n")
1266 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1267 bgp_debug_list_free(bgp_debug_update_in_peers
);
1269 if (vty
->node
== CONFIG_NODE
) {
1270 DEBUG_OFF(update
, UPDATE_IN
);
1272 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1274 "BGP updates debugging is off (inbound)\n");
1277 bgp_debug_list_free(bgp_debug_update_out_peers
);
1279 if (vty
->node
== CONFIG_NODE
) {
1280 DEBUG_OFF(update
, UPDATE_OUT
);
1282 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1284 "BGP updates debugging is off (outbound)\n");
1291 DEFUN (no_debug_bgp_update_direct_peer
,
1292 no_debug_bgp_update_direct_peer_cmd
,
1293 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1299 "Outbound updates\n"
1300 "BGP neighbor IP address to debug\n"
1301 "BGP IPv6 neighbor to debug\n"
1302 "BGP neighbor on interface to debug\n")
1308 const char *host
= argv
[idx_peer
]->arg
;
1310 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1315 if (inbound
&& bgp_debug_update_in_peers
1316 && !list_isempty(bgp_debug_update_in_peers
)) {
1317 found_peer
= bgp_debug_list_remove_entry(
1318 bgp_debug_update_in_peers
, host
, NULL
);
1320 if (list_isempty(bgp_debug_update_in_peers
)) {
1321 if (vty
->node
== CONFIG_NODE
)
1322 DEBUG_OFF(update
, UPDATE_IN
);
1324 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1326 "BGP updates debugging (inbound) is off\n");
1331 if (!inbound
&& bgp_debug_update_out_peers
1332 && !list_isempty(bgp_debug_update_out_peers
)) {
1333 found_peer
= bgp_debug_list_remove_entry(
1334 bgp_debug_update_out_peers
, host
, NULL
);
1336 if (list_isempty(bgp_debug_update_out_peers
)) {
1337 if (vty
->node
== CONFIG_NODE
)
1338 DEBUG_OFF(update
, UPDATE_OUT
);
1340 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1342 "BGP updates debugging (outbound) is off\n");
1347 struct peer_af
*paf
;
1349 peer
= bgp_find_peer(vty
, host
);
1352 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1354 paf
= peer
->peer_af_array
[afidx
];
1356 if (PAF_SUBGRP(paf
)) {
1357 UPDGRP_PEER_DBG_DIS(
1369 "BGP updates debugging (inbound) is off for %s\n",
1373 "BGP updates debugging (outbound) is off for %s\n",
1377 "BGP updates debugging (inbound) was not enabled for %s\n",
1381 "BGP updates debugging (outbound) was not enabled for %s\n",
1387 #ifndef VTYSH_EXTRACT_PL
1388 #include "bgpd/bgp_debug_clippy.c"
1391 DEFPY (debug_bgp_update_prefix_afi_safi
,
1392 debug_bgp_update_prefix_afi_safi_cmd
,
1393 "debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
1397 "Specify a prefix to debug\n"
1400 "Specify EVPN Route type\n"
1401 "MAC-IP (Type-2) route\n"
1402 MAC_STR MAC_STR MAC_STR
1406 "Multicast (Type-3) route\n"
1410 "Prefix (Type-5) route\n"
1415 struct prefix
*argv_p
;
1416 int ret
= CMD_SUCCESS
;
1417 char buf
[PREFIX2STR_BUFFER
];
1419 argv_p
= prefix_new();
1421 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1422 if (ret
!= CMD_SUCCESS
) {
1423 prefix_free(&argv_p
);
1427 if (!bgp_debug_update_prefixes
)
1428 bgp_debug_update_prefixes
= list_new();
1430 prefix2str(argv_p
, buf
, sizeof(buf
));
1432 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1434 "BGP updates debugging is already enabled for %s\n",
1436 prefix_free(&argv_p
);
1440 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1442 if (vty
->node
== CONFIG_NODE
) {
1443 DEBUG_ON(update
, UPDATE_PREFIX
);
1445 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1446 vty_out(vty
, "BGP updates debugging is on for %s\n", buf
);
1449 prefix_free(&argv_p
);
1454 DEFPY (no_debug_bgp_update_prefix_afi_safi
,
1455 no_debug_bgp_update_prefix_afi_safi_cmd
,
1456 "no debug bgp updates prefix l2vpn$afi evpn$safi type <macip mac <X:X:X:X:X:X|X:X:X:X:X:X/M> [ip <A.B.C.D|X:X::X:X>]|multicast ip <A.B.C.D|X:X::X:X>|prefix ip <A.B.C.D/M|X:X::X:X/M>>",
1461 "Specify a prefix to debug\n"
1464 "Specify EVPN Route type\n"
1465 "MAC-IP (Type-2) route\n"
1466 MAC_STR MAC_STR MAC_STR
1470 "Multicast (Type-3) route\n"
1474 "Prefix (Type-5) route\n"
1479 struct prefix
*argv_p
;
1480 bool found_prefix
= false;
1481 int ret
= CMD_SUCCESS
;
1482 char buf
[PREFIX2STR_BUFFER
];
1484 argv_p
= prefix_new();
1486 ret
= bgp_debug_parse_evpn_prefix(vty
, argv
, argc
, &argv_p
);
1487 if (ret
!= CMD_SUCCESS
) {
1488 prefix_free(&argv_p
);
1492 if (bgp_debug_update_prefixes
1493 && !list_isempty(bgp_debug_update_prefixes
)) {
1494 found_prefix
= bgp_debug_list_remove_entry(
1495 bgp_debug_update_prefixes
, NULL
, argv_p
);
1497 if (list_isempty(bgp_debug_update_prefixes
)) {
1498 if (vty
->node
== CONFIG_NODE
) {
1499 DEBUG_OFF(update
, UPDATE_PREFIX
);
1501 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1503 "BGP updates debugging (per prefix) is off\n");
1508 prefix2str(argv_p
, buf
, sizeof(buf
));
1511 vty_out(vty
, "BGP updates debugging is off for %s\n", buf
);
1513 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1516 prefix_free(&argv_p
);
1522 DEFUN (debug_bgp_update_prefix
,
1523 debug_bgp_update_prefix_cmd
,
1524 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1528 "Specify a prefix to debug\n"
1532 int idx_ipv4_ipv6_prefixlen
= 4;
1533 struct prefix
*argv_p
;
1535 argv_p
= prefix_new();
1536 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1539 if (!bgp_debug_update_prefixes
)
1540 bgp_debug_update_prefixes
= list_new();
1542 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1544 "BGP updates debugging is already enabled for %s\n",
1545 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1549 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1551 if (vty
->node
== CONFIG_NODE
) {
1552 DEBUG_ON(update
, UPDATE_PREFIX
);
1554 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1555 vty_out(vty
, "BGP updates debugging is on for %s\n",
1556 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1562 DEFUN (no_debug_bgp_update_prefix
,
1563 no_debug_bgp_update_prefix_cmd
,
1564 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1569 "Specify a prefix to debug\n"
1573 int idx_ipv4_ipv6_prefixlen
= 5;
1574 struct prefix
*argv_p
;
1575 int found_prefix
= 0;
1577 argv_p
= prefix_new();
1578 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1581 if (bgp_debug_update_prefixes
1582 && !list_isempty(bgp_debug_update_prefixes
)) {
1583 found_prefix
= bgp_debug_list_remove_entry(
1584 bgp_debug_update_prefixes
, NULL
, argv_p
);
1586 if (list_isempty(bgp_debug_update_prefixes
)) {
1587 if (vty
->node
== CONFIG_NODE
) {
1588 DEBUG_OFF(update
, UPDATE_PREFIX
);
1590 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1592 "BGP updates debugging (per prefix) is off\n");
1598 vty_out(vty
, "BGP updates debugging is off for %s\n",
1599 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1601 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1602 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1607 DEFUN (no_debug_bgp_update
,
1608 no_debug_bgp_update_cmd
,
1609 "no debug bgp updates",
1615 struct listnode
*ln
;
1618 bgp_debug_list_free(bgp_debug_update_in_peers
);
1619 bgp_debug_list_free(bgp_debug_update_out_peers
);
1620 bgp_debug_list_free(bgp_debug_update_prefixes
);
1622 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1623 bgp_debug_clear_updgrp_update_dbg(bgp
);
1625 if (vty
->node
== CONFIG_NODE
) {
1626 DEBUG_OFF(update
, UPDATE_IN
);
1627 DEBUG_OFF(update
, UPDATE_OUT
);
1628 DEBUG_OFF(update
, UPDATE_PREFIX
);
1630 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1631 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1632 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1633 vty_out(vty
, "BGP updates debugging is off\n");
1638 /* debug bgp zebra */
1639 DEFUN (debug_bgp_zebra
,
1640 debug_bgp_zebra_cmd
,
1644 "BGP Zebra messages\n")
1646 if (vty
->node
== CONFIG_NODE
)
1647 DEBUG_ON(zebra
, ZEBRA
);
1649 TERM_DEBUG_ON(zebra
, ZEBRA
);
1650 vty_out(vty
, "BGP zebra debugging is on\n");
1655 DEFUN (debug_bgp_graceful_restart
,
1656 debug_bgp_graceful_restart_cmd
,
1657 "debug bgp graceful-restart",
1662 if (vty
->node
== CONFIG_NODE
) {
1663 DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1665 TERM_DEBUG_ON(graceful_restart
, GRACEFUL_RESTART
);
1666 vty_out(vty
, "BGP Graceful Restart debugging is on\n");
1672 DEFUN (debug_bgp_zebra_prefix
,
1673 debug_bgp_zebra_prefix_cmd
,
1674 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1677 "BGP Zebra messages\n"
1678 "Specify a prefix to debug\n"
1682 int idx_ipv4_ipv6_prefixlen
= 4;
1683 struct prefix
*argv_p
;
1685 argv_p
= prefix_new();
1686 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1689 if (!bgp_debug_zebra_prefixes
)
1690 bgp_debug_zebra_prefixes
= list_new();
1692 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1693 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1694 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1698 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1700 if (vty
->node
== CONFIG_NODE
)
1701 DEBUG_ON(zebra
, ZEBRA
);
1703 TERM_DEBUG_ON(zebra
, ZEBRA
);
1704 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1705 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1711 DEFUN (no_debug_bgp_zebra
,
1712 no_debug_bgp_zebra_cmd
,
1713 "no debug bgp zebra",
1717 "BGP Zebra messages\n")
1719 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1721 if (vty
->node
== CONFIG_NODE
)
1722 DEBUG_OFF(zebra
, ZEBRA
);
1724 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1725 vty_out(vty
, "BGP zebra debugging is off\n");
1730 DEFUN (no_debug_bgp_graceful_restart
,
1731 no_debug_bgp_graceful_restart_cmd
,
1732 "no debug bgp graceful-restart",
1738 if (vty
->node
== CONFIG_NODE
) {
1739 DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1741 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
1742 vty_out(vty
, "BGP Graceful Restart debugging is off\n");
1747 DEFUN (no_debug_bgp_zebra_prefix
,
1748 no_debug_bgp_zebra_prefix_cmd
,
1749 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1753 "BGP Zebra messages\n"
1754 "Specify a prefix to debug\n"
1758 int idx_ipv4_ipv6_prefixlen
= 5;
1759 struct prefix
*argv_p
;
1760 int found_prefix
= 0;
1762 argv_p
= prefix_new();
1763 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1766 if (bgp_debug_zebra_prefixes
1767 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1768 found_prefix
= bgp_debug_list_remove_entry(
1769 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1771 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1772 if (vty
->node
== CONFIG_NODE
)
1773 DEBUG_OFF(zebra
, ZEBRA
);
1775 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1776 vty_out(vty
, "BGP zebra debugging is off\n");
1782 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1783 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1785 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1786 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1791 DEFUN (debug_bgp_allow_martians
,
1792 debug_bgp_allow_martians_cmd
,
1793 "debug bgp allow-martians",
1796 "BGP allow martian next hops\n")
1798 if (vty
->node
== CONFIG_NODE
)
1799 DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1801 TERM_DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1802 vty_out(vty
, "BGP allow_martian next hop debugging is on\n");
1807 DEFUN (no_debug_bgp_allow_martians
,
1808 no_debug_bgp_allow_martians_cmd
,
1809 "no debug bgp allow-martians",
1813 "BGP allow martian next hops\n")
1815 if (vty
->node
== CONFIG_NODE
)
1816 DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1818 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1819 vty_out(vty
, "BGP allow martian next hop debugging is off\n");
1825 /* debug bgp update-groups */
1826 DEFUN (debug_bgp_update_groups
,
1827 debug_bgp_update_groups_cmd
,
1828 "debug bgp update-groups",
1831 "BGP update-groups\n")
1833 if (vty
->node
== CONFIG_NODE
)
1834 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1836 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1837 vty_out(vty
, "BGP update-groups debugging is on\n");
1842 DEFUN (no_debug_bgp_update_groups
,
1843 no_debug_bgp_update_groups_cmd
,
1844 "no debug bgp update-groups",
1848 "BGP update-groups\n")
1850 if (vty
->node
== CONFIG_NODE
)
1851 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1853 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1854 vty_out(vty
, "BGP update-groups debugging is off\n");
1859 DEFUN (debug_bgp_vpn
,
1861 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1865 "leaked from vrf to vpn\n"
1866 "leaked to vrf from vpn\n"
1867 "route-map updates\n"
1872 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1873 if (vty
->node
== CONFIG_NODE
)
1874 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1876 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1877 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1878 if (vty
->node
== CONFIG_NODE
)
1879 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1881 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1882 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1883 if (vty
->node
== CONFIG_NODE
)
1884 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1886 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1887 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1888 if (vty
->node
== CONFIG_NODE
)
1889 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1891 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1893 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1894 return CMD_WARNING_CONFIG_FAILED
;
1897 if (vty
->node
!= CONFIG_NODE
)
1898 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1903 DEFUN (no_debug_bgp_vpn
,
1904 no_debug_bgp_vpn_cmd
,
1905 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1910 "leaked from vrf to vpn\n"
1911 "leaked to vrf from vpn\n"
1912 "route-map updates\n"
1917 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1918 if (vty
->node
== CONFIG_NODE
)
1919 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1921 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1923 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1924 if (vty
->node
== CONFIG_NODE
)
1925 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1927 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1928 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1929 if (vty
->node
== CONFIG_NODE
)
1930 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1932 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1933 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1934 if (vty
->node
== CONFIG_NODE
)
1935 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1937 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1939 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1940 return CMD_WARNING_CONFIG_FAILED
;
1943 if (vty
->node
!= CONFIG_NODE
)
1944 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1949 DEFUN (debug_bgp_pbr
,
1951 "debug bgp pbr [error]",
1954 "BGP policy based routing\n"
1959 if (argv_find(argv
, argc
, "error", &idx
)) {
1960 if (vty
->node
== CONFIG_NODE
)
1961 DEBUG_ON(pbr
, PBR_ERROR
);
1963 TERM_DEBUG_ON(pbr
, PBR_ERROR
);
1964 vty_out(vty
, "BGP policy based routing error is on\n");
1968 if (vty
->node
== CONFIG_NODE
)
1971 TERM_DEBUG_ON(pbr
, PBR
);
1972 vty_out(vty
, "BGP policy based routing is on\n");
1977 DEFUN (no_debug_bgp_pbr
,
1978 no_debug_bgp_pbr_cmd
,
1979 "no debug bgp pbr [error]",
1983 "BGP policy based routing\n"
1988 if (argv_find(argv
, argc
, "error", &idx
)) {
1989 if (vty
->node
== CONFIG_NODE
)
1990 DEBUG_OFF(pbr
, PBR_ERROR
);
1992 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1993 vty_out(vty
, "BGP policy based routing error is off\n");
1997 if (vty
->node
== CONFIG_NODE
)
1998 DEBUG_OFF(pbr
, PBR
);
2000 TERM_DEBUG_OFF(pbr
, PBR
);
2001 vty_out(vty
, "BGP policy based routing is off\n");
2006 DEFUN (debug_bgp_labelpool
,
2007 debug_bgp_labelpool_cmd
,
2008 "debug bgp labelpool",
2013 if (vty
->node
== CONFIG_NODE
)
2014 DEBUG_ON(labelpool
, LABELPOOL
);
2016 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
2018 if (vty
->node
!= CONFIG_NODE
)
2019 vty_out(vty
, "enabled debug bgp labelpool\n");
2024 DEFUN (no_debug_bgp_labelpool
,
2025 no_debug_bgp_labelpool_cmd
,
2026 "no debug bgp labelpool",
2032 if (vty
->node
== CONFIG_NODE
)
2033 DEBUG_OFF(labelpool
, LABELPOOL
);
2035 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2038 if (vty
->node
!= CONFIG_NODE
)
2039 vty_out(vty
, "disabled debug bgp labelpool\n");
2044 DEFUN (no_debug_bgp
,
2052 struct listnode
*ln
;
2054 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
2055 bgp_debug_list_free(bgp_debug_keepalive_peers
);
2056 bgp_debug_list_free(bgp_debug_update_in_peers
);
2057 bgp_debug_list_free(bgp_debug_update_out_peers
);
2058 bgp_debug_list_free(bgp_debug_update_prefixes
);
2059 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
2060 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
2062 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
2063 bgp_debug_clear_updgrp_update_dbg(bgp
);
2065 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
2066 TERM_DEBUG_OFF(update
, UPDATE_IN
);
2067 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
2068 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
2069 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
2070 TERM_DEBUG_OFF(as4
, AS4
);
2071 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
2072 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
2073 TERM_DEBUG_OFF(zebra
, ZEBRA
);
2074 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
2075 TERM_DEBUG_OFF(nht
, NHT
);
2076 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
2077 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
2078 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
2079 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
2080 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
2081 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
2082 TERM_DEBUG_OFF(pbr
, PBR
);
2083 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
2084 TERM_DEBUG_OFF(graceful_restart
, GRACEFUL_RESTART
);
2086 vty_out(vty
, "All possible debugging has been turned off\n");
2091 DEFUN_NOSH (show_debugging_bgp
,
2092 show_debugging_bgp_cmd
,
2093 "show debugging [bgp]",
2098 vty_out(vty
, "BGP debugging status:\n");
2100 if (BGP_DEBUG(as4
, AS4
))
2101 vty_out(vty
, " BGP as4 debugging is on\n");
2103 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
2104 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
2106 if (BGP_DEBUG(bestpath
, BESTPATH
))
2107 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
2108 bgp_debug_bestpath_prefixes
);
2110 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
2111 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
2112 bgp_debug_keepalive_peers
);
2114 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
2115 bgp_debug_list_print(vty
,
2116 " BGP neighbor-events debugging is on",
2117 bgp_debug_neighbor_events_peers
);
2119 if (BGP_DEBUG(nht
, NHT
))
2120 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
2122 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
2123 vty_out(vty
, " BGP update-groups debugging is on\n");
2125 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
2126 bgp_debug_list_print(vty
, " BGP updates debugging is on",
2127 bgp_debug_update_prefixes
);
2129 if (BGP_DEBUG(update
, UPDATE_IN
))
2130 bgp_debug_list_print(vty
,
2131 " BGP updates debugging is on (inbound)",
2132 bgp_debug_update_in_peers
);
2134 if (BGP_DEBUG(update
, UPDATE_OUT
))
2135 bgp_debug_list_print(vty
,
2136 " BGP updates debugging is on (outbound)",
2137 bgp_debug_update_out_peers
);
2139 if (BGP_DEBUG(zebra
, ZEBRA
))
2140 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
2141 bgp_debug_zebra_prefixes
);
2143 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2144 vty_out(vty
, " BGP graceful-restart debugging is on");
2146 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
2147 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
2149 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
2151 " BGP route leak from vrf to vpn debugging is on\n");
2152 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
2154 " BGP route leak to vrf from vpn debugging is on\n");
2155 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
2156 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
2157 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
2158 vty_out(vty
, " BGP vpn label event debugging is on\n");
2159 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
2160 vty_out(vty
, " BGP flowspec debugging is on\n");
2161 if (BGP_DEBUG(labelpool
, LABELPOOL
))
2162 vty_out(vty
, " BGP labelpool debugging is on\n");
2164 if (BGP_DEBUG(pbr
, PBR
))
2165 vty_out(vty
, " BGP policy based routing debugging is on\n");
2166 if (BGP_DEBUG(pbr
, PBR_ERROR
))
2167 vty_out(vty
, " BGP policy based routing error debugging is on\n");
2173 static int bgp_config_write_debug(struct vty
*vty
)
2177 if (CONF_BGP_DEBUG(as4
, AS4
)) {
2178 vty_out(vty
, "debug bgp as4\n");
2182 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
2183 vty_out(vty
, "debug bgp as4 segment\n");
2187 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
2188 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
2189 bgp_debug_bestpath_prefixes
);
2192 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
2193 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
2194 bgp_debug_keepalive_peers
);
2197 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
2198 write
+= bgp_debug_list_conf_print(
2199 vty
, "debug bgp neighbor-events",
2200 bgp_debug_neighbor_events_peers
);
2203 if (CONF_BGP_DEBUG(nht
, NHT
)) {
2204 vty_out(vty
, "debug bgp nht\n");
2208 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
2209 vty_out(vty
, "debug bgp update-groups\n");
2213 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2214 write
+= bgp_debug_list_conf_print(vty
,
2215 "debug bgp updates prefix",
2216 bgp_debug_update_prefixes
);
2219 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
2220 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
2221 bgp_debug_update_in_peers
);
2224 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
2225 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
2226 bgp_debug_update_out_peers
);
2229 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
2230 if (!bgp_debug_zebra_prefixes
2231 || list_isempty(bgp_debug_zebra_prefixes
)) {
2232 vty_out(vty
, "debug bgp zebra\n");
2235 write
+= bgp_debug_list_conf_print(
2236 vty
, "debug bgp zebra prefix",
2237 bgp_debug_zebra_prefixes
);
2241 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
2242 vty_out(vty
, "debug bgp allow-martians\n");
2246 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
2247 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
2250 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
2251 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
2254 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
2255 vty_out(vty
, "debug bgp vpn rmap-event\n");
2258 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
2259 vty_out(vty
, "debug bgp vpn label\n");
2262 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
2263 vty_out(vty
, "debug bgp flowspec\n");
2266 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
2267 vty_out(vty
, "debug bgp labelpool\n");
2271 if (CONF_BGP_DEBUG(pbr
, PBR
)) {
2272 vty_out(vty
, "debug bgp pbr\n");
2275 if (CONF_BGP_DEBUG(pbr
, PBR_ERROR
)) {
2276 vty_out(vty
, "debug bgp pbr error\n");
2280 if (CONF_BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
)) {
2281 vty_out(vty
, "debug bgp graceful-restart\n");
2287 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
2289 void bgp_debug_init(void)
2291 install_node(&debug_node
, bgp_config_write_debug
);
2293 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
2295 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
2296 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
2297 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
2298 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
2300 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
2301 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
2302 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
2303 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
2304 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
2305 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
2306 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
2307 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
2308 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
2309 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
2310 install_element(ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
2311 install_element(CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
2312 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
2313 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
2314 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2315 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2317 install_element(ENABLE_NODE
, &debug_bgp_graceful_restart_cmd
);
2318 install_element(CONFIG_NODE
, &debug_bgp_graceful_restart_cmd
);
2320 /* debug bgp updates (in|out) */
2321 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2322 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2323 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2324 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2326 /* debug bgp updates (in|out) A.B.C.D */
2327 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2328 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2329 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2330 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2332 /* debug bgp updates prefix A.B.C.D/M */
2333 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2334 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2335 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2336 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2337 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2338 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_afi_safi_cmd
);
2339 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2340 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_afi_safi_cmd
);
2342 /* debug bgp zebra prefix A.B.C.D/M */
2343 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2344 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2345 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2346 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2348 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2349 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2350 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2351 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2353 /* debug bgp neighbor-events A.B.C.D */
2354 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2355 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2356 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2357 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2359 /* debug bgp keepalive A.B.C.D */
2360 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2361 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2362 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2363 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2365 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2366 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2367 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2368 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2369 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2370 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2371 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2372 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2373 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2374 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2375 install_element(ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
2376 install_element(CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
2377 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2378 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2379 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2380 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2381 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2382 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2383 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2385 install_element(ENABLE_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2386 install_element(CONFIG_NODE
, &no_debug_bgp_graceful_restart_cmd
);
2388 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2389 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2390 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2391 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2393 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2394 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2395 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2396 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2399 install_element(ENABLE_NODE
, &debug_bgp_pbr_cmd
);
2400 install_element(CONFIG_NODE
, &debug_bgp_pbr_cmd
);
2401 install_element(ENABLE_NODE
, &no_debug_bgp_pbr_cmd
);
2402 install_element(CONFIG_NODE
, &no_debug_bgp_pbr_cmd
);
2406 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2407 * for BGP_DEBUG_TYPE
2409 static int bgp_debug_per_prefix(struct prefix
*p
,
2410 unsigned long term_bgp_debug_type
,
2411 unsigned int BGP_DEBUG_TYPE
,
2412 struct list
*per_prefix_list
)
2414 struct bgp_debug_filter
*filter
;
2415 struct listnode
*node
, *nnode
;
2417 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2418 /* We are debugging all prefixes so return true */
2419 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2426 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2428 if (filter
->p
->prefixlen
== p
->prefixlen
2429 && prefix_match(filter
->p
, p
))
2439 /* Return true if this peer is on the per_peer_list of peers to debug
2440 * for BGP_DEBUG_TYPE
2442 static int bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2443 unsigned int BGP_DEBUG_TYPE
,
2444 struct list
*per_peer_list
)
2446 struct bgp_debug_filter
*filter
;
2447 struct listnode
*node
, *nnode
;
2449 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2450 /* We are debugging all peers so return true */
2451 if (!per_peer_list
|| list_isempty(per_peer_list
))
2458 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2460 if (strcmp(filter
->host
, host
) == 0)
2470 int bgp_debug_neighbor_events(struct peer
*peer
)
2477 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2478 BGP_DEBUG_NEIGHBOR_EVENTS
,
2479 bgp_debug_neighbor_events_peers
);
2482 int bgp_debug_keepalive(struct peer
*peer
)
2489 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2490 BGP_DEBUG_KEEPALIVE
,
2491 bgp_debug_keepalive_peers
);
2494 int bgp_debug_update(struct peer
*peer
, struct prefix
*p
,
2495 struct update_group
*updgrp
, unsigned int inbound
)
2503 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2504 BGP_DEBUG_UPDATE_IN
,
2505 bgp_debug_update_in_peers
))
2511 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2512 BGP_DEBUG_UPDATE_OUT
,
2513 bgp_debug_update_out_peers
))
2516 /* Check if update debugging implicitly enabled for the group.
2518 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2523 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2524 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2525 BGP_DEBUG_UPDATE_PREFIX
,
2526 bgp_debug_update_prefixes
))
2533 int bgp_debug_bestpath(struct prefix
*p
)
2535 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2536 if (bgp_debug_per_prefix(p
, term_bgp_debug_bestpath
,
2538 bgp_debug_bestpath_prefixes
))
2545 int bgp_debug_zebra(struct prefix
*p
)
2547 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2548 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2550 bgp_debug_zebra_prefixes
))
2557 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2558 struct prefix_rd
*prd
,
2559 union prefixconstptr pu
,
2560 mpls_label_t
*label
, uint32_t num_labels
,
2561 int addpath_valid
, uint32_t addpath_id
,
2562 char *str
, int size
)
2564 char rd_buf
[RD_ADDRSTRLEN
];
2565 char pfx_buf
[PREFIX_STRLEN
];
2567 /* ' with addpath ID ' 17
2568 * max strlen of uint32 + 10
2569 * +/- (just in case) + 1
2570 * null terminator + 1
2571 * ============================ 29 */
2572 char pathid_buf
[30];
2574 if (size
< BGP_PRD_PATH_STRLEN
)
2577 /* Note: Path-id is created by default, but only included in update
2579 pathid_buf
[0] = '\0';
2581 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2585 if (bgp_labeled_safi(safi
) && num_labels
) {
2587 if (safi
== SAFI_EVPN
) {
2590 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2591 sprintf(tag_buf
, " label %s", tag_buf2
);
2593 uint32_t label_value
;
2595 label_value
= decode_label(label
);
2596 sprintf(tag_buf
, " label %u", label_value
);
2601 snprintf(str
, size
, "RD %s %s%s%s %s %s",
2602 prefix_rd2str(prd
, rd_buf
, sizeof(rd_buf
)),
2603 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2604 pathid_buf
, afi2str(afi
), safi2str(safi
));
2605 else if (safi
== SAFI_FLOWSPEC
) {
2606 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2607 const struct prefix_fs
*fs
= pu
.fs
;
2609 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2610 fs
->prefix
.prefixlen
,
2612 NLRI_STRING_FORMAT_DEBUG
, NULL
);
2613 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2616 snprintf(str
, size
, "%s%s%s %s %s",
2617 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2618 pathid_buf
, afi2str(afi
), safi2str(safi
));