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_flowspec.h"
47 unsigned long conf_bgp_debug_as4
;
48 unsigned long conf_bgp_debug_neighbor_events
;
49 unsigned long conf_bgp_debug_events
;
50 unsigned long conf_bgp_debug_packet
;
51 unsigned long conf_bgp_debug_filter
;
52 unsigned long conf_bgp_debug_keepalive
;
53 unsigned long conf_bgp_debug_update
;
54 unsigned long conf_bgp_debug_bestpath
;
55 unsigned long conf_bgp_debug_zebra
;
56 unsigned long conf_bgp_debug_allow_martians
;
57 unsigned long conf_bgp_debug_nht
;
58 unsigned long conf_bgp_debug_update_groups
;
59 unsigned long conf_bgp_debug_vpn
;
60 unsigned long conf_bgp_debug_flowspec
;
61 unsigned long conf_bgp_debug_labelpool
;
62 unsigned long conf_bgp_debug_pbr
;
64 unsigned long term_bgp_debug_as4
;
65 unsigned long term_bgp_debug_neighbor_events
;
66 unsigned long term_bgp_debug_events
;
67 unsigned long term_bgp_debug_packet
;
68 unsigned long term_bgp_debug_filter
;
69 unsigned long term_bgp_debug_keepalive
;
70 unsigned long term_bgp_debug_update
;
71 unsigned long term_bgp_debug_bestpath
;
72 unsigned long term_bgp_debug_zebra
;
73 unsigned long term_bgp_debug_allow_martians
;
74 unsigned long term_bgp_debug_nht
;
75 unsigned long term_bgp_debug_update_groups
;
76 unsigned long term_bgp_debug_vpn
;
77 unsigned long term_bgp_debug_flowspec
;
78 unsigned long term_bgp_debug_labelpool
;
79 unsigned long term_bgp_debug_pbr
;
81 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
82 struct list
*bgp_debug_keepalive_peers
= NULL
;
83 struct list
*bgp_debug_update_out_peers
= NULL
;
84 struct list
*bgp_debug_update_in_peers
= NULL
;
85 struct list
*bgp_debug_update_prefixes
= NULL
;
86 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
87 struct list
*bgp_debug_zebra_prefixes
= NULL
;
89 /* messages for BGP-4 status */
90 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
93 {OpenSent
, "OpenSent"},
94 {OpenConfirm
, "OpenConfirm"},
95 {Established
, "Established"},
96 {Clearing
, "Clearing"},
100 /* BGP message type string. */
101 const char *bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
102 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
105 /* message for BGP-4 Notify */
106 static const struct message bgp_notify_msg
[] = {
107 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
108 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
109 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
110 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
111 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
112 {BGP_NOTIFY_CEASE
, "Cease"},
113 {BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
116 static const struct message bgp_notify_head_msg
[] = {
117 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
118 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
119 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
122 static const struct message bgp_notify_open_msg
[] = {
123 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
124 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
125 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
126 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
127 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
128 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
129 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
130 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
133 static const struct message bgp_notify_update_msg
[] = {
134 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
135 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
136 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
137 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
138 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
139 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
140 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
141 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
142 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
143 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
144 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
145 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
148 static const struct message bgp_notify_cease_msg
[] = {
149 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
150 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
151 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
152 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
153 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
154 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
155 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
156 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
157 "/Connection collision resolution"},
158 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
161 static const struct message bgp_notify_capability_msg
[] = {
162 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
163 {BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value"},
164 {BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
165 {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
168 /* Origin strings. */
169 const char *bgp_origin_str
[] = {"i", "e", "?"};
170 const char *bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
172 /* Given a string return a pointer the corresponding peer structure */
173 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
175 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
183 ret
= str2sockunion(peer_str
, &su
);
187 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
190 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
194 return peer_lookup(bgp
, &su
);
197 static void bgp_debug_list_free(struct list
*list
)
199 struct bgp_debug_filter
*filter
;
200 struct listnode
*node
, *nnode
;
203 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
204 listnode_delete(list
, filter
);
207 prefix_free(filter
->p
);
210 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
212 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
216 /* Print the desc along with a list of peers/prefixes this debug is
218 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
221 struct bgp_debug_filter
*filter
;
222 struct listnode
*node
, *nnode
;
223 char buf
[INET6_ADDRSTRLEN
];
225 vty_out(vty
, "%s", desc
);
227 if (list
&& !list_isempty(list
)) {
228 vty_out(vty
, " for");
229 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
231 vty_out(vty
, " %s", filter
->host
);
234 vty_out(vty
, " %s/%d",
235 inet_ntop(filter
->p
->family
,
236 &filter
->p
->u
.prefix
, buf
,
238 filter
->p
->prefixlen
);
245 /* Print the command to enable the debug for each peer/prefix this debug is
248 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
251 struct bgp_debug_filter
*filter
;
252 struct listnode
*node
, *nnode
;
253 char buf
[INET6_ADDRSTRLEN
];
256 if (list
&& !list_isempty(list
)) {
257 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
259 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
265 vty_out(vty
, "%s %s/%d\n", desc
,
266 inet_ntop(filter
->p
->family
,
267 &filter
->p
->u
.prefix
, buf
,
269 filter
->p
->prefixlen
);
276 vty_out(vty
, "%s\n", desc
);
283 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
284 const struct prefix
*p
)
286 struct bgp_debug_filter
*filter
;
288 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
289 sizeof(struct bgp_debug_filter
));
292 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
296 filter
->p
= prefix_new();
297 prefix_copy(filter
->p
, p
);
300 listnode_add(list
, filter
);
303 static int bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
306 struct bgp_debug_filter
*filter
;
307 struct listnode
*node
, *nnode
;
309 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
310 if (host
&& strcmp(filter
->host
, host
) == 0) {
311 listnode_delete(list
, filter
);
312 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
313 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
315 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
316 && prefix_match(filter
->p
, p
)) {
317 listnode_delete(list
, filter
);
318 prefix_free(filter
->p
);
319 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
327 static int bgp_debug_list_has_entry(struct list
*list
, const char *host
,
328 const struct prefix
*p
)
330 struct bgp_debug_filter
*filter
;
331 struct listnode
*node
, *nnode
;
333 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
335 if (strcmp(filter
->host
, host
) == 0) {
339 if (filter
->p
->prefixlen
== p
->prefixlen
340 && prefix_match(filter
->p
, p
)) {
349 int bgp_debug_peer_updout_enabled(char *host
)
351 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
355 /* Dump attribute. */
356 int bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
358 char addrbuf
[BUFSIZ
];
363 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
364 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
366 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
367 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
368 bgp_origin_str
[attr
->origin
]);
371 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
372 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
373 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
375 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
378 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
379 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
380 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
383 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
384 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
386 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
387 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
388 ", localpref %u", attr
->local_pref
);
390 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
391 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
394 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
395 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
397 community_str(attr
->community
, false));
399 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
400 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
401 ", extcommunity %s", ecommunity_str(attr
->ecommunity
));
403 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
404 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
405 ", atomic-aggregate");
407 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
408 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
409 ", aggregated by %u %s", attr
->aggregator_as
,
410 inet_ntoa(attr
->aggregator_addr
));
412 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
413 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
414 ", originator %s", inet_ntoa(attr
->originator_id
));
416 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
419 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
421 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
422 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), " %s",
423 inet_ntoa(attr
->cluster
->list
[i
]));
426 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
427 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
428 ", pmsi tnltype %u", attr
->pmsi_tnl_type
);
430 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
431 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
432 aspath_print(attr
->aspath
));
434 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
435 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
436 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
437 ", label-index %u", attr
->label_index
);
446 const char *bgp_notify_code_str(char code
)
448 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
451 const char *bgp_notify_subcode_str(char code
, char subcode
)
455 case BGP_NOTIFY_HEADER_ERR
:
456 return lookup_msg(bgp_notify_head_msg
, subcode
,
457 "Unrecognized Error Subcode");
458 case BGP_NOTIFY_OPEN_ERR
:
459 return lookup_msg(bgp_notify_open_msg
, subcode
,
460 "Unrecognized Error Subcode");
461 case BGP_NOTIFY_UPDATE_ERR
:
462 return lookup_msg(bgp_notify_update_msg
, subcode
,
463 "Unrecognized Error Subcode");
464 case BGP_NOTIFY_HOLD_ERR
:
466 case BGP_NOTIFY_FSM_ERR
:
468 case BGP_NOTIFY_CEASE
:
469 return lookup_msg(bgp_notify_cease_msg
, subcode
,
470 "Unrecognized Error Subcode");
471 case BGP_NOTIFY_CAPABILITY_ERR
:
472 return lookup_msg(bgp_notify_capability_msg
, subcode
,
473 "Unrecognized Error Subcode");
478 /* extract notify admin reason if correctly present */
479 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, uint8_t *data
,
482 if (!data
|| datalen
< 1)
485 uint8_t len
= data
[0];
486 if (len
> 128 || len
> datalen
- 1)
489 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
492 /* dump notify packet */
493 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
496 const char *subcode_str
;
497 const char *code_str
;
498 const char *msg_str
= NULL
;
501 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
502 || bgp_flag_check(peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
503 code_str
= bgp_notify_code_str(bgp_notify
->code
);
504 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
505 bgp_notify
->subcode
);
507 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
508 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
509 || bgp_notify
->subcode
510 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
511 msg_str
= bgp_notify_admin_message(
512 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
518 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) \"%s\"",
519 strcmp(direct
, "received") == 0
522 peer
->host
, bgp_notify
->code
,
523 bgp_notify
->subcode
, code_str
, subcode_str
,
526 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
528 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
529 strcmp(direct
, "received") == 0
532 peer
->host
, bgp_notify
->code
,
533 bgp_notify
->subcode
, code_str
, subcode_str
,
534 bgp_notify
->length
, msg_str
);
539 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
542 bgp
= bgp_get_default();
543 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
547 /* Debug option setting interface. */
548 unsigned long bgp_debug_option
= 0;
550 int debug(unsigned int option
)
552 return bgp_debug_option
& option
;
555 DEFUN (debug_bgp_as4
,
562 if (vty
->node
== CONFIG_NODE
)
565 TERM_DEBUG_ON(as4
, AS4
);
566 vty_out(vty
, "BGP as4 debugging is on\n");
571 DEFUN (no_debug_bgp_as4
,
572 no_debug_bgp_as4_cmd
,
579 if (vty
->node
== CONFIG_NODE
)
582 TERM_DEBUG_OFF(as4
, AS4
);
583 vty_out(vty
, "BGP as4 debugging is off\n");
588 DEFUN (debug_bgp_as4_segment
,
589 debug_bgp_as4_segment_cmd
,
590 "debug bgp as4 segment",
594 "BGP AS4 aspath segment handling\n")
596 if (vty
->node
== CONFIG_NODE
)
597 DEBUG_ON(as4
, AS4_SEGMENT
);
599 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
600 vty_out(vty
, "BGP as4 segment debugging is on\n");
605 DEFUN (no_debug_bgp_as4_segment
,
606 no_debug_bgp_as4_segment_cmd
,
607 "no debug bgp as4 segment",
612 "BGP AS4 aspath segment handling\n")
614 if (vty
->node
== CONFIG_NODE
)
615 DEBUG_OFF(as4
, AS4_SEGMENT
);
617 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
618 vty_out(vty
, "BGP as4 segment debugging is off\n");
623 /* debug bgp neighbor_events */
624 DEFUN (debug_bgp_neighbor_events
,
625 debug_bgp_neighbor_events_cmd
,
626 "debug bgp neighbor-events",
629 "BGP Neighbor Events\n")
631 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
633 if (vty
->node
== CONFIG_NODE
)
634 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
636 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
637 vty_out(vty
, "BGP neighbor-events debugging is on\n");
642 DEFUN (debug_bgp_neighbor_events_peer
,
643 debug_bgp_neighbor_events_peer_cmd
,
644 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
647 "BGP Neighbor Events\n"
648 "BGP neighbor IP address to debug\n"
649 "BGP IPv6 neighbor to debug\n"
650 "BGP neighbor on interface to debug\n")
653 const char *host
= argv
[idx_peer
]->arg
;
655 if (!bgp_debug_neighbor_events_peers
)
656 bgp_debug_neighbor_events_peers
= list_new();
658 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
661 "BGP neighbor-events debugging is already enabled for %s\n",
666 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
668 if (vty
->node
== CONFIG_NODE
)
669 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
671 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
672 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
678 DEFUN (no_debug_bgp_neighbor_events
,
679 no_debug_bgp_neighbor_events_cmd
,
680 "no debug bgp neighbor-events",
686 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
688 if (vty
->node
== CONFIG_NODE
)
689 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
691 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
692 vty_out(vty
, "BGP neighbor-events debugging is off\n");
697 DEFUN (no_debug_bgp_neighbor_events_peer
,
698 no_debug_bgp_neighbor_events_peer_cmd
,
699 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
704 "BGP neighbor IP address to debug\n"
705 "BGP IPv6 neighbor to debug\n"
706 "BGP neighbor on interface to debug\n")
710 const char *host
= argv
[idx_peer
]->arg
;
712 if (bgp_debug_neighbor_events_peers
713 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
714 found_peer
= bgp_debug_list_remove_entry(
715 bgp_debug_neighbor_events_peers
, host
, NULL
);
717 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
718 if (vty
->node
== CONFIG_NODE
)
719 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
721 TERM_DEBUG_OFF(neighbor_events
,
727 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
731 "BGP neighbor-events debugging was not enabled for %s\n",
738 DEFUN (debug_bgp_nht
,
743 "BGP nexthop tracking events\n")
745 if (vty
->node
== CONFIG_NODE
)
748 TERM_DEBUG_ON(nht
, NHT
);
749 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
754 DEFUN (no_debug_bgp_nht
,
755 no_debug_bgp_nht_cmd
,
760 "BGP nexthop tracking events\n")
762 if (vty
->node
== CONFIG_NODE
)
765 TERM_DEBUG_OFF(nht
, NHT
);
766 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
771 /* debug bgp keepalives */
772 DEFUN (debug_bgp_keepalive
,
773 debug_bgp_keepalive_cmd
,
774 "debug bgp keepalives",
779 bgp_debug_list_free(bgp_debug_keepalive_peers
);
781 if (vty
->node
== CONFIG_NODE
)
782 DEBUG_ON(keepalive
, KEEPALIVE
);
784 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
785 vty_out(vty
, "BGP keepalives debugging is on\n");
790 DEFUN (debug_bgp_keepalive_peer
,
791 debug_bgp_keepalive_peer_cmd
,
792 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
795 "BGP Neighbor Events\n"
796 "BGP neighbor IP address to debug\n"
797 "BGP IPv6 neighbor to debug\n"
798 "BGP neighbor on interface to debug\n")
801 const char *host
= argv
[idx_peer
]->arg
;
803 if (!bgp_debug_keepalive_peers
)
804 bgp_debug_keepalive_peers
= list_new();
806 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
808 "BGP keepalive debugging is already enabled for %s\n",
813 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
815 if (vty
->node
== CONFIG_NODE
)
816 DEBUG_ON(keepalive
, KEEPALIVE
);
818 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
819 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
824 DEFUN (no_debug_bgp_keepalive
,
825 no_debug_bgp_keepalive_cmd
,
826 "no debug bgp keepalives",
832 bgp_debug_list_free(bgp_debug_keepalive_peers
);
834 if (vty
->node
== CONFIG_NODE
)
835 DEBUG_OFF(keepalive
, KEEPALIVE
);
837 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
838 vty_out(vty
, "BGP keepalives debugging is off\n");
843 DEFUN (no_debug_bgp_keepalive_peer
,
844 no_debug_bgp_keepalive_peer_cmd
,
845 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
850 "BGP neighbor IP address to debug\n"
851 "BGP IPv6 neighbor to debug\n"
852 "BGP neighbor on interface to debug\n")
856 const char *host
= argv
[idx_peer
]->arg
;
858 if (bgp_debug_keepalive_peers
859 && !list_isempty(bgp_debug_keepalive_peers
)) {
860 found_peer
= bgp_debug_list_remove_entry(
861 bgp_debug_keepalive_peers
, host
, NULL
);
863 if (list_isempty(bgp_debug_keepalive_peers
)) {
864 if (vty
->node
== CONFIG_NODE
)
865 DEBUG_OFF(keepalive
, KEEPALIVE
);
867 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
872 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
875 "BGP keepalives debugging was not enabled for %s\n",
881 /* debug bgp bestpath */
882 DEFUN (debug_bgp_bestpath_prefix
,
883 debug_bgp_bestpath_prefix_cmd
,
884 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
891 struct prefix
*argv_p
;
892 int idx_ipv4_ipv6_prefixlen
= 3;
894 argv_p
= prefix_new();
895 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
898 if (!bgp_debug_bestpath_prefixes
)
899 bgp_debug_bestpath_prefixes
= list_new();
901 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
904 "BGP bestpath debugging is already enabled for %s\n",
905 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
909 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
911 if (vty
->node
== CONFIG_NODE
) {
912 DEBUG_ON(bestpath
, BESTPATH
);
914 TERM_DEBUG_ON(bestpath
, BESTPATH
);
915 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
916 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
922 DEFUN (no_debug_bgp_bestpath_prefix
,
923 no_debug_bgp_bestpath_prefix_cmd
,
924 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
932 int idx_ipv4_ipv6_prefixlen
= 4;
933 struct prefix
*argv_p
;
934 int found_prefix
= 0;
936 argv_p
= prefix_new();
937 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
940 if (bgp_debug_bestpath_prefixes
941 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
942 found_prefix
= bgp_debug_list_remove_entry(
943 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
945 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
946 if (vty
->node
== CONFIG_NODE
) {
947 DEBUG_OFF(bestpath
, BESTPATH
);
949 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
951 "BGP bestpath debugging (per prefix) is off\n");
957 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
958 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
960 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
961 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
966 DEFUN (no_debug_bgp_bestpath
,
967 no_debug_bgp_bestpath_cmd
,
968 "no debug bgp bestpath",
974 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
976 if (vty
->node
== CONFIG_NODE
)
977 DEBUG_OFF(bestpath
, BESTPATH
);
979 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
980 vty_out(vty
, "BGP bestpath debugging is off\n");
985 /* debug bgp updates */
986 DEFUN (debug_bgp_update
,
987 debug_bgp_update_cmd
,
993 bgp_debug_list_free(bgp_debug_update_in_peers
);
994 bgp_debug_list_free(bgp_debug_update_out_peers
);
995 bgp_debug_list_free(bgp_debug_update_prefixes
);
997 if (vty
->node
== CONFIG_NODE
) {
998 DEBUG_ON(update
, UPDATE_IN
);
999 DEBUG_ON(update
, UPDATE_OUT
);
1001 TERM_DEBUG_ON(update
, UPDATE_IN
);
1002 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1003 vty_out(vty
, "BGP updates debugging is on\n");
1008 DEFUN (debug_bgp_update_direct
,
1009 debug_bgp_update_direct_cmd
,
1010 "debug bgp updates <in|out>",
1015 "Outbound updates\n")
1019 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1020 bgp_debug_list_free(bgp_debug_update_in_peers
);
1022 bgp_debug_list_free(bgp_debug_update_out_peers
);
1024 if (vty
->node
== CONFIG_NODE
) {
1025 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1026 DEBUG_ON(update
, UPDATE_IN
);
1028 DEBUG_ON(update
, UPDATE_OUT
);
1030 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1031 TERM_DEBUG_ON(update
, UPDATE_IN
);
1032 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1034 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1036 "BGP updates debugging is on (outbound)\n");
1042 DEFUN (debug_bgp_update_direct_peer
,
1043 debug_bgp_update_direct_peer_cmd
,
1044 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1049 "Outbound updates\n"
1050 "BGP neighbor IP address to debug\n"
1051 "BGP IPv6 neighbor to debug\n"
1052 "BGP neighbor on interface to debug\n")
1056 const char *host
= argv
[idx_peer
]->arg
;
1059 if (!bgp_debug_update_in_peers
)
1060 bgp_debug_update_in_peers
= list_new();
1062 if (!bgp_debug_update_out_peers
)
1063 bgp_debug_update_out_peers
= list_new();
1065 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1071 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1074 "BGP inbound update debugging is already enabled for %s\n",
1081 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1084 "BGP outbound update debugging is already enabled for %s\n",
1091 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1094 struct peer_af
*paf
;
1097 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1099 peer
= bgp_find_peer(vty
, host
);
1102 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1104 paf
= peer
->peer_af_array
[afidx
];
1106 if (PAF_SUBGRP(paf
)) {
1116 if (vty
->node
== CONFIG_NODE
) {
1118 DEBUG_ON(update
, UPDATE_IN
);
1120 DEBUG_ON(update
, UPDATE_OUT
);
1123 TERM_DEBUG_ON(update
, UPDATE_IN
);
1125 "BGP updates debugging is on (inbound) for %s\n",
1126 argv
[idx_peer
]->arg
);
1128 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1130 "BGP updates debugging is on (outbound) for %s\n",
1131 argv
[idx_peer
]->arg
);
1137 DEFUN (no_debug_bgp_update_direct
,
1138 no_debug_bgp_update_direct_cmd
,
1139 "no debug bgp updates <in|out>",
1145 "Outbound updates\n")
1148 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1149 bgp_debug_list_free(bgp_debug_update_in_peers
);
1151 if (vty
->node
== CONFIG_NODE
) {
1152 DEBUG_OFF(update
, UPDATE_IN
);
1154 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1156 "BGP updates debugging is off (inbound)\n");
1159 bgp_debug_list_free(bgp_debug_update_out_peers
);
1161 if (vty
->node
== CONFIG_NODE
) {
1162 DEBUG_OFF(update
, UPDATE_OUT
);
1164 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1166 "BGP updates debugging is off (outbound)\n");
1173 DEFUN (no_debug_bgp_update_direct_peer
,
1174 no_debug_bgp_update_direct_peer_cmd
,
1175 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1181 "Outbound updates\n"
1182 "BGP neighbor IP address to debug\n"
1183 "BGP IPv6 neighbor to debug\n"
1184 "BGP neighbor on interface to debug\n")
1190 const char *host
= argv
[idx_peer
]->arg
;
1192 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1197 if (inbound
&& bgp_debug_update_in_peers
1198 && !list_isempty(bgp_debug_update_in_peers
)) {
1199 found_peer
= bgp_debug_list_remove_entry(
1200 bgp_debug_update_in_peers
, host
, NULL
);
1202 if (list_isempty(bgp_debug_update_in_peers
)) {
1203 if (vty
->node
== CONFIG_NODE
)
1204 DEBUG_OFF(update
, UPDATE_IN
);
1206 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1208 "BGP updates debugging (inbound) is off\n");
1213 if (!inbound
&& bgp_debug_update_out_peers
1214 && !list_isempty(bgp_debug_update_out_peers
)) {
1215 found_peer
= bgp_debug_list_remove_entry(
1216 bgp_debug_update_out_peers
, host
, NULL
);
1218 if (list_isempty(bgp_debug_update_out_peers
)) {
1219 if (vty
->node
== CONFIG_NODE
)
1220 DEBUG_OFF(update
, UPDATE_OUT
);
1222 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1224 "BGP updates debugging (outbound) is off\n");
1229 struct peer_af
*paf
;
1231 peer
= bgp_find_peer(vty
, host
);
1234 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1236 paf
= peer
->peer_af_array
[afidx
];
1238 if (PAF_SUBGRP(paf
)) {
1239 UPDGRP_PEER_DBG_DIS(
1251 "BGP updates debugging (inbound) is off for %s\n",
1255 "BGP updates debugging (outbound) is off for %s\n",
1259 "BGP updates debugging (inbound) was not enabled for %s\n",
1263 "BGP updates debugging (outbound) was not enabled for %s\n",
1269 DEFUN (debug_bgp_update_prefix
,
1270 debug_bgp_update_prefix_cmd
,
1271 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1275 "Specify a prefix to debug\n"
1279 int idx_ipv4_ipv6_prefixlen
= 4;
1280 struct prefix
*argv_p
;
1282 argv_p
= prefix_new();
1283 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1286 if (!bgp_debug_update_prefixes
)
1287 bgp_debug_update_prefixes
= list_new();
1289 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1291 "BGP updates debugging is already enabled for %s\n",
1292 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1296 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1298 if (vty
->node
== CONFIG_NODE
) {
1299 DEBUG_ON(update
, UPDATE_PREFIX
);
1301 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1302 vty_out(vty
, "BGP updates debugging is on for %s\n",
1303 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1309 DEFUN (no_debug_bgp_update_prefix
,
1310 no_debug_bgp_update_prefix_cmd
,
1311 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1316 "Specify a prefix to debug\n"
1320 int idx_ipv4_ipv6_prefixlen
= 5;
1321 struct prefix
*argv_p
;
1322 int found_prefix
= 0;
1324 argv_p
= prefix_new();
1325 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1328 if (bgp_debug_update_prefixes
1329 && !list_isempty(bgp_debug_update_prefixes
)) {
1330 found_prefix
= bgp_debug_list_remove_entry(
1331 bgp_debug_update_prefixes
, NULL
, argv_p
);
1333 if (list_isempty(bgp_debug_update_prefixes
)) {
1334 if (vty
->node
== CONFIG_NODE
) {
1335 DEBUG_OFF(update
, UPDATE_PREFIX
);
1337 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1339 "BGP updates debugging (per prefix) is off\n");
1345 vty_out(vty
, "BGP updates debugging is off for %s\n",
1346 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1348 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1349 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1354 DEFUN (no_debug_bgp_update
,
1355 no_debug_bgp_update_cmd
,
1356 "no debug bgp updates",
1362 struct listnode
*ln
;
1365 bgp_debug_list_free(bgp_debug_update_in_peers
);
1366 bgp_debug_list_free(bgp_debug_update_out_peers
);
1367 bgp_debug_list_free(bgp_debug_update_prefixes
);
1369 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1370 bgp_debug_clear_updgrp_update_dbg(bgp
);
1372 if (vty
->node
== CONFIG_NODE
) {
1373 DEBUG_OFF(update
, UPDATE_IN
);
1374 DEBUG_OFF(update
, UPDATE_OUT
);
1375 DEBUG_OFF(update
, UPDATE_PREFIX
);
1377 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1378 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1379 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1380 vty_out(vty
, "BGP updates debugging is off\n");
1385 /* debug bgp zebra */
1386 DEFUN (debug_bgp_zebra
,
1387 debug_bgp_zebra_cmd
,
1391 "BGP Zebra messages\n")
1393 if (vty
->node
== CONFIG_NODE
)
1394 DEBUG_ON(zebra
, ZEBRA
);
1396 TERM_DEBUG_ON(zebra
, ZEBRA
);
1397 vty_out(vty
, "BGP zebra debugging is on\n");
1402 DEFUN (debug_bgp_zebra_prefix
,
1403 debug_bgp_zebra_prefix_cmd
,
1404 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1407 "BGP Zebra messages\n"
1408 "Specify a prefix to debug\n"
1412 int idx_ipv4_ipv6_prefixlen
= 4;
1413 struct prefix
*argv_p
;
1415 argv_p
= prefix_new();
1416 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1419 if (!bgp_debug_zebra_prefixes
)
1420 bgp_debug_zebra_prefixes
= list_new();
1422 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1423 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1424 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1428 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1430 if (vty
->node
== CONFIG_NODE
)
1431 DEBUG_ON(zebra
, ZEBRA
);
1433 TERM_DEBUG_ON(zebra
, ZEBRA
);
1434 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1435 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1441 DEFUN (no_debug_bgp_zebra
,
1442 no_debug_bgp_zebra_cmd
,
1443 "no debug bgp zebra",
1447 "BGP Zebra messages\n")
1449 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1451 if (vty
->node
== CONFIG_NODE
)
1452 DEBUG_OFF(zebra
, ZEBRA
);
1454 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1455 vty_out(vty
, "BGP zebra debugging is off\n");
1460 DEFUN (no_debug_bgp_zebra_prefix
,
1461 no_debug_bgp_zebra_prefix_cmd
,
1462 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1466 "BGP Zebra messages\n"
1467 "Specify a prefix to debug\n"
1471 int idx_ipv4_ipv6_prefixlen
= 5;
1472 struct prefix
*argv_p
;
1473 int found_prefix
= 0;
1475 argv_p
= prefix_new();
1476 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1479 if (bgp_debug_zebra_prefixes
1480 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1481 found_prefix
= bgp_debug_list_remove_entry(
1482 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1484 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1485 if (vty
->node
== CONFIG_NODE
)
1486 DEBUG_OFF(zebra
, ZEBRA
);
1488 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1489 vty_out(vty
, "BGP zebra debugging is off\n");
1495 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1496 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1498 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1499 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1504 DEFUN (debug_bgp_allow_martians
,
1505 debug_bgp_allow_martians_cmd
,
1506 "debug bgp allow-martians",
1509 "BGP allow martian next hops\n")
1511 if (vty
->node
== CONFIG_NODE
)
1512 DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1514 TERM_DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1515 vty_out(vty
, "BGP allow_martian next hop debugging is on\n");
1520 DEFUN (no_debug_bgp_allow_martians
,
1521 no_debug_bgp_allow_martians_cmd
,
1522 "no debug bgp allow-martians",
1526 "BGP allow martian next hops\n")
1528 if (vty
->node
== CONFIG_NODE
)
1529 DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1531 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1532 vty_out(vty
, "BGP allow martian next hop debugging is off\n");
1538 /* debug bgp update-groups */
1539 DEFUN (debug_bgp_update_groups
,
1540 debug_bgp_update_groups_cmd
,
1541 "debug bgp update-groups",
1544 "BGP update-groups\n")
1546 if (vty
->node
== CONFIG_NODE
)
1547 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1549 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1550 vty_out(vty
, "BGP update-groups debugging is on\n");
1555 DEFUN (no_debug_bgp_update_groups
,
1556 no_debug_bgp_update_groups_cmd
,
1557 "no debug bgp update-groups",
1561 "BGP update-groups\n")
1563 if (vty
->node
== CONFIG_NODE
)
1564 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1566 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1567 vty_out(vty
, "BGP update-groups debugging is off\n");
1572 DEFUN (debug_bgp_vpn
,
1574 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1578 "leaked from vrf to vpn\n"
1579 "leaked to vrf from vpn\n"
1580 "route-map updates\n"
1585 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1586 if (vty
->node
== CONFIG_NODE
)
1587 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1589 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1590 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1591 if (vty
->node
== CONFIG_NODE
)
1592 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1594 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1595 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1596 if (vty
->node
== CONFIG_NODE
)
1597 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1599 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1600 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1601 if (vty
->node
== CONFIG_NODE
)
1602 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1604 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1606 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1607 return CMD_WARNING_CONFIG_FAILED
;
1610 if (vty
->node
!= CONFIG_NODE
)
1611 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1616 DEFUN (no_debug_bgp_vpn
,
1617 no_debug_bgp_vpn_cmd
,
1618 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1623 "leaked from vrf to vpn\n"
1624 "leaked to vrf from vpn\n"
1625 "route-map updates\n"
1630 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1631 if (vty
->node
== CONFIG_NODE
)
1632 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1634 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1636 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1637 if (vty
->node
== CONFIG_NODE
)
1638 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1640 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1641 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1642 if (vty
->node
== CONFIG_NODE
)
1643 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1645 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1646 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1647 if (vty
->node
== CONFIG_NODE
)
1648 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1650 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1652 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1653 return CMD_WARNING_CONFIG_FAILED
;
1656 if (vty
->node
!= CONFIG_NODE
)
1657 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1662 DEFUN (debug_bgp_pbr
,
1664 "debug bgp pbr [error]",
1667 "BGP policy based routing\n"
1672 if (argv_find(argv
, argc
, "error", &idx
)) {
1673 if (vty
->node
== CONFIG_NODE
)
1674 DEBUG_ON(pbr
, PBR_ERROR
);
1676 TERM_DEBUG_ON(pbr
, PBR_ERROR
);
1677 vty_out(vty
, "BGP policy based routing error is on\n");
1681 if (vty
->node
== CONFIG_NODE
)
1684 TERM_DEBUG_ON(pbr
, PBR
);
1685 vty_out(vty
, "BGP policy based routing is on\n");
1690 DEFUN (no_debug_bgp_pbr
,
1691 no_debug_bgp_pbr_cmd
,
1692 "no debug bgp pbr [error]",
1696 "BGP policy based routing\n"
1701 if (argv_find(argv
, argc
, "error", &idx
)) {
1702 if (vty
->node
== CONFIG_NODE
)
1703 DEBUG_OFF(pbr
, PBR_ERROR
);
1705 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1706 vty_out(vty
, "BGP policy based routing error is off\n");
1710 if (vty
->node
== CONFIG_NODE
)
1711 DEBUG_OFF(pbr
, PBR
);
1713 TERM_DEBUG_OFF(pbr
, PBR
);
1714 vty_out(vty
, "BGP policy based routing is off\n");
1719 DEFUN (debug_bgp_labelpool
,
1720 debug_bgp_labelpool_cmd
,
1721 "debug bgp labelpool",
1726 if (vty
->node
== CONFIG_NODE
)
1727 DEBUG_ON(labelpool
, LABELPOOL
);
1729 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
1731 if (vty
->node
!= CONFIG_NODE
)
1732 vty_out(vty
, "enabled debug bgp labelpool\n");
1737 DEFUN (no_debug_bgp_labelpool
,
1738 no_debug_bgp_labelpool_cmd
,
1739 "no debug bgp labelpool",
1745 if (vty
->node
== CONFIG_NODE
)
1746 DEBUG_OFF(labelpool
, LABELPOOL
);
1748 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
1751 if (vty
->node
!= CONFIG_NODE
)
1752 vty_out(vty
, "disabled debug bgp labelpool\n");
1757 DEFUN (no_debug_bgp
,
1765 struct listnode
*ln
;
1767 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1768 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1769 bgp_debug_list_free(bgp_debug_update_in_peers
);
1770 bgp_debug_list_free(bgp_debug_update_out_peers
);
1771 bgp_debug_list_free(bgp_debug_update_prefixes
);
1772 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1773 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1775 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1776 bgp_debug_clear_updgrp_update_dbg(bgp
);
1778 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
1779 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1780 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1781 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1782 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1783 TERM_DEBUG_OFF(as4
, AS4
);
1784 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
1785 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
1786 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1787 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1788 TERM_DEBUG_OFF(nht
, NHT
);
1789 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1790 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1791 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1792 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1793 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
1794 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
1795 TERM_DEBUG_OFF(pbr
, PBR
);
1796 TERM_DEBUG_OFF(pbr
, PBR_ERROR
);
1797 vty_out(vty
, "All possible debugging has been turned off\n");
1802 DEFUN_NOSH (show_debugging_bgp
,
1803 show_debugging_bgp_cmd
,
1804 "show debugging [bgp]",
1809 vty_out(vty
, "BGP debugging status:\n");
1811 if (BGP_DEBUG(as4
, AS4
))
1812 vty_out(vty
, " BGP as4 debugging is on\n");
1814 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1815 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
1817 if (BGP_DEBUG(bestpath
, BESTPATH
))
1818 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
1819 bgp_debug_bestpath_prefixes
);
1821 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1822 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
1823 bgp_debug_keepalive_peers
);
1825 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1826 bgp_debug_list_print(vty
,
1827 " BGP neighbor-events debugging is on",
1828 bgp_debug_neighbor_events_peers
);
1830 if (BGP_DEBUG(nht
, NHT
))
1831 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
1833 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1834 vty_out(vty
, " BGP update-groups debugging is on\n");
1836 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1837 bgp_debug_list_print(vty
, " BGP updates debugging is on",
1838 bgp_debug_update_prefixes
);
1840 if (BGP_DEBUG(update
, UPDATE_IN
))
1841 bgp_debug_list_print(vty
,
1842 " BGP updates debugging is on (inbound)",
1843 bgp_debug_update_in_peers
);
1845 if (BGP_DEBUG(update
, UPDATE_OUT
))
1846 bgp_debug_list_print(vty
,
1847 " BGP updates debugging is on (outbound)",
1848 bgp_debug_update_out_peers
);
1850 if (BGP_DEBUG(zebra
, ZEBRA
))
1851 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
1852 bgp_debug_zebra_prefixes
);
1854 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1855 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
1857 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1859 " BGP route leak from vrf to vpn debugging is on\n");
1860 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1862 " BGP route leak to vrf from vpn debugging is on\n");
1863 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1864 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
1865 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1866 vty_out(vty
, " BGP vpn label event debugging is on\n");
1867 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
1868 vty_out(vty
, " BGP flowspec debugging is on\n");
1869 if (BGP_DEBUG(labelpool
, LABELPOOL
))
1870 vty_out(vty
, " BGP labelpool debugging is on\n");
1872 if (BGP_DEBUG(pbr
, PBR
))
1873 vty_out(vty
, " BGP policy based routing debugging is on\n");
1874 if (BGP_DEBUG(pbr
, PBR_ERROR
))
1875 vty_out(vty
, " BGP policy based routing error debugging is on\n");
1881 /* return count of number of debug flags set */
1882 int bgp_debug_count(void)
1885 if (BGP_DEBUG(as4
, AS4
))
1888 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1891 if (BGP_DEBUG(bestpath
, BESTPATH
))
1894 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1897 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1900 if (BGP_DEBUG(nht
, NHT
))
1903 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1906 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1909 if (BGP_DEBUG(update
, UPDATE_IN
))
1912 if (BGP_DEBUG(update
, UPDATE_OUT
))
1915 if (BGP_DEBUG(zebra
, ZEBRA
))
1918 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1921 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1923 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1925 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1927 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1929 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
1931 if (BGP_DEBUG(labelpool
, LABELPOOL
))
1934 if (BGP_DEBUG(pbr
, PBR
))
1936 if (BGP_DEBUG(pbr
, PBR_ERROR
))
1942 static int bgp_config_write_debug(struct vty
*vty
)
1946 if (CONF_BGP_DEBUG(as4
, AS4
)) {
1947 vty_out(vty
, "debug bgp as4\n");
1951 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
1952 vty_out(vty
, "debug bgp as4 segment\n");
1956 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
1957 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
1958 bgp_debug_bestpath_prefixes
);
1961 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
1962 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
1963 bgp_debug_keepalive_peers
);
1966 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
1967 write
+= bgp_debug_list_conf_print(
1968 vty
, "debug bgp neighbor-events",
1969 bgp_debug_neighbor_events_peers
);
1972 if (CONF_BGP_DEBUG(nht
, NHT
)) {
1973 vty_out(vty
, "debug bgp nht\n");
1977 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
1978 vty_out(vty
, "debug bgp update-groups\n");
1982 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
1983 write
+= bgp_debug_list_conf_print(vty
,
1984 "debug bgp updates prefix",
1985 bgp_debug_update_prefixes
);
1988 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
1989 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
1990 bgp_debug_update_in_peers
);
1993 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
1994 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
1995 bgp_debug_update_out_peers
);
1998 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
1999 if (!bgp_debug_zebra_prefixes
2000 || list_isempty(bgp_debug_zebra_prefixes
)) {
2001 vty_out(vty
, "debug bgp zebra\n");
2004 write
+= bgp_debug_list_conf_print(
2005 vty
, "debug bgp zebra prefix",
2006 bgp_debug_zebra_prefixes
);
2010 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
2011 vty_out(vty
, "debug bgp allow-martians\n");
2015 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
2016 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
2019 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
2020 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
2023 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
2024 vty_out(vty
, "debug bgp vpn rmap-event\n");
2027 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
2028 vty_out(vty
, "debug bgp vpn label\n");
2031 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
2032 vty_out(vty
, "debug bgp flowspec\n");
2035 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
2036 vty_out(vty
, "debug bgp labelpool\n");
2040 if (CONF_BGP_DEBUG(pbr
, PBR
)) {
2041 vty_out(vty
, "debug bgp pbr\n");
2044 if (CONF_BGP_DEBUG(pbr
, PBR_ERROR
)) {
2045 vty_out(vty
, "debug bgp pbr error\n");
2051 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
2053 void bgp_debug_init(void)
2055 install_node(&debug_node
, bgp_config_write_debug
);
2057 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
2059 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
2060 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
2061 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
2062 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
2064 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
2065 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
2066 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
2067 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
2068 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
2069 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
2070 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
2071 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
2072 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
2073 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
2074 install_element(ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
2075 install_element(CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
2076 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
2077 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
2078 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2079 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2081 /* debug bgp updates (in|out) */
2082 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2083 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2084 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2085 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2087 /* debug bgp updates (in|out) A.B.C.D */
2088 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2089 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2090 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2091 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2093 /* debug bgp updates prefix A.B.C.D/M */
2094 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2095 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2096 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2097 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2099 /* debug bgp zebra prefix A.B.C.D/M */
2100 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2101 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2102 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2103 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2105 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2106 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2107 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2108 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2110 /* debug bgp neighbor-events A.B.C.D */
2111 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2112 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2113 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2114 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2116 /* debug bgp keepalive A.B.C.D */
2117 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2118 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2119 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2120 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2122 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2123 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2124 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2125 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2126 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2127 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2128 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2129 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2130 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2131 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2132 install_element(ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
2133 install_element(CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
2134 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2135 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2136 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2137 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2138 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2139 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2140 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2142 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2143 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2144 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2145 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2147 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2148 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2149 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2150 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2153 install_element(ENABLE_NODE
, &debug_bgp_pbr_cmd
);
2154 install_element(CONFIG_NODE
, &debug_bgp_pbr_cmd
);
2155 install_element(ENABLE_NODE
, &no_debug_bgp_pbr_cmd
);
2156 install_element(CONFIG_NODE
, &no_debug_bgp_pbr_cmd
);
2160 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2161 * for BGP_DEBUG_TYPE
2163 static int bgp_debug_per_prefix(struct prefix
*p
,
2164 unsigned long term_bgp_debug_type
,
2165 unsigned int BGP_DEBUG_TYPE
,
2166 struct list
*per_prefix_list
)
2168 struct bgp_debug_filter
*filter
;
2169 struct listnode
*node
, *nnode
;
2171 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2172 /* We are debugging all prefixes so return true */
2173 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2180 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2182 if (filter
->p
->prefixlen
== p
->prefixlen
2183 && prefix_match(filter
->p
, p
))
2193 /* Return true if this peer is on the per_peer_list of peers to debug
2194 * for BGP_DEBUG_TYPE
2196 static int bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2197 unsigned int BGP_DEBUG_TYPE
,
2198 struct list
*per_peer_list
)
2200 struct bgp_debug_filter
*filter
;
2201 struct listnode
*node
, *nnode
;
2203 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2204 /* We are debugging all peers so return true */
2205 if (!per_peer_list
|| list_isempty(per_peer_list
))
2212 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2214 if (strcmp(filter
->host
, host
) == 0)
2224 int bgp_debug_neighbor_events(struct peer
*peer
)
2231 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2232 BGP_DEBUG_NEIGHBOR_EVENTS
,
2233 bgp_debug_neighbor_events_peers
);
2236 int bgp_debug_keepalive(struct peer
*peer
)
2243 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2244 BGP_DEBUG_KEEPALIVE
,
2245 bgp_debug_keepalive_peers
);
2248 int bgp_debug_update(struct peer
*peer
, struct prefix
*p
,
2249 struct update_group
*updgrp
, unsigned int inbound
)
2257 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2258 BGP_DEBUG_UPDATE_IN
,
2259 bgp_debug_update_in_peers
))
2265 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2266 BGP_DEBUG_UPDATE_OUT
,
2267 bgp_debug_update_out_peers
))
2270 /* Check if update debugging implicitly enabled for the group.
2272 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2277 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2278 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2279 BGP_DEBUG_UPDATE_PREFIX
,
2280 bgp_debug_update_prefixes
))
2287 int bgp_debug_bestpath(struct prefix
*p
)
2289 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2290 if (bgp_debug_per_prefix(p
, term_bgp_debug_bestpath
,
2292 bgp_debug_bestpath_prefixes
))
2299 int bgp_debug_zebra(struct prefix
*p
)
2301 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2302 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2304 bgp_debug_zebra_prefixes
))
2311 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2312 struct prefix_rd
*prd
,
2313 union prefixconstptr pu
,
2314 mpls_label_t
*label
, uint32_t num_labels
,
2315 int addpath_valid
, uint32_t addpath_id
,
2316 char *str
, int size
)
2318 char rd_buf
[RD_ADDRSTRLEN
];
2319 char pfx_buf
[PREFIX_STRLEN
];
2321 /* ' with addpath ID ' 17
2322 * max strlen of uint32 + 10
2323 * +/- (just in case) + 1
2324 * null terminator + 1
2325 * ============================ 29 */
2326 char pathid_buf
[30];
2328 if (size
< BGP_PRD_PATH_STRLEN
)
2331 /* Note: Path-id is created by default, but only included in update
2333 pathid_buf
[0] = '\0';
2335 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2339 if (bgp_labeled_safi(safi
) && num_labels
) {
2341 if (safi
== SAFI_EVPN
) {
2344 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2345 sprintf(tag_buf
, " label %s", tag_buf2
);
2347 uint32_t label_value
;
2349 label_value
= decode_label(label
);
2350 sprintf(tag_buf
, " label %u", label_value
);
2355 snprintf(str
, size
, "RD %s %s%s%s %s %s",
2356 prefix_rd2str(prd
, rd_buf
, sizeof(rd_buf
)),
2357 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2358 pathid_buf
, afi2str(afi
), safi2str(safi
));
2359 else if (safi
== SAFI_FLOWSPEC
) {
2360 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2361 const struct prefix_fs
*fs
= pu
.fs
;
2363 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2364 fs
->prefix
.prefixlen
,
2366 NLRI_STRING_FORMAT_DEBUG
, NULL
);
2367 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2370 snprintf(str
, size
, "%s%s%s %s %s",
2371 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2372 pathid_buf
, afi2str(afi
), safi2str(safi
));