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
;
63 unsigned long term_bgp_debug_as4
;
64 unsigned long term_bgp_debug_neighbor_events
;
65 unsigned long term_bgp_debug_events
;
66 unsigned long term_bgp_debug_packet
;
67 unsigned long term_bgp_debug_filter
;
68 unsigned long term_bgp_debug_keepalive
;
69 unsigned long term_bgp_debug_update
;
70 unsigned long term_bgp_debug_bestpath
;
71 unsigned long term_bgp_debug_zebra
;
72 unsigned long term_bgp_debug_allow_martians
;
73 unsigned long term_bgp_debug_nht
;
74 unsigned long term_bgp_debug_update_groups
;
75 unsigned long term_bgp_debug_vpn
;
76 unsigned long term_bgp_debug_flowspec
;
77 unsigned long term_bgp_debug_labelpool
;
79 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
80 struct list
*bgp_debug_keepalive_peers
= NULL
;
81 struct list
*bgp_debug_update_out_peers
= NULL
;
82 struct list
*bgp_debug_update_in_peers
= NULL
;
83 struct list
*bgp_debug_update_prefixes
= NULL
;
84 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
85 struct list
*bgp_debug_zebra_prefixes
= NULL
;
87 /* messages for BGP-4 status */
88 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
91 {OpenSent
, "OpenSent"},
92 {OpenConfirm
, "OpenConfirm"},
93 {Established
, "Established"},
94 {Clearing
, "Clearing"},
98 /* BGP message type string. */
99 const char *bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
100 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
103 /* message for BGP-4 Notify */
104 static const struct message bgp_notify_msg
[] = {
105 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
106 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
107 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
108 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
109 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
110 {BGP_NOTIFY_CEASE
, "Cease"},
111 {BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
114 static const struct message bgp_notify_head_msg
[] = {
115 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
116 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
117 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
120 static const struct message bgp_notify_open_msg
[] = {
121 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
122 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
123 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
124 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
125 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
126 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
127 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
128 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
131 static const struct message bgp_notify_update_msg
[] = {
132 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
133 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
134 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
135 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
136 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
137 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
138 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
139 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
140 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
141 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
142 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
143 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
146 static const struct message bgp_notify_cease_msg
[] = {
147 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
148 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
149 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
150 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
151 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
152 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
153 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
154 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
155 "/Connection collision resolution"},
156 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
159 static const struct message bgp_notify_capability_msg
[] = {
160 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
161 {BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value"},
162 {BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
163 {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
166 /* Origin strings. */
167 const char *bgp_origin_str
[] = {"i", "e", "?"};
168 const char *bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
170 /* Given a string return a pointer the corresponding peer structure */
171 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
173 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
181 ret
= str2sockunion(peer_str
, &su
);
185 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
188 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
192 return peer_lookup(bgp
, &su
);
195 static void bgp_debug_list_free(struct list
*list
)
197 struct bgp_debug_filter
*filter
;
198 struct listnode
*node
, *nnode
;
201 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
202 listnode_delete(list
, filter
);
205 prefix_free(filter
->p
);
208 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
210 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
214 /* Print the desc along with a list of peers/prefixes this debug is
216 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
219 struct bgp_debug_filter
*filter
;
220 struct listnode
*node
, *nnode
;
221 char buf
[INET6_ADDRSTRLEN
];
223 vty_out(vty
, "%s", desc
);
225 if (list
&& !list_isempty(list
)) {
226 vty_out(vty
, " for");
227 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
229 vty_out(vty
, " %s", filter
->host
);
232 vty_out(vty
, " %s/%d",
233 inet_ntop(filter
->p
->family
,
234 &filter
->p
->u
.prefix
, buf
,
236 filter
->p
->prefixlen
);
243 /* Print the command to enable the debug for each peer/prefix this debug is
246 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
249 struct bgp_debug_filter
*filter
;
250 struct listnode
*node
, *nnode
;
251 char buf
[INET6_ADDRSTRLEN
];
254 if (list
&& !list_isempty(list
)) {
255 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
257 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
263 vty_out(vty
, "%s %s/%d\n", desc
,
264 inet_ntop(filter
->p
->family
,
265 &filter
->p
->u
.prefix
, buf
,
267 filter
->p
->prefixlen
);
274 vty_out(vty
, "%s\n", desc
);
281 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
282 const struct prefix
*p
)
284 struct bgp_debug_filter
*filter
;
286 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
287 sizeof(struct bgp_debug_filter
));
290 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
294 filter
->p
= prefix_new();
295 prefix_copy(filter
->p
, p
);
298 listnode_add(list
, filter
);
301 static int bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
304 struct bgp_debug_filter
*filter
;
305 struct listnode
*node
, *nnode
;
307 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
308 if (host
&& strcmp(filter
->host
, host
) == 0) {
309 listnode_delete(list
, filter
);
310 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
311 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
313 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
314 && prefix_match(filter
->p
, p
)) {
315 listnode_delete(list
, filter
);
316 prefix_free(filter
->p
);
317 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
325 static int bgp_debug_list_has_entry(struct list
*list
, const char *host
,
326 const struct prefix
*p
)
328 struct bgp_debug_filter
*filter
;
329 struct listnode
*node
, *nnode
;
331 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
333 if (strcmp(filter
->host
, host
) == 0) {
337 if (filter
->p
->prefixlen
== p
->prefixlen
338 && prefix_match(filter
->p
, p
)) {
347 int bgp_debug_peer_updout_enabled(char *host
)
349 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
353 /* Dump attribute. */
354 int bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
356 char addrbuf
[BUFSIZ
];
361 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
362 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
364 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
365 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
366 bgp_origin_str
[attr
->origin
]);
369 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
370 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
371 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
373 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
376 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
377 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
378 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
381 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
382 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
384 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
385 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
386 ", localpref %u", attr
->local_pref
);
388 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
389 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
392 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
393 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
395 community_str(attr
->community
, false));
397 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
398 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
399 ", extcommunity %s", ecommunity_str(attr
->ecommunity
));
401 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
402 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
403 ", atomic-aggregate");
405 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
406 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
407 ", aggregated by %u %s", attr
->aggregator_as
,
408 inet_ntoa(attr
->aggregator_addr
));
410 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
411 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
412 ", originator %s", inet_ntoa(attr
->originator_id
));
414 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
417 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
419 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
420 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), " %s",
421 inet_ntoa(attr
->cluster
->list
[i
]));
424 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
425 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
426 ", pmsi tnltype %u", attr
->pmsi_tnl_type
);
428 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
429 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
430 aspath_print(attr
->aspath
));
432 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
433 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
434 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
435 ", label-index %u", attr
->label_index
);
444 const char *bgp_notify_code_str(char code
)
446 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
449 const char *bgp_notify_subcode_str(char code
, char subcode
)
453 case BGP_NOTIFY_HEADER_ERR
:
454 return lookup_msg(bgp_notify_head_msg
, subcode
,
455 "Unrecognized Error Subcode");
456 case BGP_NOTIFY_OPEN_ERR
:
457 return lookup_msg(bgp_notify_open_msg
, subcode
,
458 "Unrecognized Error Subcode");
459 case BGP_NOTIFY_UPDATE_ERR
:
460 return lookup_msg(bgp_notify_update_msg
, subcode
,
461 "Unrecognized Error Subcode");
462 case BGP_NOTIFY_HOLD_ERR
:
464 case BGP_NOTIFY_FSM_ERR
:
466 case BGP_NOTIFY_CEASE
:
467 return lookup_msg(bgp_notify_cease_msg
, subcode
,
468 "Unrecognized Error Subcode");
469 case BGP_NOTIFY_CAPABILITY_ERR
:
470 return lookup_msg(bgp_notify_capability_msg
, subcode
,
471 "Unrecognized Error Subcode");
476 /* extract notify admin reason if correctly present */
477 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, uint8_t *data
,
480 if (!data
|| datalen
< 1)
483 uint8_t len
= data
[0];
484 if (len
> 128 || len
> datalen
- 1)
487 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
490 /* dump notify packet */
491 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
494 const char *subcode_str
;
495 const char *code_str
;
496 const char *msg_str
= NULL
;
499 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
500 || bgp_flag_check(peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
501 code_str
= bgp_notify_code_str(bgp_notify
->code
);
502 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
503 bgp_notify
->subcode
);
505 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
506 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
507 || bgp_notify
->subcode
508 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
509 msg_str
= bgp_notify_admin_message(
510 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
516 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) \"%s\"",
517 strcmp(direct
, "received") == 0
520 peer
->host
, bgp_notify
->code
,
521 bgp_notify
->subcode
, code_str
, subcode_str
,
524 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
526 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
527 strcmp(direct
, "received") == 0
530 peer
->host
, bgp_notify
->code
,
531 bgp_notify
->subcode
, code_str
, subcode_str
,
532 bgp_notify
->length
, msg_str
);
537 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
540 bgp
= bgp_get_default();
541 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
545 /* Debug option setting interface. */
546 unsigned long bgp_debug_option
= 0;
548 int debug(unsigned int option
)
550 return bgp_debug_option
& option
;
553 DEFUN (debug_bgp_as4
,
560 if (vty
->node
== CONFIG_NODE
)
563 TERM_DEBUG_ON(as4
, AS4
);
564 vty_out(vty
, "BGP as4 debugging is on\n");
569 DEFUN (no_debug_bgp_as4
,
570 no_debug_bgp_as4_cmd
,
577 if (vty
->node
== CONFIG_NODE
)
580 TERM_DEBUG_OFF(as4
, AS4
);
581 vty_out(vty
, "BGP as4 debugging is off\n");
586 DEFUN (debug_bgp_as4_segment
,
587 debug_bgp_as4_segment_cmd
,
588 "debug bgp as4 segment",
592 "BGP AS4 aspath segment handling\n")
594 if (vty
->node
== CONFIG_NODE
)
595 DEBUG_ON(as4
, AS4_SEGMENT
);
597 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
598 vty_out(vty
, "BGP as4 segment debugging is on\n");
603 DEFUN (no_debug_bgp_as4_segment
,
604 no_debug_bgp_as4_segment_cmd
,
605 "no debug bgp as4 segment",
610 "BGP AS4 aspath segment handling\n")
612 if (vty
->node
== CONFIG_NODE
)
613 DEBUG_OFF(as4
, AS4_SEGMENT
);
615 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
616 vty_out(vty
, "BGP as4 segment debugging is off\n");
621 /* debug bgp neighbor_events */
622 DEFUN (debug_bgp_neighbor_events
,
623 debug_bgp_neighbor_events_cmd
,
624 "debug bgp neighbor-events",
627 "BGP Neighbor Events\n")
629 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
631 if (vty
->node
== CONFIG_NODE
)
632 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
634 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
635 vty_out(vty
, "BGP neighbor-events debugging is on\n");
640 DEFUN (debug_bgp_neighbor_events_peer
,
641 debug_bgp_neighbor_events_peer_cmd
,
642 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
645 "BGP Neighbor Events\n"
646 "BGP neighbor IP address to debug\n"
647 "BGP IPv6 neighbor to debug\n"
648 "BGP neighbor on interface to debug\n")
651 const char *host
= argv
[idx_peer
]->arg
;
653 if (!bgp_debug_neighbor_events_peers
)
654 bgp_debug_neighbor_events_peers
= list_new();
656 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
659 "BGP neighbor-events debugging is already enabled for %s\n",
664 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
666 if (vty
->node
== CONFIG_NODE
)
667 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
669 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
670 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
676 DEFUN (no_debug_bgp_neighbor_events
,
677 no_debug_bgp_neighbor_events_cmd
,
678 "no debug bgp neighbor-events",
684 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
686 if (vty
->node
== CONFIG_NODE
)
687 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
689 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
690 vty_out(vty
, "BGP neighbor-events debugging is off\n");
695 DEFUN (no_debug_bgp_neighbor_events_peer
,
696 no_debug_bgp_neighbor_events_peer_cmd
,
697 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
702 "BGP neighbor IP address to debug\n"
703 "BGP IPv6 neighbor to debug\n"
704 "BGP neighbor on interface to debug\n")
708 const char *host
= argv
[idx_peer
]->arg
;
710 if (bgp_debug_neighbor_events_peers
711 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
712 found_peer
= bgp_debug_list_remove_entry(
713 bgp_debug_neighbor_events_peers
, host
, NULL
);
715 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
716 if (vty
->node
== CONFIG_NODE
)
717 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
719 TERM_DEBUG_OFF(neighbor_events
,
725 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
729 "BGP neighbor-events debugging was not enabled for %s\n",
736 DEFUN (debug_bgp_nht
,
741 "BGP nexthop tracking events\n")
743 if (vty
->node
== CONFIG_NODE
)
746 TERM_DEBUG_ON(nht
, NHT
);
747 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
752 DEFUN (no_debug_bgp_nht
,
753 no_debug_bgp_nht_cmd
,
758 "BGP nexthop tracking events\n")
760 if (vty
->node
== CONFIG_NODE
)
763 TERM_DEBUG_OFF(nht
, NHT
);
764 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
769 /* debug bgp keepalives */
770 DEFUN (debug_bgp_keepalive
,
771 debug_bgp_keepalive_cmd
,
772 "debug bgp keepalives",
777 bgp_debug_list_free(bgp_debug_keepalive_peers
);
779 if (vty
->node
== CONFIG_NODE
)
780 DEBUG_ON(keepalive
, KEEPALIVE
);
782 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
783 vty_out(vty
, "BGP keepalives debugging is on\n");
788 DEFUN (debug_bgp_keepalive_peer
,
789 debug_bgp_keepalive_peer_cmd
,
790 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
793 "BGP Neighbor Events\n"
794 "BGP neighbor IP address to debug\n"
795 "BGP IPv6 neighbor to debug\n"
796 "BGP neighbor on interface to debug\n")
799 const char *host
= argv
[idx_peer
]->arg
;
801 if (!bgp_debug_keepalive_peers
)
802 bgp_debug_keepalive_peers
= list_new();
804 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
806 "BGP keepalive debugging is already enabled for %s\n",
811 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
813 if (vty
->node
== CONFIG_NODE
)
814 DEBUG_ON(keepalive
, KEEPALIVE
);
816 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
817 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
822 DEFUN (no_debug_bgp_keepalive
,
823 no_debug_bgp_keepalive_cmd
,
824 "no debug bgp keepalives",
830 bgp_debug_list_free(bgp_debug_keepalive_peers
);
832 if (vty
->node
== CONFIG_NODE
)
833 DEBUG_OFF(keepalive
, KEEPALIVE
);
835 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
836 vty_out(vty
, "BGP keepalives debugging is off\n");
841 DEFUN (no_debug_bgp_keepalive_peer
,
842 no_debug_bgp_keepalive_peer_cmd
,
843 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
848 "BGP neighbor IP address to debug\n"
849 "BGP IPv6 neighbor to debug\n"
850 "BGP neighbor on interface to debug\n")
854 const char *host
= argv
[idx_peer
]->arg
;
856 if (bgp_debug_keepalive_peers
857 && !list_isempty(bgp_debug_keepalive_peers
)) {
858 found_peer
= bgp_debug_list_remove_entry(
859 bgp_debug_keepalive_peers
, host
, NULL
);
861 if (list_isempty(bgp_debug_keepalive_peers
)) {
862 if (vty
->node
== CONFIG_NODE
)
863 DEBUG_OFF(keepalive
, KEEPALIVE
);
865 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
870 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
873 "BGP keepalives debugging was not enabled for %s\n",
879 /* debug bgp bestpath */
880 DEFUN (debug_bgp_bestpath_prefix
,
881 debug_bgp_bestpath_prefix_cmd
,
882 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
889 struct prefix
*argv_p
;
890 int idx_ipv4_ipv6_prefixlen
= 3;
892 argv_p
= prefix_new();
893 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
896 if (!bgp_debug_bestpath_prefixes
)
897 bgp_debug_bestpath_prefixes
= list_new();
899 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
902 "BGP bestpath debugging is already enabled for %s\n",
903 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
907 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
909 if (vty
->node
== CONFIG_NODE
) {
910 DEBUG_ON(bestpath
, BESTPATH
);
912 TERM_DEBUG_ON(bestpath
, BESTPATH
);
913 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
914 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
920 DEFUN (no_debug_bgp_bestpath_prefix
,
921 no_debug_bgp_bestpath_prefix_cmd
,
922 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
930 int idx_ipv4_ipv6_prefixlen
= 4;
931 struct prefix
*argv_p
;
932 int found_prefix
= 0;
934 argv_p
= prefix_new();
935 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
938 if (bgp_debug_bestpath_prefixes
939 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
940 found_prefix
= bgp_debug_list_remove_entry(
941 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
943 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
944 if (vty
->node
== CONFIG_NODE
) {
945 DEBUG_OFF(bestpath
, BESTPATH
);
947 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
949 "BGP bestpath debugging (per prefix) is off\n");
955 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
956 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
958 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
959 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
964 DEFUN (no_debug_bgp_bestpath
,
965 no_debug_bgp_bestpath_cmd
,
966 "no debug bgp bestpath",
972 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
974 if (vty
->node
== CONFIG_NODE
)
975 DEBUG_OFF(bestpath
, BESTPATH
);
977 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
978 vty_out(vty
, "BGP bestpath debugging is off\n");
983 /* debug bgp updates */
984 DEFUN (debug_bgp_update
,
985 debug_bgp_update_cmd
,
991 bgp_debug_list_free(bgp_debug_update_in_peers
);
992 bgp_debug_list_free(bgp_debug_update_out_peers
);
993 bgp_debug_list_free(bgp_debug_update_prefixes
);
995 if (vty
->node
== CONFIG_NODE
) {
996 DEBUG_ON(update
, UPDATE_IN
);
997 DEBUG_ON(update
, UPDATE_OUT
);
999 TERM_DEBUG_ON(update
, UPDATE_IN
);
1000 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1001 vty_out(vty
, "BGP updates debugging is on\n");
1006 DEFUN (debug_bgp_update_direct
,
1007 debug_bgp_update_direct_cmd
,
1008 "debug bgp updates <in|out>",
1013 "Outbound updates\n")
1017 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1018 bgp_debug_list_free(bgp_debug_update_in_peers
);
1020 bgp_debug_list_free(bgp_debug_update_out_peers
);
1022 if (vty
->node
== CONFIG_NODE
) {
1023 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1024 DEBUG_ON(update
, UPDATE_IN
);
1026 DEBUG_ON(update
, UPDATE_OUT
);
1028 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1029 TERM_DEBUG_ON(update
, UPDATE_IN
);
1030 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1032 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1034 "BGP updates debugging is on (outbound)\n");
1040 DEFUN (debug_bgp_update_direct_peer
,
1041 debug_bgp_update_direct_peer_cmd
,
1042 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1047 "Outbound updates\n"
1048 "BGP neighbor IP address to debug\n"
1049 "BGP IPv6 neighbor to debug\n"
1050 "BGP neighbor on interface to debug\n")
1054 const char *host
= argv
[idx_peer
]->arg
;
1057 if (!bgp_debug_update_in_peers
)
1058 bgp_debug_update_in_peers
= list_new();
1060 if (!bgp_debug_update_out_peers
)
1061 bgp_debug_update_out_peers
= list_new();
1063 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1069 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1072 "BGP inbound update debugging is already enabled for %s\n",
1079 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1082 "BGP outbound update debugging is already enabled for %s\n",
1089 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1092 struct peer_af
*paf
;
1095 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1097 peer
= bgp_find_peer(vty
, host
);
1100 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1102 paf
= peer
->peer_af_array
[afidx
];
1104 if (PAF_SUBGRP(paf
)) {
1114 if (vty
->node
== CONFIG_NODE
) {
1116 DEBUG_ON(update
, UPDATE_IN
);
1118 DEBUG_ON(update
, UPDATE_OUT
);
1121 TERM_DEBUG_ON(update
, UPDATE_IN
);
1123 "BGP updates debugging is on (inbound) for %s\n",
1124 argv
[idx_peer
]->arg
);
1126 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1128 "BGP updates debugging is on (outbound) for %s\n",
1129 argv
[idx_peer
]->arg
);
1135 DEFUN (no_debug_bgp_update_direct
,
1136 no_debug_bgp_update_direct_cmd
,
1137 "no debug bgp updates <in|out>",
1143 "Outbound updates\n")
1146 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1147 bgp_debug_list_free(bgp_debug_update_in_peers
);
1149 if (vty
->node
== CONFIG_NODE
) {
1150 DEBUG_OFF(update
, UPDATE_IN
);
1152 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1154 "BGP updates debugging is off (inbound)\n");
1157 bgp_debug_list_free(bgp_debug_update_out_peers
);
1159 if (vty
->node
== CONFIG_NODE
) {
1160 DEBUG_OFF(update
, UPDATE_OUT
);
1162 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1164 "BGP updates debugging is off (outbound)\n");
1171 DEFUN (no_debug_bgp_update_direct_peer
,
1172 no_debug_bgp_update_direct_peer_cmd
,
1173 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1179 "Outbound updates\n"
1180 "BGP neighbor IP address to debug\n"
1181 "BGP IPv6 neighbor to debug\n"
1182 "BGP neighbor on interface to debug\n")
1188 const char *host
= argv
[idx_peer
]->arg
;
1190 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1195 if (inbound
&& bgp_debug_update_in_peers
1196 && !list_isempty(bgp_debug_update_in_peers
)) {
1197 found_peer
= bgp_debug_list_remove_entry(
1198 bgp_debug_update_in_peers
, host
, NULL
);
1200 if (list_isempty(bgp_debug_update_in_peers
)) {
1201 if (vty
->node
== CONFIG_NODE
)
1202 DEBUG_OFF(update
, UPDATE_IN
);
1204 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1206 "BGP updates debugging (inbound) is off\n");
1211 if (!inbound
&& bgp_debug_update_out_peers
1212 && !list_isempty(bgp_debug_update_out_peers
)) {
1213 found_peer
= bgp_debug_list_remove_entry(
1214 bgp_debug_update_out_peers
, host
, NULL
);
1216 if (list_isempty(bgp_debug_update_out_peers
)) {
1217 if (vty
->node
== CONFIG_NODE
)
1218 DEBUG_OFF(update
, UPDATE_OUT
);
1220 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1222 "BGP updates debugging (outbound) is off\n");
1227 struct peer_af
*paf
;
1229 peer
= bgp_find_peer(vty
, host
);
1232 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1234 paf
= peer
->peer_af_array
[afidx
];
1236 if (PAF_SUBGRP(paf
)) {
1237 UPDGRP_PEER_DBG_DIS(
1249 "BGP updates debugging (inbound) is off for %s\n",
1253 "BGP updates debugging (outbound) is off for %s\n",
1257 "BGP updates debugging (inbound) was not enabled for %s\n",
1261 "BGP updates debugging (outbound) was not enabled for %s\n",
1267 DEFUN (debug_bgp_update_prefix
,
1268 debug_bgp_update_prefix_cmd
,
1269 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1273 "Specify a prefix to debug\n"
1277 int idx_ipv4_ipv6_prefixlen
= 4;
1278 struct prefix
*argv_p
;
1280 argv_p
= prefix_new();
1281 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1284 if (!bgp_debug_update_prefixes
)
1285 bgp_debug_update_prefixes
= list_new();
1287 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1289 "BGP updates debugging is already enabled for %s\n",
1290 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1294 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1296 if (vty
->node
== CONFIG_NODE
) {
1297 DEBUG_ON(update
, UPDATE_PREFIX
);
1299 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1300 vty_out(vty
, "BGP updates debugging is on for %s\n",
1301 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1307 DEFUN (no_debug_bgp_update_prefix
,
1308 no_debug_bgp_update_prefix_cmd
,
1309 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1314 "Specify a prefix to debug\n"
1318 int idx_ipv4_ipv6_prefixlen
= 5;
1319 struct prefix
*argv_p
;
1320 int found_prefix
= 0;
1322 argv_p
= prefix_new();
1323 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1326 if (bgp_debug_update_prefixes
1327 && !list_isempty(bgp_debug_update_prefixes
)) {
1328 found_prefix
= bgp_debug_list_remove_entry(
1329 bgp_debug_update_prefixes
, NULL
, argv_p
);
1331 if (list_isempty(bgp_debug_update_prefixes
)) {
1332 if (vty
->node
== CONFIG_NODE
) {
1333 DEBUG_OFF(update
, UPDATE_PREFIX
);
1335 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1337 "BGP updates debugging (per prefix) is off\n");
1343 vty_out(vty
, "BGP updates debugging is off for %s\n",
1344 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1346 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1347 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1352 DEFUN (no_debug_bgp_update
,
1353 no_debug_bgp_update_cmd
,
1354 "no debug bgp updates",
1360 struct listnode
*ln
;
1363 bgp_debug_list_free(bgp_debug_update_in_peers
);
1364 bgp_debug_list_free(bgp_debug_update_out_peers
);
1365 bgp_debug_list_free(bgp_debug_update_prefixes
);
1367 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1368 bgp_debug_clear_updgrp_update_dbg(bgp
);
1370 if (vty
->node
== CONFIG_NODE
) {
1371 DEBUG_OFF(update
, UPDATE_IN
);
1372 DEBUG_OFF(update
, UPDATE_OUT
);
1373 DEBUG_OFF(update
, UPDATE_PREFIX
);
1375 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1376 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1377 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1378 vty_out(vty
, "BGP updates debugging is off\n");
1383 /* debug bgp zebra */
1384 DEFUN (debug_bgp_zebra
,
1385 debug_bgp_zebra_cmd
,
1389 "BGP Zebra messages\n")
1391 if (vty
->node
== CONFIG_NODE
)
1392 DEBUG_ON(zebra
, ZEBRA
);
1394 TERM_DEBUG_ON(zebra
, ZEBRA
);
1395 vty_out(vty
, "BGP zebra debugging is on\n");
1400 DEFUN (debug_bgp_zebra_prefix
,
1401 debug_bgp_zebra_prefix_cmd
,
1402 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1405 "BGP Zebra messages\n"
1406 "Specify a prefix to debug\n"
1410 int idx_ipv4_ipv6_prefixlen
= 4;
1411 struct prefix
*argv_p
;
1413 argv_p
= prefix_new();
1414 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1417 if (!bgp_debug_zebra_prefixes
)
1418 bgp_debug_zebra_prefixes
= list_new();
1420 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1421 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1422 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1426 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1428 if (vty
->node
== CONFIG_NODE
)
1429 DEBUG_ON(zebra
, ZEBRA
);
1431 TERM_DEBUG_ON(zebra
, ZEBRA
);
1432 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1433 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1439 DEFUN (no_debug_bgp_zebra
,
1440 no_debug_bgp_zebra_cmd
,
1441 "no debug bgp zebra",
1445 "BGP Zebra messages\n")
1447 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1449 if (vty
->node
== CONFIG_NODE
)
1450 DEBUG_OFF(zebra
, ZEBRA
);
1452 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1453 vty_out(vty
, "BGP zebra debugging is off\n");
1458 DEFUN (no_debug_bgp_zebra_prefix
,
1459 no_debug_bgp_zebra_prefix_cmd
,
1460 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1464 "BGP Zebra messages\n"
1465 "Specify a prefix to debug\n"
1469 int idx_ipv4_ipv6_prefixlen
= 5;
1470 struct prefix
*argv_p
;
1471 int found_prefix
= 0;
1473 argv_p
= prefix_new();
1474 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1477 if (bgp_debug_zebra_prefixes
1478 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1479 found_prefix
= bgp_debug_list_remove_entry(
1480 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1482 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1483 if (vty
->node
== CONFIG_NODE
)
1484 DEBUG_OFF(zebra
, ZEBRA
);
1486 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1487 vty_out(vty
, "BGP zebra debugging is off\n");
1493 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1494 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1496 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1497 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1502 DEFUN (debug_bgp_allow_martians
,
1503 debug_bgp_allow_martians_cmd
,
1504 "debug bgp allow-martians",
1507 "BGP allow martian next hops\n")
1509 if (vty
->node
== CONFIG_NODE
)
1510 DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1512 TERM_DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1513 vty_out(vty
, "BGP allow_martian next hop debugging is on\n");
1518 DEFUN (no_debug_bgp_allow_martians
,
1519 no_debug_bgp_allow_martians_cmd
,
1520 "no debug bgp allow-martians",
1524 "BGP allow martian next hops\n")
1526 if (vty
->node
== CONFIG_NODE
)
1527 DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1529 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1530 vty_out(vty
, "BGP allow martian next hop debugging is off\n");
1536 /* debug bgp update-groups */
1537 DEFUN (debug_bgp_update_groups
,
1538 debug_bgp_update_groups_cmd
,
1539 "debug bgp update-groups",
1542 "BGP update-groups\n")
1544 if (vty
->node
== CONFIG_NODE
)
1545 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1547 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1548 vty_out(vty
, "BGP update-groups debugging is on\n");
1553 DEFUN (no_debug_bgp_update_groups
,
1554 no_debug_bgp_update_groups_cmd
,
1555 "no debug bgp update-groups",
1559 "BGP update-groups\n")
1561 if (vty
->node
== CONFIG_NODE
)
1562 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1564 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1565 vty_out(vty
, "BGP update-groups debugging is off\n");
1570 DEFUN (debug_bgp_vpn
,
1572 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1576 "leaked from vrf to vpn\n"
1577 "leaked to vrf from vpn\n"
1578 "route-map updates\n"
1583 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1584 if (vty
->node
== CONFIG_NODE
)
1585 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1587 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1588 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1589 if (vty
->node
== CONFIG_NODE
)
1590 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1592 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1593 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1594 if (vty
->node
== CONFIG_NODE
)
1595 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1597 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1598 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1599 if (vty
->node
== CONFIG_NODE
)
1600 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1602 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1604 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1605 return CMD_WARNING_CONFIG_FAILED
;
1608 if (vty
->node
!= CONFIG_NODE
)
1609 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1614 DEFUN (no_debug_bgp_vpn
,
1615 no_debug_bgp_vpn_cmd
,
1616 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1621 "leaked from vrf to vpn\n"
1622 "leaked to vrf from vpn\n"
1623 "route-map updates\n"
1628 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1629 if (vty
->node
== CONFIG_NODE
)
1630 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1632 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1634 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1635 if (vty
->node
== CONFIG_NODE
)
1636 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1638 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1639 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1640 if (vty
->node
== CONFIG_NODE
)
1641 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1643 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1644 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1645 if (vty
->node
== CONFIG_NODE
)
1646 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1648 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1650 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1651 return CMD_WARNING_CONFIG_FAILED
;
1654 if (vty
->node
!= CONFIG_NODE
)
1655 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1660 DEFUN (debug_bgp_labelpool
,
1661 debug_bgp_labelpool_cmd
,
1662 "debug bgp labelpool",
1667 if (vty
->node
== CONFIG_NODE
)
1668 DEBUG_ON(labelpool
, LABELPOOL
);
1670 TERM_DEBUG_ON(labelpool
, LABELPOOL
);
1672 if (vty
->node
!= CONFIG_NODE
)
1673 vty_out(vty
, "enabled debug bgp labelpool\n");
1678 DEFUN (no_debug_bgp_labelpool
,
1679 no_debug_bgp_labelpool_cmd
,
1680 "no debug bgp labelpool",
1686 if (vty
->node
== CONFIG_NODE
)
1687 DEBUG_OFF(labelpool
, LABELPOOL
);
1689 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
1692 if (vty
->node
!= CONFIG_NODE
)
1693 vty_out(vty
, "disabled debug bgp labelpool\n");
1698 DEFUN (no_debug_bgp
,
1706 struct listnode
*ln
;
1708 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1709 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1710 bgp_debug_list_free(bgp_debug_update_in_peers
);
1711 bgp_debug_list_free(bgp_debug_update_out_peers
);
1712 bgp_debug_list_free(bgp_debug_update_prefixes
);
1713 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1714 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1716 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1717 bgp_debug_clear_updgrp_update_dbg(bgp
);
1719 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
1720 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1721 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1722 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1723 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1724 TERM_DEBUG_OFF(as4
, AS4
);
1725 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
1726 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
1727 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1728 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1729 TERM_DEBUG_OFF(nht
, NHT
);
1730 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1731 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1732 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1733 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1734 TERM_DEBUG_OFF(flowspec
, FLOWSPEC
);
1735 TERM_DEBUG_OFF(labelpool
, LABELPOOL
);
1736 vty_out(vty
, "All possible debugging has been turned off\n");
1741 DEFUN_NOSH (show_debugging_bgp
,
1742 show_debugging_bgp_cmd
,
1743 "show debugging [bgp]",
1748 vty_out(vty
, "BGP debugging status:\n");
1750 if (BGP_DEBUG(as4
, AS4
))
1751 vty_out(vty
, " BGP as4 debugging is on\n");
1753 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1754 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
1756 if (BGP_DEBUG(bestpath
, BESTPATH
))
1757 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
1758 bgp_debug_bestpath_prefixes
);
1760 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1761 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
1762 bgp_debug_keepalive_peers
);
1764 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1765 bgp_debug_list_print(vty
,
1766 " BGP neighbor-events debugging is on",
1767 bgp_debug_neighbor_events_peers
);
1769 if (BGP_DEBUG(nht
, NHT
))
1770 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
1772 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1773 vty_out(vty
, " BGP update-groups debugging is on\n");
1775 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1776 bgp_debug_list_print(vty
, " BGP updates debugging is on",
1777 bgp_debug_update_prefixes
);
1779 if (BGP_DEBUG(update
, UPDATE_IN
))
1780 bgp_debug_list_print(vty
,
1781 " BGP updates debugging is on (inbound)",
1782 bgp_debug_update_in_peers
);
1784 if (BGP_DEBUG(update
, UPDATE_OUT
))
1785 bgp_debug_list_print(vty
,
1786 " BGP updates debugging is on (outbound)",
1787 bgp_debug_update_out_peers
);
1789 if (BGP_DEBUG(zebra
, ZEBRA
))
1790 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
1791 bgp_debug_zebra_prefixes
);
1793 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1794 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
1796 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1798 " BGP route leak from vrf to vpn debugging is on\n");
1799 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1801 " BGP route leak to vrf from vpn debugging is on\n");
1802 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1803 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
1804 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1805 vty_out(vty
, " BGP vpn label event debugging is on\n");
1806 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
1807 vty_out(vty
, " BGP flowspec debugging is on\n");
1808 if (BGP_DEBUG(labelpool
, LABELPOOL
))
1809 vty_out(vty
, " BGP labelpool debugging is on\n");
1815 /* return count of number of debug flags set */
1816 int bgp_debug_count(void)
1819 if (BGP_DEBUG(as4
, AS4
))
1822 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1825 if (BGP_DEBUG(bestpath
, BESTPATH
))
1828 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1831 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1834 if (BGP_DEBUG(nht
, NHT
))
1837 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1840 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1843 if (BGP_DEBUG(update
, UPDATE_IN
))
1846 if (BGP_DEBUG(update
, UPDATE_OUT
))
1849 if (BGP_DEBUG(zebra
, ZEBRA
))
1852 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1855 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1857 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1859 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1861 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1863 if (BGP_DEBUG(flowspec
, FLOWSPEC
))
1865 if (BGP_DEBUG(labelpool
, LABELPOOL
))
1871 static int bgp_config_write_debug(struct vty
*vty
)
1875 if (CONF_BGP_DEBUG(as4
, AS4
)) {
1876 vty_out(vty
, "debug bgp as4\n");
1880 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
1881 vty_out(vty
, "debug bgp as4 segment\n");
1885 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
1886 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
1887 bgp_debug_bestpath_prefixes
);
1890 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
1891 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
1892 bgp_debug_keepalive_peers
);
1895 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
1896 write
+= bgp_debug_list_conf_print(
1897 vty
, "debug bgp neighbor-events",
1898 bgp_debug_neighbor_events_peers
);
1901 if (CONF_BGP_DEBUG(nht
, NHT
)) {
1902 vty_out(vty
, "debug bgp nht\n");
1906 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
1907 vty_out(vty
, "debug bgp update-groups\n");
1911 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
1912 write
+= bgp_debug_list_conf_print(vty
,
1913 "debug bgp updates prefix",
1914 bgp_debug_update_prefixes
);
1917 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
1918 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
1919 bgp_debug_update_in_peers
);
1922 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
1923 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
1924 bgp_debug_update_out_peers
);
1927 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
1928 if (!bgp_debug_zebra_prefixes
1929 || list_isempty(bgp_debug_zebra_prefixes
)) {
1930 vty_out(vty
, "debug bgp zebra\n");
1933 write
+= bgp_debug_list_conf_print(
1934 vty
, "debug bgp zebra prefix",
1935 bgp_debug_zebra_prefixes
);
1939 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
1940 vty_out(vty
, "debug bgp allow-martians\n");
1944 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
1945 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
1948 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
1949 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
1952 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
1953 vty_out(vty
, "debug bgp vpn rmap-event\n");
1956 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
1957 vty_out(vty
, "debug bgp vpn label\n");
1960 if (CONF_BGP_DEBUG(flowspec
, FLOWSPEC
)) {
1961 vty_out(vty
, "debug bgp flowspec\n");
1964 if (CONF_BGP_DEBUG(labelpool
, LABELPOOL
)) {
1965 vty_out(vty
, "debug bgp labelpool\n");
1972 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
1974 void bgp_debug_init(void)
1976 install_node(&debug_node
, bgp_config_write_debug
);
1978 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
1980 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
1981 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
1982 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1983 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1985 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1986 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1987 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
1988 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
1989 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1990 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1991 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
1992 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
1993 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1994 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1995 install_element(ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1996 install_element(CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1997 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1998 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1999 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2000 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
2002 /* debug bgp updates (in|out) */
2003 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
2004 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
2005 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
2006 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
2008 /* debug bgp updates (in|out) A.B.C.D */
2009 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
2010 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
2011 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2012 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
2014 /* debug bgp updates prefix A.B.C.D/M */
2015 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
2016 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
2017 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
2018 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
2020 /* debug bgp zebra prefix A.B.C.D/M */
2021 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
2022 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
2023 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2024 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
2026 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
2027 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
2028 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
2029 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
2031 /* debug bgp neighbor-events A.B.C.D */
2032 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2033 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
2034 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2035 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
2037 /* debug bgp keepalive A.B.C.D */
2038 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
2039 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
2040 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2041 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
2043 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2044 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
2045 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
2046 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
2047 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
2048 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
2049 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
2050 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
2051 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
2052 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
2053 install_element(ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
2054 install_element(CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
2055 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
2056 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
2057 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
2058 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
2059 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
2060 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2061 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2063 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2064 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2065 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2066 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2068 install_element(ENABLE_NODE
, &debug_bgp_labelpool_cmd
);
2069 install_element(CONFIG_NODE
, &debug_bgp_labelpool_cmd
);
2070 install_element(ENABLE_NODE
, &no_debug_bgp_labelpool_cmd
);
2071 install_element(CONFIG_NODE
, &no_debug_bgp_labelpool_cmd
);
2074 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2075 * for BGP_DEBUG_TYPE
2077 static int bgp_debug_per_prefix(struct prefix
*p
,
2078 unsigned long term_bgp_debug_type
,
2079 unsigned int BGP_DEBUG_TYPE
,
2080 struct list
*per_prefix_list
)
2082 struct bgp_debug_filter
*filter
;
2083 struct listnode
*node
, *nnode
;
2085 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2086 /* We are debugging all prefixes so return true */
2087 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2094 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2096 if (filter
->p
->prefixlen
== p
->prefixlen
2097 && prefix_match(filter
->p
, p
))
2107 /* Return true if this peer is on the per_peer_list of peers to debug
2108 * for BGP_DEBUG_TYPE
2110 static int bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2111 unsigned int BGP_DEBUG_TYPE
,
2112 struct list
*per_peer_list
)
2114 struct bgp_debug_filter
*filter
;
2115 struct listnode
*node
, *nnode
;
2117 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2118 /* We are debugging all peers so return true */
2119 if (!per_peer_list
|| list_isempty(per_peer_list
))
2126 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2128 if (strcmp(filter
->host
, host
) == 0)
2138 int bgp_debug_neighbor_events(struct peer
*peer
)
2145 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2146 BGP_DEBUG_NEIGHBOR_EVENTS
,
2147 bgp_debug_neighbor_events_peers
);
2150 int bgp_debug_keepalive(struct peer
*peer
)
2157 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2158 BGP_DEBUG_KEEPALIVE
,
2159 bgp_debug_keepalive_peers
);
2162 int bgp_debug_update(struct peer
*peer
, struct prefix
*p
,
2163 struct update_group
*updgrp
, unsigned int inbound
)
2171 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2172 BGP_DEBUG_UPDATE_IN
,
2173 bgp_debug_update_in_peers
))
2179 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2180 BGP_DEBUG_UPDATE_OUT
,
2181 bgp_debug_update_out_peers
))
2184 /* Check if update debugging implicitly enabled for the group.
2186 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2191 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2192 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2193 BGP_DEBUG_UPDATE_PREFIX
,
2194 bgp_debug_update_prefixes
))
2201 int bgp_debug_bestpath(struct prefix
*p
)
2203 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2204 if (bgp_debug_per_prefix(p
, term_bgp_debug_bestpath
,
2206 bgp_debug_bestpath_prefixes
))
2213 int bgp_debug_zebra(struct prefix
*p
)
2215 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2216 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2218 bgp_debug_zebra_prefixes
))
2225 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2226 struct prefix_rd
*prd
,
2227 union prefixconstptr pu
,
2228 mpls_label_t
*label
, uint32_t num_labels
,
2229 int addpath_valid
, uint32_t addpath_id
,
2230 char *str
, int size
)
2232 char rd_buf
[RD_ADDRSTRLEN
];
2233 char pfx_buf
[PREFIX_STRLEN
];
2235 /* ' with addpath ID ' 17
2236 * max strlen of uint32 + 10
2237 * +/- (just in case) + 1
2238 * null terminator + 1
2239 * ============================ 29 */
2240 char pathid_buf
[30];
2242 if (size
< BGP_PRD_PATH_STRLEN
)
2245 /* Note: Path-id is created by default, but only included in update
2247 pathid_buf
[0] = '\0';
2249 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2253 if (bgp_labeled_safi(safi
) && num_labels
) {
2255 if (safi
== SAFI_EVPN
) {
2258 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2259 sprintf(tag_buf
, " label %s", tag_buf2
);
2261 uint32_t label_value
;
2263 label_value
= decode_label(label
);
2264 sprintf(tag_buf
, " label %u", label_value
);
2269 snprintf(str
, size
, "RD %s %s%s%s %s %s",
2270 prefix_rd2str(prd
, rd_buf
, sizeof(rd_buf
)),
2271 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2272 pathid_buf
, afi2str(afi
), safi2str(safi
));
2273 else if (safi
== SAFI_FLOWSPEC
) {
2274 char return_string
[BGP_FLOWSPEC_NLRI_STRING_MAX
];
2275 const struct prefix_fs
*fs
= pu
.fs
;
2277 bgp_fs_nlri_get_string((unsigned char *)fs
->prefix
.ptr
,
2278 fs
->prefix
.prefixlen
,
2280 NLRI_STRING_FORMAT_DEBUG
, NULL
);
2281 snprintf(str
, size
, "FS %s Match{%s}", afi2str(afi
),
2284 snprintf(str
, size
, "%s%s%s %s %s",
2285 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2286 pathid_buf
, afi2str(afi
), safi2str(safi
));