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"
46 unsigned long conf_bgp_debug_as4
;
47 unsigned long conf_bgp_debug_neighbor_events
;
48 unsigned long conf_bgp_debug_events
;
49 unsigned long conf_bgp_debug_packet
;
50 unsigned long conf_bgp_debug_filter
;
51 unsigned long conf_bgp_debug_keepalive
;
52 unsigned long conf_bgp_debug_update
;
53 unsigned long conf_bgp_debug_bestpath
;
54 unsigned long conf_bgp_debug_zebra
;
55 unsigned long conf_bgp_debug_allow_martians
;
56 unsigned long conf_bgp_debug_nht
;
57 unsigned long conf_bgp_debug_update_groups
;
58 unsigned long conf_bgp_debug_vpn
;
60 unsigned long term_bgp_debug_as4
;
61 unsigned long term_bgp_debug_neighbor_events
;
62 unsigned long term_bgp_debug_events
;
63 unsigned long term_bgp_debug_packet
;
64 unsigned long term_bgp_debug_filter
;
65 unsigned long term_bgp_debug_keepalive
;
66 unsigned long term_bgp_debug_update
;
67 unsigned long term_bgp_debug_bestpath
;
68 unsigned long term_bgp_debug_zebra
;
69 unsigned long term_bgp_debug_allow_martians
;
70 unsigned long term_bgp_debug_nht
;
71 unsigned long term_bgp_debug_update_groups
;
72 unsigned long term_bgp_debug_vpn
;
74 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
75 struct list
*bgp_debug_keepalive_peers
= NULL
;
76 struct list
*bgp_debug_update_out_peers
= NULL
;
77 struct list
*bgp_debug_update_in_peers
= NULL
;
78 struct list
*bgp_debug_update_prefixes
= NULL
;
79 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
80 struct list
*bgp_debug_zebra_prefixes
= NULL
;
82 /* messages for BGP-4 status */
83 const struct message bgp_status_msg
[] = {{Idle
, "Idle"},
86 {OpenSent
, "OpenSent"},
87 {OpenConfirm
, "OpenConfirm"},
88 {Established
, "Established"},
89 {Clearing
, "Clearing"},
93 /* BGP message type string. */
94 const char *bgp_type_str
[] = {NULL
, "OPEN", "UPDATE",
95 "NOTIFICATION", "KEEPALIVE", "ROUTE-REFRESH",
98 /* message for BGP-4 Notify */
99 static const struct message bgp_notify_msg
[] = {
100 {BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
101 {BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
102 {BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
103 {BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
104 {BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
105 {BGP_NOTIFY_CEASE
, "Cease"},
106 {BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
109 static const struct message bgp_notify_head_msg
[] = {
110 {BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
111 {BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
112 {BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"},
115 static const struct message bgp_notify_open_msg
[] = {
116 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
117 {BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number"},
118 {BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
119 {BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
120 {BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
121 {BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
122 {BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
123 {BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
126 static const struct message bgp_notify_update_msg
[] = {
127 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
128 {BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
129 {BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
130 {BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
131 {BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
132 {BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
133 {BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
134 {BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
135 {BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
136 {BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
137 {BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
138 {BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
141 static const struct message bgp_notify_cease_msg
[] = {
142 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
143 {BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
144 {BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
145 {BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
146 {BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
147 {BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
148 {BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
149 {BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
,
150 "/Connection collision resolution"},
151 {BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
154 static const struct message bgp_notify_capability_msg
[] = {
155 {BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
156 {BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value"},
157 {BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
158 {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
161 /* Origin strings. */
162 const char *bgp_origin_str
[] = {"i", "e", "?"};
163 const char *bgp_origin_long_str
[] = {"IGP", "EGP", "incomplete"};
165 /* Given a string return a pointer the corresponding peer structure */
166 static struct peer
*bgp_find_peer(struct vty
*vty
, const char *peer_str
)
168 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
176 ret
= str2sockunion(peer_str
, &su
);
180 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
183 peer
= peer_lookup_by_hostname(bgp
, peer_str
);
187 return peer_lookup(bgp
, &su
);
190 static void bgp_debug_list_free(struct list
*list
)
192 struct bgp_debug_filter
*filter
;
193 struct listnode
*node
, *nnode
;
196 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
197 listnode_delete(list
, filter
);
200 prefix_free(filter
->p
);
203 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
205 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
209 /* Print the desc along with a list of peers/prefixes this debug is
211 static void bgp_debug_list_print(struct vty
*vty
, const char *desc
,
214 struct bgp_debug_filter
*filter
;
215 struct listnode
*node
, *nnode
;
216 char buf
[INET6_ADDRSTRLEN
];
218 vty_out(vty
, "%s", desc
);
220 if (list
&& !list_isempty(list
)) {
221 vty_out(vty
, " for");
222 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
224 vty_out(vty
, " %s", filter
->host
);
227 vty_out(vty
, " %s/%d",
228 inet_ntop(filter
->p
->family
,
229 &filter
->p
->u
.prefix
, buf
,
231 filter
->p
->prefixlen
);
238 /* Print the command to enable the debug for each peer/prefix this debug is
241 static int bgp_debug_list_conf_print(struct vty
*vty
, const char *desc
,
244 struct bgp_debug_filter
*filter
;
245 struct listnode
*node
, *nnode
;
246 char buf
[INET6_ADDRSTRLEN
];
249 if (list
&& !list_isempty(list
)) {
250 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
252 vty_out(vty
, "%s %s\n", desc
, filter
->host
);
258 vty_out(vty
, "%s %s/%d\n", desc
,
259 inet_ntop(filter
->p
->family
,
260 &filter
->p
->u
.prefix
, buf
,
262 filter
->p
->prefixlen
);
269 vty_out(vty
, "%s\n", desc
);
276 static void bgp_debug_list_add_entry(struct list
*list
, const char *host
,
277 const struct prefix
*p
)
279 struct bgp_debug_filter
*filter
;
281 filter
= XCALLOC(MTYPE_BGP_DEBUG_FILTER
,
282 sizeof(struct bgp_debug_filter
));
285 filter
->host
= XSTRDUP(MTYPE_BGP_DEBUG_STR
, host
);
289 filter
->p
= prefix_new();
290 prefix_copy(filter
->p
, p
);
293 listnode_add(list
, filter
);
296 static int bgp_debug_list_remove_entry(struct list
*list
, const char *host
,
299 struct bgp_debug_filter
*filter
;
300 struct listnode
*node
, *nnode
;
302 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
303 if (host
&& strcmp(filter
->host
, host
) == 0) {
304 listnode_delete(list
, filter
);
305 XFREE(MTYPE_BGP_DEBUG_STR
, filter
->host
);
306 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
308 } else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
309 && prefix_match(filter
->p
, p
)) {
310 listnode_delete(list
, filter
);
311 prefix_free(filter
->p
);
312 XFREE(MTYPE_BGP_DEBUG_FILTER
, filter
);
320 static int bgp_debug_list_has_entry(struct list
*list
, const char *host
,
321 const struct prefix
*p
)
323 struct bgp_debug_filter
*filter
;
324 struct listnode
*node
, *nnode
;
326 for (ALL_LIST_ELEMENTS(list
, node
, nnode
, filter
)) {
328 if (strcmp(filter
->host
, host
) == 0) {
332 if (filter
->p
->prefixlen
== p
->prefixlen
333 && prefix_match(filter
->p
, p
)) {
342 int bgp_debug_peer_updout_enabled(char *host
)
344 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
348 /* Dump attribute. */
349 int bgp_dump_attr(struct attr
*attr
, char *buf
, size_t size
)
351 char addrbuf
[BUFSIZ
];
356 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
)))
357 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
359 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGIN
)))
360 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", origin %s",
361 bgp_origin_str
[attr
->origin
]);
364 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
365 || attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
366 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
368 inet_ntop(AF_INET6
, &attr
->mp_nexthop_global
, addrbuf
,
371 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
372 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), "(%s)",
373 inet_ntop(AF_INET6
, &attr
->mp_nexthop_local
, addrbuf
,
376 if (attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
)
377 snprintf(buf
, size
, "nexthop %s", inet_ntoa(attr
->nexthop
));
379 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
)))
380 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
381 ", localpref %u", attr
->local_pref
);
383 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
)))
384 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", metric %u",
387 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
)))
388 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
390 community_str(attr
->community
, false));
392 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
)))
393 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
394 ", extcommunity %s", ecommunity_str(attr
->ecommunity
));
396 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
)))
397 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
398 ", atomic-aggregate");
400 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)))
401 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
402 ", aggregated by %u %s", attr
->aggregator_as
,
403 inet_ntoa(attr
->aggregator_addr
));
405 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)))
406 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
407 ", originator %s", inet_ntoa(attr
->originator_id
));
409 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))) {
412 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
414 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
415 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), " %s",
416 inet_ntoa(attr
->cluster
->list
[i
]));
419 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL
)))
420 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
421 ", pmsi tnltype %u", attr
->pmsi_tnl_type
);
423 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH
)))
424 snprintf(buf
+ strlen(buf
), size
- strlen(buf
), ", path %s",
425 aspath_print(attr
->aspath
));
427 if (CHECK_FLAG(attr
->flag
, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
))) {
428 if (attr
->label_index
!= BGP_INVALID_LABEL_INDEX
)
429 snprintf(buf
+ strlen(buf
), size
- strlen(buf
),
430 ", label-index %u", attr
->label_index
);
439 const char *bgp_notify_code_str(char code
)
441 return lookup_msg(bgp_notify_msg
, code
, "Unrecognized Error Code");
444 const char *bgp_notify_subcode_str(char code
, char subcode
)
448 case BGP_NOTIFY_HEADER_ERR
:
449 return lookup_msg(bgp_notify_head_msg
, subcode
,
450 "Unrecognized Error Subcode");
451 case BGP_NOTIFY_OPEN_ERR
:
452 return lookup_msg(bgp_notify_open_msg
, subcode
,
453 "Unrecognized Error Subcode");
454 case BGP_NOTIFY_UPDATE_ERR
:
455 return lookup_msg(bgp_notify_update_msg
, subcode
,
456 "Unrecognized Error Subcode");
457 case BGP_NOTIFY_HOLD_ERR
:
459 case BGP_NOTIFY_FSM_ERR
:
461 case BGP_NOTIFY_CEASE
:
462 return lookup_msg(bgp_notify_cease_msg
, subcode
,
463 "Unrecognized Error Subcode");
464 case BGP_NOTIFY_CAPABILITY_ERR
:
465 return lookup_msg(bgp_notify_capability_msg
, subcode
,
466 "Unrecognized Error Subcode");
471 /* extract notify admin reason if correctly present */
472 const char *bgp_notify_admin_message(char *buf
, size_t bufsz
, u_char
*data
,
475 if (!data
|| datalen
< 1)
478 u_char len
= data
[0];
479 if (len
> 128 || len
> datalen
- 1)
482 return zlog_sanitize(buf
, bufsz
, data
+ 1, len
);
485 /* dump notify packet */
486 void bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
489 const char *subcode_str
;
490 const char *code_str
;
491 const char *msg_str
= NULL
;
494 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)
495 || bgp_flag_check(peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)) {
496 code_str
= bgp_notify_code_str(bgp_notify
->code
);
497 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
,
498 bgp_notify
->subcode
);
500 if (bgp_notify
->code
== BGP_NOTIFY_CEASE
501 && (bgp_notify
->subcode
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
502 || bgp_notify
->subcode
503 == BGP_NOTIFY_CEASE_ADMIN_RESET
)) {
504 msg_str
= bgp_notify_admin_message(
505 msg_buf
, sizeof(msg_buf
), bgp_notify
->raw_data
,
511 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) \"%s\"",
512 strcmp(direct
, "received") == 0
515 peer
->host
, bgp_notify
->code
,
516 bgp_notify
->subcode
, code_str
, subcode_str
,
519 msg_str
= bgp_notify
->data
? bgp_notify
->data
: "";
521 "%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
522 strcmp(direct
, "received") == 0
525 peer
->host
, bgp_notify
->code
,
526 bgp_notify
->subcode
, code_str
, subcode_str
,
527 bgp_notify
->length
, msg_str
);
532 static void bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
535 bgp
= bgp_get_default();
536 update_group_walk(bgp
, update_group_clear_update_dbg
, NULL
);
540 /* Debug option setting interface. */
541 unsigned long bgp_debug_option
= 0;
543 int debug(unsigned int option
)
545 return bgp_debug_option
& option
;
548 DEFUN (debug_bgp_as4
,
555 if (vty
->node
== CONFIG_NODE
)
558 TERM_DEBUG_ON(as4
, AS4
);
559 vty_out(vty
, "BGP as4 debugging is on\n");
564 DEFUN (no_debug_bgp_as4
,
565 no_debug_bgp_as4_cmd
,
572 if (vty
->node
== CONFIG_NODE
)
575 TERM_DEBUG_OFF(as4
, AS4
);
576 vty_out(vty
, "BGP as4 debugging is off\n");
581 DEFUN (debug_bgp_as4_segment
,
582 debug_bgp_as4_segment_cmd
,
583 "debug bgp as4 segment",
587 "BGP AS4 aspath segment handling\n")
589 if (vty
->node
== CONFIG_NODE
)
590 DEBUG_ON(as4
, AS4_SEGMENT
);
592 TERM_DEBUG_ON(as4
, AS4_SEGMENT
);
593 vty_out(vty
, "BGP as4 segment debugging is on\n");
598 DEFUN (no_debug_bgp_as4_segment
,
599 no_debug_bgp_as4_segment_cmd
,
600 "no debug bgp as4 segment",
605 "BGP AS4 aspath segment handling\n")
607 if (vty
->node
== CONFIG_NODE
)
608 DEBUG_OFF(as4
, AS4_SEGMENT
);
610 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
611 vty_out(vty
, "BGP as4 segment debugging is off\n");
616 /* debug bgp neighbor_events */
617 DEFUN (debug_bgp_neighbor_events
,
618 debug_bgp_neighbor_events_cmd
,
619 "debug bgp neighbor-events",
622 "BGP Neighbor Events\n")
624 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
626 if (vty
->node
== CONFIG_NODE
)
627 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
629 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
630 vty_out(vty
, "BGP neighbor-events debugging is on\n");
635 DEFUN (debug_bgp_neighbor_events_peer
,
636 debug_bgp_neighbor_events_peer_cmd
,
637 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
640 "BGP Neighbor Events\n"
641 "BGP neighbor IP address to debug\n"
642 "BGP IPv6 neighbor to debug\n"
643 "BGP neighbor on interface to debug\n")
646 const char *host
= argv
[idx_peer
]->arg
;
648 if (!bgp_debug_neighbor_events_peers
)
649 bgp_debug_neighbor_events_peers
= list_new();
651 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
,
654 "BGP neighbor-events debugging is already enabled for %s\n",
659 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
661 if (vty
->node
== CONFIG_NODE
)
662 DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
664 TERM_DEBUG_ON(neighbor_events
, NEIGHBOR_EVENTS
);
665 vty_out(vty
, "BGP neighbor-events debugging is on for %s\n",
671 DEFUN (no_debug_bgp_neighbor_events
,
672 no_debug_bgp_neighbor_events_cmd
,
673 "no debug bgp neighbor-events",
679 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
681 if (vty
->node
== CONFIG_NODE
)
682 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
684 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
685 vty_out(vty
, "BGP neighbor-events debugging is off\n");
690 DEFUN (no_debug_bgp_neighbor_events_peer
,
691 no_debug_bgp_neighbor_events_peer_cmd
,
692 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
697 "BGP neighbor IP address to debug\n"
698 "BGP IPv6 neighbor to debug\n"
699 "BGP neighbor on interface to debug\n")
703 const char *host
= argv
[idx_peer
]->arg
;
705 if (bgp_debug_neighbor_events_peers
706 && !list_isempty(bgp_debug_neighbor_events_peers
)) {
707 found_peer
= bgp_debug_list_remove_entry(
708 bgp_debug_neighbor_events_peers
, host
, NULL
);
710 if (list_isempty(bgp_debug_neighbor_events_peers
)) {
711 if (vty
->node
== CONFIG_NODE
)
712 DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
714 TERM_DEBUG_OFF(neighbor_events
,
720 vty_out(vty
, "BGP neighbor-events debugging is off for %s\n",
724 "BGP neighbor-events debugging was not enabled for %s\n",
731 DEFUN (debug_bgp_nht
,
736 "BGP nexthop tracking events\n")
738 if (vty
->node
== CONFIG_NODE
)
741 TERM_DEBUG_ON(nht
, NHT
);
742 vty_out(vty
, "BGP nexthop tracking debugging is on\n");
747 DEFUN (no_debug_bgp_nht
,
748 no_debug_bgp_nht_cmd
,
753 "BGP nexthop tracking events\n")
755 if (vty
->node
== CONFIG_NODE
)
758 TERM_DEBUG_OFF(nht
, NHT
);
759 vty_out(vty
, "BGP nexthop tracking debugging is off\n");
764 /* debug bgp keepalives */
765 DEFUN (debug_bgp_keepalive
,
766 debug_bgp_keepalive_cmd
,
767 "debug bgp keepalives",
772 bgp_debug_list_free(bgp_debug_keepalive_peers
);
774 if (vty
->node
== CONFIG_NODE
)
775 DEBUG_ON(keepalive
, KEEPALIVE
);
777 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
778 vty_out(vty
, "BGP keepalives debugging is on\n");
783 DEFUN (debug_bgp_keepalive_peer
,
784 debug_bgp_keepalive_peer_cmd
,
785 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
788 "BGP Neighbor Events\n"
789 "BGP neighbor IP address to debug\n"
790 "BGP IPv6 neighbor to debug\n"
791 "BGP neighbor on interface to debug\n")
794 const char *host
= argv
[idx_peer
]->arg
;
796 if (!bgp_debug_keepalive_peers
)
797 bgp_debug_keepalive_peers
= list_new();
799 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
)) {
801 "BGP keepalive debugging is already enabled for %s\n",
806 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
808 if (vty
->node
== CONFIG_NODE
)
809 DEBUG_ON(keepalive
, KEEPALIVE
);
811 TERM_DEBUG_ON(keepalive
, KEEPALIVE
);
812 vty_out(vty
, "BGP keepalives debugging is on for %s\n", host
);
817 DEFUN (no_debug_bgp_keepalive
,
818 no_debug_bgp_keepalive_cmd
,
819 "no debug bgp keepalives",
825 bgp_debug_list_free(bgp_debug_keepalive_peers
);
827 if (vty
->node
== CONFIG_NODE
)
828 DEBUG_OFF(keepalive
, KEEPALIVE
);
830 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
831 vty_out(vty
, "BGP keepalives debugging is off\n");
836 DEFUN (no_debug_bgp_keepalive_peer
,
837 no_debug_bgp_keepalive_peer_cmd
,
838 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
843 "BGP neighbor IP address to debug\n"
844 "BGP IPv6 neighbor to debug\n"
845 "BGP neighbor on interface to debug\n")
849 const char *host
= argv
[idx_peer
]->arg
;
851 if (bgp_debug_keepalive_peers
852 && !list_isempty(bgp_debug_keepalive_peers
)) {
853 found_peer
= bgp_debug_list_remove_entry(
854 bgp_debug_keepalive_peers
, host
, NULL
);
856 if (list_isempty(bgp_debug_keepalive_peers
)) {
857 if (vty
->node
== CONFIG_NODE
)
858 DEBUG_OFF(keepalive
, KEEPALIVE
);
860 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
865 vty_out(vty
, "BGP keepalives debugging is off for %s\n", host
);
868 "BGP keepalives debugging was not enabled for %s\n",
874 /* debug bgp bestpath */
875 DEFUN (debug_bgp_bestpath_prefix
,
876 debug_bgp_bestpath_prefix_cmd
,
877 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
884 struct prefix
*argv_p
;
885 int idx_ipv4_ipv6_prefixlen
= 3;
887 argv_p
= prefix_new();
888 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
891 if (!bgp_debug_bestpath_prefixes
)
892 bgp_debug_bestpath_prefixes
= list_new();
894 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
,
897 "BGP bestpath debugging is already enabled for %s\n",
898 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
902 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
904 if (vty
->node
== CONFIG_NODE
) {
905 DEBUG_ON(bestpath
, BESTPATH
);
907 TERM_DEBUG_ON(bestpath
, BESTPATH
);
908 vty_out(vty
, "BGP bestpath debugging is on for %s\n",
909 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
915 DEFUN (no_debug_bgp_bestpath_prefix
,
916 no_debug_bgp_bestpath_prefix_cmd
,
917 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
925 int idx_ipv4_ipv6_prefixlen
= 4;
926 struct prefix
*argv_p
;
927 int found_prefix
= 0;
929 argv_p
= prefix_new();
930 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
933 if (bgp_debug_bestpath_prefixes
934 && !list_isempty(bgp_debug_bestpath_prefixes
)) {
935 found_prefix
= bgp_debug_list_remove_entry(
936 bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
938 if (list_isempty(bgp_debug_bestpath_prefixes
)) {
939 if (vty
->node
== CONFIG_NODE
) {
940 DEBUG_OFF(bestpath
, BESTPATH
);
942 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
944 "BGP bestpath debugging (per prefix) is off\n");
950 vty_out(vty
, "BGP bestpath debugging is off for %s\n",
951 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
953 vty_out(vty
, "BGP bestpath debugging was not enabled for %s\n",
954 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
959 DEFUN (no_debug_bgp_bestpath
,
960 no_debug_bgp_bestpath_cmd
,
961 "no debug bgp bestpath",
967 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
969 if (vty
->node
== CONFIG_NODE
)
970 DEBUG_OFF(bestpath
, BESTPATH
);
972 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
973 vty_out(vty
, "BGP bestpath debugging is off\n");
978 /* debug bgp updates */
979 DEFUN (debug_bgp_update
,
980 debug_bgp_update_cmd
,
986 bgp_debug_list_free(bgp_debug_update_in_peers
);
987 bgp_debug_list_free(bgp_debug_update_out_peers
);
988 bgp_debug_list_free(bgp_debug_update_prefixes
);
990 if (vty
->node
== CONFIG_NODE
) {
991 DEBUG_ON(update
, UPDATE_IN
);
992 DEBUG_ON(update
, UPDATE_OUT
);
994 TERM_DEBUG_ON(update
, UPDATE_IN
);
995 TERM_DEBUG_ON(update
, UPDATE_OUT
);
996 vty_out(vty
, "BGP updates debugging is on\n");
1001 DEFUN (debug_bgp_update_direct
,
1002 debug_bgp_update_direct_cmd
,
1003 "debug bgp updates <in|out>",
1008 "Outbound updates\n")
1012 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1013 bgp_debug_list_free(bgp_debug_update_in_peers
);
1015 bgp_debug_list_free(bgp_debug_update_out_peers
);
1017 if (vty
->node
== CONFIG_NODE
) {
1018 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1019 DEBUG_ON(update
, UPDATE_IN
);
1021 DEBUG_ON(update
, UPDATE_OUT
);
1023 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1024 TERM_DEBUG_ON(update
, UPDATE_IN
);
1025 vty_out(vty
, "BGP updates debugging is on (inbound)\n");
1027 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1029 "BGP updates debugging is on (outbound)\n");
1035 DEFUN (debug_bgp_update_direct_peer
,
1036 debug_bgp_update_direct_peer_cmd
,
1037 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1042 "Outbound updates\n"
1043 "BGP neighbor IP address to debug\n"
1044 "BGP IPv6 neighbor to debug\n"
1045 "BGP neighbor on interface to debug\n")
1049 const char *host
= argv
[idx_peer
]->arg
;
1052 if (!bgp_debug_update_in_peers
)
1053 bgp_debug_update_in_peers
= list_new();
1055 if (!bgp_debug_update_out_peers
)
1056 bgp_debug_update_out_peers
= list_new();
1058 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1064 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
,
1067 "BGP inbound update debugging is already enabled for %s\n",
1074 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
,
1077 "BGP outbound update debugging is already enabled for %s\n",
1084 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1087 struct peer_af
*paf
;
1090 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
,
1092 peer
= bgp_find_peer(vty
, host
);
1095 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1097 paf
= peer
->peer_af_array
[afidx
];
1099 if (PAF_SUBGRP(paf
)) {
1109 if (vty
->node
== CONFIG_NODE
) {
1111 DEBUG_ON(update
, UPDATE_IN
);
1113 DEBUG_ON(update
, UPDATE_OUT
);
1116 TERM_DEBUG_ON(update
, UPDATE_IN
);
1118 "BGP updates debugging is on (inbound) for %s\n",
1119 argv
[idx_peer
]->arg
);
1121 TERM_DEBUG_ON(update
, UPDATE_OUT
);
1123 "BGP updates debugging is on (outbound) for %s\n",
1124 argv
[idx_peer
]->arg
);
1130 DEFUN (no_debug_bgp_update_direct
,
1131 no_debug_bgp_update_direct_cmd
,
1132 "no debug bgp updates <in|out>",
1138 "Outbound updates\n")
1141 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0) {
1142 bgp_debug_list_free(bgp_debug_update_in_peers
);
1144 if (vty
->node
== CONFIG_NODE
) {
1145 DEBUG_OFF(update
, UPDATE_IN
);
1147 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1149 "BGP updates debugging is off (inbound)\n");
1152 bgp_debug_list_free(bgp_debug_update_out_peers
);
1154 if (vty
->node
== CONFIG_NODE
) {
1155 DEBUG_OFF(update
, UPDATE_OUT
);
1157 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1159 "BGP updates debugging is off (outbound)\n");
1166 DEFUN (no_debug_bgp_update_direct_peer
,
1167 no_debug_bgp_update_direct_peer_cmd
,
1168 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1174 "Outbound updates\n"
1175 "BGP neighbor IP address to debug\n"
1176 "BGP IPv6 neighbor to debug\n"
1177 "BGP neighbor on interface to debug\n")
1183 const char *host
= argv
[idx_peer
]->arg
;
1185 if (strncmp("i", argv
[idx_in_out
]->arg
, 1) == 0)
1190 if (inbound
&& bgp_debug_update_in_peers
1191 && !list_isempty(bgp_debug_update_in_peers
)) {
1192 found_peer
= bgp_debug_list_remove_entry(
1193 bgp_debug_update_in_peers
, host
, NULL
);
1195 if (list_isempty(bgp_debug_update_in_peers
)) {
1196 if (vty
->node
== CONFIG_NODE
)
1197 DEBUG_OFF(update
, UPDATE_IN
);
1199 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1201 "BGP updates debugging (inbound) is off\n");
1206 if (!inbound
&& bgp_debug_update_out_peers
1207 && !list_isempty(bgp_debug_update_out_peers
)) {
1208 found_peer
= bgp_debug_list_remove_entry(
1209 bgp_debug_update_out_peers
, host
, NULL
);
1211 if (list_isempty(bgp_debug_update_out_peers
)) {
1212 if (vty
->node
== CONFIG_NODE
)
1213 DEBUG_OFF(update
, UPDATE_OUT
);
1215 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1217 "BGP updates debugging (outbound) is off\n");
1222 struct peer_af
*paf
;
1224 peer
= bgp_find_peer(vty
, host
);
1227 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
;
1229 paf
= peer
->peer_af_array
[afidx
];
1231 if (PAF_SUBGRP(paf
)) {
1232 UPDGRP_PEER_DBG_DIS(
1244 "BGP updates debugging (inbound) is off for %s\n",
1248 "BGP updates debugging (outbound) is off for %s\n",
1252 "BGP updates debugging (inbound) was not enabled for %s\n",
1256 "BGP updates debugging (outbound) was not enabled for %s\n",
1262 DEFUN (debug_bgp_update_prefix
,
1263 debug_bgp_update_prefix_cmd
,
1264 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1268 "Specify a prefix to debug\n"
1272 int idx_ipv4_ipv6_prefixlen
= 4;
1273 struct prefix
*argv_p
;
1275 argv_p
= prefix_new();
1276 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1279 if (!bgp_debug_update_prefixes
)
1280 bgp_debug_update_prefixes
= list_new();
1282 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
)) {
1284 "BGP updates debugging is already enabled for %s\n",
1285 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1289 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1291 if (vty
->node
== CONFIG_NODE
) {
1292 DEBUG_ON(update
, UPDATE_PREFIX
);
1294 TERM_DEBUG_ON(update
, UPDATE_PREFIX
);
1295 vty_out(vty
, "BGP updates debugging is on for %s\n",
1296 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1302 DEFUN (no_debug_bgp_update_prefix
,
1303 no_debug_bgp_update_prefix_cmd
,
1304 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1309 "Specify a prefix to debug\n"
1313 int idx_ipv4_ipv6_prefixlen
= 5;
1314 struct prefix
*argv_p
;
1315 int found_prefix
= 0;
1317 argv_p
= prefix_new();
1318 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1321 if (bgp_debug_update_prefixes
1322 && !list_isempty(bgp_debug_update_prefixes
)) {
1323 found_prefix
= bgp_debug_list_remove_entry(
1324 bgp_debug_update_prefixes
, NULL
, argv_p
);
1326 if (list_isempty(bgp_debug_update_prefixes
)) {
1327 if (vty
->node
== CONFIG_NODE
) {
1328 DEBUG_OFF(update
, UPDATE_PREFIX
);
1330 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1332 "BGP updates debugging (per prefix) is off\n");
1338 vty_out(vty
, "BGP updates debugging is off for %s\n",
1339 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1341 vty_out(vty
, "BGP updates debugging was not enabled for %s\n",
1342 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1347 DEFUN (no_debug_bgp_update
,
1348 no_debug_bgp_update_cmd
,
1349 "no debug bgp updates",
1355 struct listnode
*ln
;
1358 bgp_debug_list_free(bgp_debug_update_in_peers
);
1359 bgp_debug_list_free(bgp_debug_update_out_peers
);
1360 bgp_debug_list_free(bgp_debug_update_prefixes
);
1362 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1363 bgp_debug_clear_updgrp_update_dbg(bgp
);
1365 if (vty
->node
== CONFIG_NODE
) {
1366 DEBUG_OFF(update
, UPDATE_IN
);
1367 DEBUG_OFF(update
, UPDATE_OUT
);
1368 DEBUG_OFF(update
, UPDATE_PREFIX
);
1370 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1371 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1372 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1373 vty_out(vty
, "BGP updates debugging is off\n");
1378 /* debug bgp zebra */
1379 DEFUN (debug_bgp_zebra
,
1380 debug_bgp_zebra_cmd
,
1384 "BGP Zebra messages\n")
1386 if (vty
->node
== CONFIG_NODE
)
1387 DEBUG_ON(zebra
, ZEBRA
);
1389 TERM_DEBUG_ON(zebra
, ZEBRA
);
1390 vty_out(vty
, "BGP zebra debugging is on\n");
1395 DEFUN (debug_bgp_zebra_prefix
,
1396 debug_bgp_zebra_prefix_cmd
,
1397 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1400 "BGP Zebra messages\n"
1401 "Specify a prefix to debug\n"
1405 int idx_ipv4_ipv6_prefixlen
= 4;
1406 struct prefix
*argv_p
;
1408 argv_p
= prefix_new();
1409 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1412 if (!bgp_debug_zebra_prefixes
)
1413 bgp_debug_zebra_prefixes
= list_new();
1415 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
)) {
1416 vty_out(vty
, "BGP zebra debugging is already enabled for %s\n",
1417 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1421 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1423 if (vty
->node
== CONFIG_NODE
)
1424 DEBUG_ON(zebra
, ZEBRA
);
1426 TERM_DEBUG_ON(zebra
, ZEBRA
);
1427 vty_out(vty
, "BGP zebra debugging is on for %s\n",
1428 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1434 DEFUN (no_debug_bgp_zebra
,
1435 no_debug_bgp_zebra_cmd
,
1436 "no debug bgp zebra",
1440 "BGP Zebra messages\n")
1442 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1444 if (vty
->node
== CONFIG_NODE
)
1445 DEBUG_OFF(zebra
, ZEBRA
);
1447 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1448 vty_out(vty
, "BGP zebra debugging is off\n");
1453 DEFUN (no_debug_bgp_zebra_prefix
,
1454 no_debug_bgp_zebra_prefix_cmd
,
1455 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1459 "BGP Zebra messages\n"
1460 "Specify a prefix to debug\n"
1464 int idx_ipv4_ipv6_prefixlen
= 5;
1465 struct prefix
*argv_p
;
1466 int found_prefix
= 0;
1468 argv_p
= prefix_new();
1469 (void)str2prefix(argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1472 if (bgp_debug_zebra_prefixes
1473 && !list_isempty(bgp_debug_zebra_prefixes
)) {
1474 found_prefix
= bgp_debug_list_remove_entry(
1475 bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1477 if (list_isempty(bgp_debug_zebra_prefixes
)) {
1478 if (vty
->node
== CONFIG_NODE
)
1479 DEBUG_OFF(zebra
, ZEBRA
);
1481 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1482 vty_out(vty
, "BGP zebra debugging is off\n");
1488 vty_out(vty
, "BGP zebra debugging is off for %s\n",
1489 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1491 vty_out(vty
, "BGP zebra debugging was not enabled for %s\n",
1492 argv
[idx_ipv4_ipv6_prefixlen
]->arg
);
1497 DEFUN (debug_bgp_allow_martians
,
1498 debug_bgp_allow_martians_cmd
,
1499 "debug bgp allow-martians",
1502 "BGP allow martian next hops\n")
1504 if (vty
->node
== CONFIG_NODE
)
1505 DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1507 TERM_DEBUG_ON(allow_martians
, ALLOW_MARTIANS
);
1508 vty_out(vty
, "BGP allow_martian next hop debugging is on\n");
1513 DEFUN (no_debug_bgp_allow_martians
,
1514 no_debug_bgp_allow_martians_cmd
,
1515 "no debug bgp allow-martians",
1519 "BGP allow martian next hops\n")
1521 if (vty
->node
== CONFIG_NODE
)
1522 DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1524 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1525 vty_out(vty
, "BGP allow martian next hop debugging is off\n");
1531 /* debug bgp update-groups */
1532 DEFUN (debug_bgp_update_groups
,
1533 debug_bgp_update_groups_cmd
,
1534 "debug bgp update-groups",
1537 "BGP update-groups\n")
1539 if (vty
->node
== CONFIG_NODE
)
1540 DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1542 TERM_DEBUG_ON(update_groups
, UPDATE_GROUPS
);
1543 vty_out(vty
, "BGP update-groups debugging is on\n");
1548 DEFUN (no_debug_bgp_update_groups
,
1549 no_debug_bgp_update_groups_cmd
,
1550 "no debug bgp update-groups",
1554 "BGP update-groups\n")
1556 if (vty
->node
== CONFIG_NODE
)
1557 DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1559 TERM_DEBUG_OFF(update_groups
, UPDATE_GROUPS
);
1560 vty_out(vty
, "BGP update-groups debugging is off\n");
1565 DEFUN (debug_bgp_vpn
,
1567 "debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1571 "leaked from vrf to vpn\n"
1572 "leaked to vrf from vpn\n"
1573 "route-map updates\n"
1578 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1579 if (vty
->node
== CONFIG_NODE
)
1580 DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1582 TERM_DEBUG_ON(vpn
, VPN_LEAK_FROM_VRF
);
1583 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1584 if (vty
->node
== CONFIG_NODE
)
1585 DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1587 TERM_DEBUG_ON(vpn
, VPN_LEAK_TO_VRF
);
1588 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1589 if (vty
->node
== CONFIG_NODE
)
1590 DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1592 TERM_DEBUG_ON(vpn
, VPN_LEAK_RMAP_EVENT
);
1593 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1594 if (vty
->node
== CONFIG_NODE
)
1595 DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1597 TERM_DEBUG_ON(vpn
, VPN_LEAK_LABEL
);
1599 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1600 return CMD_WARNING_CONFIG_FAILED
;
1603 if (vty
->node
!= CONFIG_NODE
)
1604 vty_out(vty
, "enabled debug bgp vpn %s\n", argv
[idx
]->text
);
1609 DEFUN (no_debug_bgp_vpn
,
1610 no_debug_bgp_vpn_cmd
,
1611 "no debug bgp vpn <leak-from-vrf|leak-to-vrf|rmap-event|label>",
1616 "leaked from vrf to vpn\n"
1617 "leaked to vrf from vpn\n"
1618 "route-map updates\n"
1623 if (argv_find(argv
, argc
, "leak-from-vrf", &idx
)) {
1624 if (vty
->node
== CONFIG_NODE
)
1625 DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1627 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1629 } else if (argv_find(argv
, argc
, "leak-to-vrf", &idx
)) {
1630 if (vty
->node
== CONFIG_NODE
)
1631 DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1633 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1634 } else if (argv_find(argv
, argc
, "rmap-event", &idx
)) {
1635 if (vty
->node
== CONFIG_NODE
)
1636 DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1638 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1639 } else if (argv_find(argv
, argc
, "label", &idx
)) {
1640 if (vty
->node
== CONFIG_NODE
)
1641 DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1643 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1645 vty_out(vty
, "%% unknown debug bgp vpn keyword\n");
1646 return CMD_WARNING_CONFIG_FAILED
;
1649 if (vty
->node
!= CONFIG_NODE
)
1650 vty_out(vty
, "disabled debug bgp vpn %s\n", argv
[idx
]->text
);
1655 DEFUN (no_debug_bgp
,
1663 struct listnode
*ln
;
1665 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1666 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1667 bgp_debug_list_free(bgp_debug_update_in_peers
);
1668 bgp_debug_list_free(bgp_debug_update_out_peers
);
1669 bgp_debug_list_free(bgp_debug_update_prefixes
);
1670 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1671 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1673 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, ln
, bgp
))
1674 bgp_debug_clear_updgrp_update_dbg(bgp
);
1676 TERM_DEBUG_OFF(keepalive
, KEEPALIVE
);
1677 TERM_DEBUG_OFF(update
, UPDATE_IN
);
1678 TERM_DEBUG_OFF(update
, UPDATE_OUT
);
1679 TERM_DEBUG_OFF(update
, UPDATE_PREFIX
);
1680 TERM_DEBUG_OFF(bestpath
, BESTPATH
);
1681 TERM_DEBUG_OFF(as4
, AS4
);
1682 TERM_DEBUG_OFF(as4
, AS4_SEGMENT
);
1683 TERM_DEBUG_OFF(neighbor_events
, NEIGHBOR_EVENTS
);
1684 TERM_DEBUG_OFF(zebra
, ZEBRA
);
1685 TERM_DEBUG_OFF(allow_martians
, ALLOW_MARTIANS
);
1686 TERM_DEBUG_OFF(nht
, NHT
);
1687 TERM_DEBUG_OFF(vpn
, VPN_LEAK_FROM_VRF
);
1688 TERM_DEBUG_OFF(vpn
, VPN_LEAK_TO_VRF
);
1689 TERM_DEBUG_OFF(vpn
, VPN_LEAK_RMAP_EVENT
);
1690 TERM_DEBUG_OFF(vpn
, VPN_LEAK_LABEL
);
1691 vty_out(vty
, "All possible debugging has been turned off\n");
1696 DEFUN_NOSH (show_debugging_bgp
,
1697 show_debugging_bgp_cmd
,
1698 "show debugging [bgp]",
1703 vty_out(vty
, "BGP debugging status:\n");
1705 if (BGP_DEBUG(as4
, AS4
))
1706 vty_out(vty
, " BGP as4 debugging is on\n");
1708 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1709 vty_out(vty
, " BGP as4 aspath segment debugging is on\n");
1711 if (BGP_DEBUG(bestpath
, BESTPATH
))
1712 bgp_debug_list_print(vty
, " BGP bestpath debugging is on",
1713 bgp_debug_bestpath_prefixes
);
1715 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1716 bgp_debug_list_print(vty
, " BGP keepalives debugging is on",
1717 bgp_debug_keepalive_peers
);
1719 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1720 bgp_debug_list_print(vty
,
1721 " BGP neighbor-events debugging is on",
1722 bgp_debug_neighbor_events_peers
);
1724 if (BGP_DEBUG(nht
, NHT
))
1725 vty_out(vty
, " BGP next-hop tracking debugging is on\n");
1727 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1728 vty_out(vty
, " BGP update-groups debugging is on\n");
1730 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1731 bgp_debug_list_print(vty
, " BGP updates debugging is on",
1732 bgp_debug_update_prefixes
);
1734 if (BGP_DEBUG(update
, UPDATE_IN
))
1735 bgp_debug_list_print(vty
,
1736 " BGP updates debugging is on (inbound)",
1737 bgp_debug_update_in_peers
);
1739 if (BGP_DEBUG(update
, UPDATE_OUT
))
1740 bgp_debug_list_print(vty
,
1741 " BGP updates debugging is on (outbound)",
1742 bgp_debug_update_out_peers
);
1744 if (BGP_DEBUG(zebra
, ZEBRA
))
1745 bgp_debug_list_print(vty
, " BGP zebra debugging is on",
1746 bgp_debug_zebra_prefixes
);
1748 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1749 vty_out(vty
, " BGP allow martian next hop debugging is on\n");
1751 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1753 " BGP route leak from vrf to vpn debugging is on\n");
1754 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1756 " BGP route leak to vrf from vpn debugging is on\n");
1757 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1758 vty_out(vty
, " BGP vpn route-map event debugging is on\n");
1759 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1760 vty_out(vty
, " BGP vpn label event debugging is on\n");
1766 /* return count of number of debug flags set */
1767 int bgp_debug_count(void)
1770 if (BGP_DEBUG(as4
, AS4
))
1773 if (BGP_DEBUG(as4
, AS4_SEGMENT
))
1776 if (BGP_DEBUG(bestpath
, BESTPATH
))
1779 if (BGP_DEBUG(keepalive
, KEEPALIVE
))
1782 if (BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
))
1785 if (BGP_DEBUG(nht
, NHT
))
1788 if (BGP_DEBUG(update_groups
, UPDATE_GROUPS
))
1791 if (BGP_DEBUG(update
, UPDATE_PREFIX
))
1794 if (BGP_DEBUG(update
, UPDATE_IN
))
1797 if (BGP_DEBUG(update
, UPDATE_OUT
))
1800 if (BGP_DEBUG(zebra
, ZEBRA
))
1803 if (BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
))
1806 if (BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
))
1808 if (BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
))
1810 if (BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
))
1812 if (BGP_DEBUG(vpn
, VPN_LEAK_LABEL
))
1818 static int bgp_config_write_debug(struct vty
*vty
)
1822 if (CONF_BGP_DEBUG(as4
, AS4
)) {
1823 vty_out(vty
, "debug bgp as4\n");
1827 if (CONF_BGP_DEBUG(as4
, AS4_SEGMENT
)) {
1828 vty_out(vty
, "debug bgp as4 segment\n");
1832 if (CONF_BGP_DEBUG(bestpath
, BESTPATH
)) {
1833 write
+= bgp_debug_list_conf_print(vty
, "debug bgp bestpath",
1834 bgp_debug_bestpath_prefixes
);
1837 if (CONF_BGP_DEBUG(keepalive
, KEEPALIVE
)) {
1838 write
+= bgp_debug_list_conf_print(vty
, "debug bgp keepalives",
1839 bgp_debug_keepalive_peers
);
1842 if (CONF_BGP_DEBUG(neighbor_events
, NEIGHBOR_EVENTS
)) {
1843 write
+= bgp_debug_list_conf_print(
1844 vty
, "debug bgp neighbor-events",
1845 bgp_debug_neighbor_events_peers
);
1848 if (CONF_BGP_DEBUG(nht
, NHT
)) {
1849 vty_out(vty
, "debug bgp nht\n");
1853 if (CONF_BGP_DEBUG(update_groups
, UPDATE_GROUPS
)) {
1854 vty_out(vty
, "debug bgp update-groups\n");
1858 if (CONF_BGP_DEBUG(update
, UPDATE_PREFIX
)) {
1859 write
+= bgp_debug_list_conf_print(vty
,
1860 "debug bgp updates prefix",
1861 bgp_debug_update_prefixes
);
1864 if (CONF_BGP_DEBUG(update
, UPDATE_IN
)) {
1865 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates in",
1866 bgp_debug_update_in_peers
);
1869 if (CONF_BGP_DEBUG(update
, UPDATE_OUT
)) {
1870 write
+= bgp_debug_list_conf_print(vty
, "debug bgp updates out",
1871 bgp_debug_update_out_peers
);
1874 if (CONF_BGP_DEBUG(zebra
, ZEBRA
)) {
1875 if (!bgp_debug_zebra_prefixes
1876 || list_isempty(bgp_debug_zebra_prefixes
)) {
1877 vty_out(vty
, "debug bgp zebra\n");
1880 write
+= bgp_debug_list_conf_print(
1881 vty
, "debug bgp zebra prefix",
1882 bgp_debug_zebra_prefixes
);
1886 if (CONF_BGP_DEBUG(allow_martians
, ALLOW_MARTIANS
)) {
1887 vty_out(vty
, "debug bgp allow-martians\n");
1891 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_FROM_VRF
)) {
1892 vty_out(vty
, "debug bgp vpn leak-from-vrf\n");
1895 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_TO_VRF
)) {
1896 vty_out(vty
, "debug bgp vpn leak-to-vrf\n");
1899 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_RMAP_EVENT
)) {
1900 vty_out(vty
, "debug bgp vpn rmap-event\n");
1903 if (CONF_BGP_DEBUG(vpn
, VPN_LEAK_LABEL
)) {
1904 vty_out(vty
, "debug bgp vpn label\n");
1911 static struct cmd_node debug_node
= {DEBUG_NODE
, "", 1};
1913 void bgp_debug_init(void)
1915 install_node(&debug_node
, bgp_config_write_debug
);
1917 install_element(ENABLE_NODE
, &show_debugging_bgp_cmd
);
1919 install_element(ENABLE_NODE
, &debug_bgp_as4_cmd
);
1920 install_element(CONFIG_NODE
, &debug_bgp_as4_cmd
);
1921 install_element(ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1922 install_element(CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1924 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1925 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1926 install_element(ENABLE_NODE
, &debug_bgp_nht_cmd
);
1927 install_element(CONFIG_NODE
, &debug_bgp_nht_cmd
);
1928 install_element(ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1929 install_element(CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1930 install_element(ENABLE_NODE
, &debug_bgp_update_cmd
);
1931 install_element(CONFIG_NODE
, &debug_bgp_update_cmd
);
1932 install_element(ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1933 install_element(CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1934 install_element(ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1935 install_element(CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1936 install_element(ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1937 install_element(CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1938 install_element(ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1939 install_element(CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1941 /* debug bgp updates (in|out) */
1942 install_element(ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1943 install_element(CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1944 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1945 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1947 /* debug bgp updates (in|out) A.B.C.D */
1948 install_element(ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1949 install_element(CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1950 install_element(ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1951 install_element(CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1953 /* debug bgp updates prefix A.B.C.D/M */
1954 install_element(ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1955 install_element(CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1956 install_element(ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1957 install_element(CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1959 /* debug bgp zebra prefix A.B.C.D/M */
1960 install_element(ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1961 install_element(CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1962 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1963 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1965 install_element(ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1966 install_element(CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1967 install_element(ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1968 install_element(CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1970 /* debug bgp neighbor-events A.B.C.D */
1971 install_element(ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1972 install_element(CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1973 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1974 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1976 /* debug bgp keepalive A.B.C.D */
1977 install_element(ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1978 install_element(CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1979 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1980 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1982 install_element(ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1983 install_element(CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1984 install_element(ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1985 install_element(CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1986 install_element(ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1987 install_element(CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1988 install_element(ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1989 install_element(CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1990 install_element(ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1991 install_element(CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1992 install_element(ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1993 install_element(CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1994 install_element(ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1995 install_element(CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1996 install_element(ENABLE_NODE
, &no_debug_bgp_cmd
);
1997 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1998 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1999 install_element(ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2000 install_element(CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
2002 install_element(ENABLE_NODE
, &debug_bgp_vpn_cmd
);
2003 install_element(CONFIG_NODE
, &debug_bgp_vpn_cmd
);
2004 install_element(ENABLE_NODE
, &no_debug_bgp_vpn_cmd
);
2005 install_element(CONFIG_NODE
, &no_debug_bgp_vpn_cmd
);
2008 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
2009 * for BGP_DEBUG_TYPE
2011 static int bgp_debug_per_prefix(struct prefix
*p
,
2012 unsigned long term_bgp_debug_type
,
2013 unsigned int BGP_DEBUG_TYPE
,
2014 struct list
*per_prefix_list
)
2016 struct bgp_debug_filter
*filter
;
2017 struct listnode
*node
, *nnode
;
2019 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2020 /* We are debugging all prefixes so return true */
2021 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
2028 for (ALL_LIST_ELEMENTS(per_prefix_list
, node
, nnode
,
2030 if (filter
->p
->prefixlen
== p
->prefixlen
2031 && prefix_match(filter
->p
, p
))
2041 /* Return true if this peer is on the per_peer_list of peers to debug
2042 * for BGP_DEBUG_TYPE
2044 static int bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
2045 unsigned int BGP_DEBUG_TYPE
,
2046 struct list
*per_peer_list
)
2048 struct bgp_debug_filter
*filter
;
2049 struct listnode
*node
, *nnode
;
2051 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
) {
2052 /* We are debugging all peers so return true */
2053 if (!per_peer_list
|| list_isempty(per_peer_list
))
2060 for (ALL_LIST_ELEMENTS(per_peer_list
, node
, nnode
,
2062 if (strcmp(filter
->host
, host
) == 0)
2072 int bgp_debug_neighbor_events(struct peer
*peer
)
2079 return bgp_debug_per_peer(host
, term_bgp_debug_neighbor_events
,
2080 BGP_DEBUG_NEIGHBOR_EVENTS
,
2081 bgp_debug_neighbor_events_peers
);
2084 int bgp_debug_keepalive(struct peer
*peer
)
2091 return bgp_debug_per_peer(host
, term_bgp_debug_keepalive
,
2092 BGP_DEBUG_KEEPALIVE
,
2093 bgp_debug_keepalive_peers
);
2096 int bgp_debug_update(struct peer
*peer
, struct prefix
*p
,
2097 struct update_group
*updgrp
, unsigned int inbound
)
2105 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2106 BGP_DEBUG_UPDATE_IN
,
2107 bgp_debug_update_in_peers
))
2113 if (bgp_debug_per_peer(host
, term_bgp_debug_update
,
2114 BGP_DEBUG_UPDATE_OUT
,
2115 bgp_debug_update_out_peers
))
2118 /* Check if update debugging implicitly enabled for the group.
2120 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2125 if (BGP_DEBUG(update
, UPDATE_PREFIX
)) {
2126 if (bgp_debug_per_prefix(p
, term_bgp_debug_update
,
2127 BGP_DEBUG_UPDATE_PREFIX
,
2128 bgp_debug_update_prefixes
))
2135 int bgp_debug_bestpath(struct prefix
*p
)
2137 if (BGP_DEBUG(bestpath
, BESTPATH
)) {
2138 if (bgp_debug_per_prefix(p
, term_bgp_debug_bestpath
,
2140 bgp_debug_bestpath_prefixes
))
2147 int bgp_debug_zebra(struct prefix
*p
)
2149 if (BGP_DEBUG(zebra
, ZEBRA
)) {
2150 if (bgp_debug_per_prefix(p
, term_bgp_debug_zebra
,
2152 bgp_debug_zebra_prefixes
))
2159 const char *bgp_debug_rdpfxpath2str(afi_t afi
, safi_t safi
,
2160 struct prefix_rd
*prd
,
2161 union prefixconstptr pu
,
2162 mpls_label_t
*label
, u_int32_t num_labels
,
2163 int addpath_valid
, u_int32_t addpath_id
,
2164 char *str
, int size
)
2166 char rd_buf
[RD_ADDRSTRLEN
];
2167 char pfx_buf
[PREFIX_STRLEN
];
2169 /* ' with addpath ID ' 17
2170 * max strlen of uint32 + 10
2171 * +/- (just in case) + 1
2172 * null terminator + 1
2173 * ============================ 29 */
2174 char pathid_buf
[30];
2176 if (size
< BGP_PRD_PATH_STRLEN
)
2179 /* Note: Path-id is created by default, but only included in update
2181 pathid_buf
[0] = '\0';
2183 snprintf(pathid_buf
, sizeof(pathid_buf
), " with addpath ID %u",
2187 if (bgp_labeled_safi(safi
) && num_labels
) {
2189 if (safi
== SAFI_EVPN
) {
2192 bgp_evpn_label2str(label
, num_labels
, tag_buf2
, 20);
2193 sprintf(tag_buf
, " label %s", tag_buf2
);
2195 u_int32_t label_value
;
2197 label_value
= decode_label(label
);
2198 sprintf(tag_buf
, " label %u", label_value
);
2203 snprintf(str
, size
, "RD %s %s%s%s %s %s",
2204 prefix_rd2str(prd
, rd_buf
, sizeof(rd_buf
)),
2205 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2206 pathid_buf
, afi2str(afi
), safi2str(safi
));
2208 snprintf(str
, size
, "%s%s%s %s %s",
2209 prefix2str(pu
, pfx_buf
, sizeof(pfx_buf
)), tag_buf
,
2210 pathid_buf
, afi2str(afi
), safi2str(safi
));