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
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
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"
42 unsigned long conf_bgp_debug_as4
;
43 unsigned long conf_bgp_debug_neighbor_events
;
44 unsigned long conf_bgp_debug_events
;
45 unsigned long conf_bgp_debug_packet
;
46 unsigned long conf_bgp_debug_filter
;
47 unsigned long conf_bgp_debug_keepalive
;
48 unsigned long conf_bgp_debug_update
;
49 unsigned long conf_bgp_debug_bestpath
;
50 unsigned long conf_bgp_debug_zebra
;
51 unsigned long conf_bgp_debug_allow_martians
;
52 unsigned long conf_bgp_debug_nht
;
53 unsigned long conf_bgp_debug_update_groups
;
55 unsigned long term_bgp_debug_as4
;
56 unsigned long term_bgp_debug_neighbor_events
;
57 unsigned long term_bgp_debug_events
;
58 unsigned long term_bgp_debug_packet
;
59 unsigned long term_bgp_debug_filter
;
60 unsigned long term_bgp_debug_keepalive
;
61 unsigned long term_bgp_debug_update
;
62 unsigned long term_bgp_debug_bestpath
;
63 unsigned long term_bgp_debug_zebra
;
64 unsigned long term_bgp_debug_allow_martians
;
65 unsigned long term_bgp_debug_nht
;
66 unsigned long term_bgp_debug_update_groups
;
68 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
69 struct list
*bgp_debug_keepalive_peers
= NULL
;
70 struct list
*bgp_debug_update_out_peers
= NULL
;
71 struct list
*bgp_debug_update_in_peers
= NULL
;
72 struct list
*bgp_debug_update_prefixes
= NULL
;
73 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
74 struct list
*bgp_debug_zebra_prefixes
= NULL
;
76 /* messages for BGP-4 status */
77 const struct message bgp_status_msg
[] =
80 { Connect
, "Connect" },
82 { OpenSent
, "OpenSent" },
83 { OpenConfirm
, "OpenConfirm" },
84 { Established
, "Established" },
85 { Clearing
, "Clearing" },
86 { Deleted
, "Deleted" },
88 const int bgp_status_msg_max
= BGP_STATUS_MAX
;
90 /* BGP message type string. */
91 const char *bgp_type_str
[] =
102 /* message for BGP-4 Notify */
103 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"},
113 static const int bgp_notify_msg_max
= BGP_NOTIFY_MAX
;
115 static const struct message bgp_notify_head_msg
[] =
117 { BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
118 { BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
119 { BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"}
121 static const int bgp_notify_head_msg_max
= BGP_NOTIFY_HEADER_MAX
;
123 static const struct message bgp_notify_open_msg
[] =
125 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
126 { BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
127 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
128 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
129 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
130 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
131 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
132 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
134 static const int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
136 static const struct message bgp_notify_update_msg
[] =
138 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
139 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
140 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
141 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
142 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
143 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
144 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
145 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
146 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
147 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
148 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
149 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
151 static const int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
153 static const struct message bgp_notify_cease_msg
[] =
155 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
156 { BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
157 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
158 { BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
159 { BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
160 { BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
161 { BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
162 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
, "/Connection collision resolution"},
163 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
165 static const int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
167 static const struct message bgp_notify_capability_msg
[] =
169 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
170 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
171 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
172 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
174 static const int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
176 /* Origin strings. */
177 const char *bgp_origin_str
[] = {"i","e","?"};
178 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
181 /* Given a string return a pointer the corresponding peer structure */
183 bgp_find_peer (struct vty
*vty
, const char *peer_str
)
185 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
193 ret
= str2sockunion (peer_str
, &su
);
198 peer
= peer_lookup_by_conf_if (bgp
, peer_str
);
201 peer
= peer_lookup_by_hostname (bgp
, peer_str
);
206 return peer_lookup (bgp
, &su
);
210 bgp_debug_list_free(struct list
*list
)
212 struct bgp_debug_filter
*filter
;
213 struct listnode
*node
, *nnode
;
216 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
218 listnode_delete (list
, filter
);
221 prefix_free(filter
->p
);
224 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
226 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
230 /* Print the desc along with a list of peers/prefixes this debug is
233 bgp_debug_list_print (struct vty
*vty
, const char *desc
, struct list
*list
)
235 struct bgp_debug_filter
*filter
;
236 struct listnode
*node
, *nnode
;
237 char buf
[INET6_ADDRSTRLEN
];
239 vty_out (vty
, "%s", desc
);
241 if (list
&& !list_isempty(list
))
243 vty_out (vty
, " for");
244 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
247 vty_out (vty
, " %s", filter
->host
);
250 vty_out (vty
, " %s/%d",
251 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
252 filter
->p
->prefixlen
);
256 vty_out (vty
, "%s", VTY_NEWLINE
);
259 /* Print the command to enable the debug for each peer/prefix this debug is
263 bgp_debug_list_conf_print (struct vty
*vty
, const char *desc
, struct list
*list
)
265 struct bgp_debug_filter
*filter
;
266 struct listnode
*node
, *nnode
;
267 char buf
[INET6_ADDRSTRLEN
];
270 if (list
&& !list_isempty(list
))
272 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
276 vty_out (vty
, "%s %s%s", desc
, filter
->host
, VTY_NEWLINE
);
283 vty_out (vty
, "%s %s/%d%s", desc
,
284 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
285 filter
->p
->prefixlen
, VTY_NEWLINE
);
293 vty_out (vty
, "%s%s", desc
, VTY_NEWLINE
);
301 bgp_debug_list_add_entry(struct list
*list
, const char *host
, struct prefix
*p
)
303 struct bgp_debug_filter
*filter
;
305 filter
= XCALLOC (MTYPE_BGP_DEBUG_FILTER
, sizeof (struct bgp_debug_filter
));
309 filter
->host
= XSTRDUP (MTYPE_BGP_DEBUG_STR
, host
);
318 listnode_add(list
, filter
);
322 bgp_debug_list_remove_entry(struct list
*list
, const char *host
, struct prefix
*p
)
324 struct bgp_debug_filter
*filter
;
325 struct listnode
*node
, *nnode
;
327 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
329 if (host
&& strcmp (filter
->host
, host
) == 0)
331 listnode_delete (list
, filter
);
332 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
333 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
336 else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
338 listnode_delete (list
, filter
);
339 prefix_free (filter
->p
);
340 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
349 bgp_debug_list_has_entry(struct list
*list
, const char *host
, struct prefix
*p
)
351 struct bgp_debug_filter
*filter
;
352 struct listnode
*node
, *nnode
;
354 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
358 if (strcmp (filter
->host
, host
) == 0)
365 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
376 bgp_debug_peer_updout_enabled(char *host
)
378 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
));
381 /* Dump attribute. */
383 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
388 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
389 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
391 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
392 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
393 bgp_origin_str
[attr
->origin
]);
398 char addrbuf
[BUFSIZ
];
401 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
402 || attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
403 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
404 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
407 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
408 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
409 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
412 #endif /* HAVE_IPV6 */
414 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
415 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %u",
418 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
419 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %u",
422 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
423 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
424 community_str (attr
->community
));
426 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
427 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
429 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
430 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
431 attr
->extra
->aggregator_as
,
432 inet_ntoa (attr
->extra
->aggregator_addr
));
434 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
435 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
436 inet_ntoa (attr
->extra
->originator_id
));
438 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
442 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
443 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
444 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
445 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
448 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
449 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
450 aspath_print (attr
->aspath
));
452 if (strlen (buf
) > 1)
459 bgp_notify_code_str (char code
)
461 return LOOKUP_DEF (bgp_notify_msg
, code
, "Unrecognized Error Code");
465 bgp_notify_subcode_str (char code
, char subcode
)
470 case BGP_NOTIFY_HEADER_ERR
:
471 return LOOKUP_DEF (bgp_notify_head_msg
, subcode
,
472 "Unrecognized Error Subcode");
473 case BGP_NOTIFY_OPEN_ERR
:
474 return LOOKUP_DEF (bgp_notify_open_msg
, subcode
,
475 "Unrecognized Error Subcode");
476 case BGP_NOTIFY_UPDATE_ERR
:
477 return LOOKUP_DEF (bgp_notify_update_msg
, subcode
,
478 "Unrecognized Error Subcode");
479 case BGP_NOTIFY_HOLD_ERR
:
481 case BGP_NOTIFY_FSM_ERR
:
483 case BGP_NOTIFY_CEASE
:
484 return LOOKUP_DEF (bgp_notify_cease_msg
, subcode
,
485 "Unrecognized Error Subcode");
486 case BGP_NOTIFY_CAPABILITY_ERR
:
487 return LOOKUP_DEF (bgp_notify_capability_msg
, subcode
,
488 "Unrecognized Error Subcode");
493 /* dump notify packet */
495 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
498 const char *subcode_str
;
499 const char *code_str
;
501 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
) || bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
503 code_str
= bgp_notify_code_str(bgp_notify
->code
);
504 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
, bgp_notify
->subcode
);
506 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
507 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
508 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
509 code_str
, subcode_str
, bgp_notify
->length
,
510 bgp_notify
->data
? bgp_notify
->data
: "");
515 bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
518 bgp
= bgp_get_default();
519 update_group_walk (bgp
, update_group_clear_update_dbg
, NULL
);
523 /* Debug option setting interface. */
524 unsigned long bgp_debug_option
= 0;
527 debug (unsigned int option
)
529 return bgp_debug_option
& option
;
532 DEFUN (debug_bgp_as4
,
539 if (vty
->node
== CONFIG_NODE
)
543 TERM_DEBUG_ON (as4
, AS4
);
544 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
549 DEFUN (no_debug_bgp_as4
,
550 no_debug_bgp_as4_cmd
,
557 if (vty
->node
== CONFIG_NODE
)
558 DEBUG_OFF (as4
, AS4
);
561 TERM_DEBUG_OFF (as4
, AS4
);
562 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
567 DEFUN (debug_bgp_as4_segment
,
568 debug_bgp_as4_segment_cmd
,
569 "debug bgp as4 segment",
573 "BGP AS4 aspath segment handling\n")
575 if (vty
->node
== CONFIG_NODE
)
576 DEBUG_ON (as4
, AS4_SEGMENT
);
579 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
580 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
585 DEFUN (no_debug_bgp_as4_segment
,
586 no_debug_bgp_as4_segment_cmd
,
587 "no debug bgp as4 segment",
592 "BGP AS4 aspath segment handling\n")
594 if (vty
->node
== CONFIG_NODE
)
595 DEBUG_OFF (as4
, AS4_SEGMENT
);
598 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
599 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
604 /* debug bgp neighbor_events */
605 DEFUN (debug_bgp_neighbor_events
,
606 debug_bgp_neighbor_events_cmd
,
607 "debug bgp neighbor-events",
610 "BGP Neighbor Events\n")
612 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
614 if (vty
->node
== CONFIG_NODE
)
615 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
618 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
619 vty_out (vty
, "BGP neighbor-events debugging is on%s", VTY_NEWLINE
);
624 DEFUN (debug_bgp_neighbor_events_peer
,
625 debug_bgp_neighbor_events_peer_cmd
,
626 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
629 "BGP Neighbor Events\n"
630 "BGP neighbor IP address to debug\n"
631 "BGP IPv6 neighbor to debug\n"
632 "BGP neighbor on interface to debug\n")
635 const char *host
= argv
[idx_peer
]->arg
;
637 if (!bgp_debug_neighbor_events_peers
)
638 bgp_debug_neighbor_events_peers
= list_new ();
640 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
, NULL
))
642 vty_out (vty
, "BGP neighbor-events debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
646 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
648 if (vty
->node
== CONFIG_NODE
)
649 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
652 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
653 vty_out (vty
, "BGP neighbor-events debugging is on for %s%s", host
, VTY_NEWLINE
);
658 DEFUN (no_debug_bgp_neighbor_events
,
659 no_debug_bgp_neighbor_events_cmd
,
660 "no debug bgp neighbor-events",
666 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
668 if (vty
->node
== CONFIG_NODE
)
669 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
672 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
673 vty_out (vty
, "BGP neighbor-events debugging is off%s", VTY_NEWLINE
);
678 DEFUN (no_debug_bgp_neighbor_events_peer
,
679 no_debug_bgp_neighbor_events_peer_cmd
,
680 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
685 "BGP neighbor IP address to debug\n"
686 "BGP IPv6 neighbor to debug\n"
687 "BGP neighbor on interface to debug\n")
691 const char *host
= argv
[idx_peer
]->arg
;
693 if (bgp_debug_neighbor_events_peers
&& !list_isempty(bgp_debug_neighbor_events_peers
))
695 found_peer
= bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
697 if (list_isempty(bgp_debug_neighbor_events_peers
))
699 if (vty
->node
== CONFIG_NODE
)
700 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
702 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
707 vty_out (vty
, "BGP neighbor-events debugging is off for %s%s", host
, VTY_NEWLINE
);
709 vty_out (vty
, "BGP neighbor-events debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
715 DEFUN (debug_bgp_nht
,
720 "BGP nexthop tracking events\n")
722 if (vty
->node
== CONFIG_NODE
)
726 TERM_DEBUG_ON (nht
, NHT
);
727 vty_out (vty
, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE
);
732 DEFUN (no_debug_bgp_nht
,
733 no_debug_bgp_nht_cmd
,
738 "BGP nexthop tracking events\n")
740 if (vty
->node
== CONFIG_NODE
)
741 DEBUG_OFF (nht
, NHT
);
744 TERM_DEBUG_OFF (nht
, NHT
);
745 vty_out (vty
, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE
);
750 /* debug bgp keepalives */
751 DEFUN (debug_bgp_keepalive
,
752 debug_bgp_keepalive_cmd
,
753 "debug bgp keepalives",
758 bgp_debug_list_free(bgp_debug_keepalive_peers
);
760 if (vty
->node
== CONFIG_NODE
)
761 DEBUG_ON (keepalive
, KEEPALIVE
);
764 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
765 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
770 DEFUN (debug_bgp_keepalive_peer
,
771 debug_bgp_keepalive_peer_cmd
,
772 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
775 "BGP Neighbor Events\n"
776 "BGP neighbor IP address to debug\n"
777 "BGP IPv6 neighbor to debug\n"
778 "BGP neighbor on interface to debug\n")
781 const char *host
= argv
[idx_peer
]->arg
;
783 if (!bgp_debug_keepalive_peers
)
784 bgp_debug_keepalive_peers
= list_new ();
786 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
))
788 vty_out (vty
, "BGP keepalive debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
792 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
794 if (vty
->node
== CONFIG_NODE
)
795 DEBUG_ON (keepalive
, KEEPALIVE
);
798 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
799 vty_out (vty
, "BGP keepalives debugging is on for %s%s", host
, VTY_NEWLINE
);
804 DEFUN (no_debug_bgp_keepalive
,
805 no_debug_bgp_keepalive_cmd
,
806 "no debug bgp keepalives",
812 bgp_debug_list_free(bgp_debug_keepalive_peers
);
814 if (vty
->node
== CONFIG_NODE
)
815 DEBUG_OFF (keepalive
, KEEPALIVE
);
818 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
819 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
824 DEFUN (no_debug_bgp_keepalive_peer
,
825 no_debug_bgp_keepalive_peer_cmd
,
826 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
831 "BGP neighbor IP address to debug\n"
832 "BGP IPv6 neighbor to debug\n"
833 "BGP neighbor on interface to debug\n")
837 const char *host
= argv
[idx_peer
]->arg
;
839 if (bgp_debug_keepalive_peers
&& !list_isempty(bgp_debug_keepalive_peers
))
841 found_peer
= bgp_debug_list_remove_entry(bgp_debug_keepalive_peers
, host
, NULL
);
843 if (list_isempty(bgp_debug_keepalive_peers
))
845 if (vty
->node
== CONFIG_NODE
)
846 DEBUG_OFF (keepalive
, KEEPALIVE
);
848 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
853 vty_out (vty
, "BGP keepalives debugging is off for %s%s", host
, VTY_NEWLINE
);
855 vty_out (vty
, "BGP keepalives debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
860 /* debug bgp bestpath */
861 DEFUN (debug_bgp_bestpath_prefix
,
862 debug_bgp_bestpath_prefix_cmd
,
863 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
871 int idx_ipv4_ipv6_prefixlen
= 3;
872 struct prefix
*argv_p
;
875 argv_p
= prefix_new();
876 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
880 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
885 if (!bgp_debug_bestpath_prefixes
)
886 bgp_debug_bestpath_prefixes
= list_new ();
888 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
))
890 vty_out (vty
, "BGP bestptah debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
894 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
896 if (vty
->node
== CONFIG_NODE
)
898 DEBUG_ON (bestpath
, BESTPATH
);
902 TERM_DEBUG_ON (bestpath
, BESTPATH
);
903 vty_out (vty
, "BGP bestpath debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
909 DEFUN (no_debug_bgp_bestpath_prefix
,
910 no_debug_bgp_bestpath_prefix_cmd
,
911 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
920 int idx_ipv4_ipv6_prefixlen
= 4;
921 struct prefix
*argv_p
;
922 int found_prefix
= 0;
925 argv_p
= prefix_new();
926 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
930 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
934 if (bgp_debug_bestpath_prefixes
&& !list_isempty(bgp_debug_bestpath_prefixes
))
936 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
938 if (list_isempty(bgp_debug_bestpath_prefixes
))
940 if (vty
->node
== CONFIG_NODE
)
942 DEBUG_OFF (bestpath
, BESTPATH
);
946 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
947 vty_out (vty
, "BGP bestpath debugging (per prefix) is off%s", VTY_NEWLINE
);
953 vty_out (vty
, "BGP bestpath debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
955 vty_out (vty
, "BGP bestpath debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
960 DEFUN (no_debug_bgp_bestpath
,
961 no_debug_bgp_bestpath_cmd
,
962 "no debug bgp bestpath",
968 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
970 if (vty
->node
== CONFIG_NODE
)
971 DEBUG_OFF (bestpath
, BESTPATH
);
974 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
975 vty_out (vty
, "BGP bestpath debugging is off%s", VTY_NEWLINE
);
980 /* debug bgp updates */
981 DEFUN (debug_bgp_update
,
982 debug_bgp_update_cmd
,
988 bgp_debug_list_free(bgp_debug_update_in_peers
);
989 bgp_debug_list_free(bgp_debug_update_out_peers
);
990 bgp_debug_list_free(bgp_debug_update_prefixes
);
992 if (vty
->node
== CONFIG_NODE
)
994 DEBUG_ON (update
, UPDATE_IN
);
995 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%s", VTY_NEWLINE
);
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
)
1024 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1025 DEBUG_ON (update
, UPDATE_IN
);
1027 DEBUG_ON (update
, UPDATE_OUT
);
1031 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1033 TERM_DEBUG_ON (update
, UPDATE_IN
);
1034 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
1038 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1039 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
1045 DEFUN (debug_bgp_update_direct_peer
,
1046 debug_bgp_update_direct_peer_cmd
,
1047 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1052 "Outbound updates\n"
1053 "BGP neighbor IP address to debug\n"
1054 "BGP IPv6 neighbor to debug\n"
1055 "BGP neighbor on interface to debug\n")
1059 const char *host
= argv
[idx_peer
]->arg
;
1062 if (!bgp_debug_update_in_peers
)
1063 bgp_debug_update_in_peers
= list_new ();
1065 if (!bgp_debug_update_out_peers
)
1066 bgp_debug_update_out_peers
= list_new ();
1068 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1075 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
, NULL
))
1077 vty_out (vty
, "BGP inbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1084 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
))
1086 vty_out (vty
, "BGP outbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1092 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1096 struct peer_af
*paf
;
1099 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
, NULL
);
1100 peer
= bgp_find_peer (vty
, host
);
1104 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1106 paf
= peer
->peer_af_array
[afidx
];
1109 if (PAF_SUBGRP (paf
))
1111 UPDGRP_PEER_DBG_EN(PAF_SUBGRP(paf
)->update_group
);
1118 if (vty
->node
== CONFIG_NODE
)
1121 DEBUG_ON (update
, UPDATE_IN
);
1123 DEBUG_ON (update
, UPDATE_OUT
);
1129 TERM_DEBUG_ON (update
, UPDATE_IN
);
1130 vty_out (vty
, "BGP updates debugging is on (inbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1134 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1135 vty_out (vty
, "BGP updates debugging is on (outbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1141 DEFUN (no_debug_bgp_update_direct
,
1142 no_debug_bgp_update_direct_cmd
,
1143 "no debug bgp updates <in|out>",
1149 "Outbound updates\n")
1152 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1154 bgp_debug_list_free(bgp_debug_update_in_peers
);
1156 if (vty
->node
== CONFIG_NODE
)
1158 DEBUG_OFF (update
, UPDATE_IN
);
1162 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1163 vty_out (vty
, "BGP updates debugging is off (inbound)%s", VTY_NEWLINE
);
1168 bgp_debug_list_free(bgp_debug_update_out_peers
);
1170 if (vty
->node
== CONFIG_NODE
)
1172 DEBUG_OFF (update
, UPDATE_OUT
);
1176 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1177 vty_out (vty
, "BGP updates debugging is off (outbound)%s", VTY_NEWLINE
);
1184 DEFUN (no_debug_bgp_update_direct_peer
,
1185 no_debug_bgp_update_direct_peer_cmd
,
1186 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1192 "Outbound updates\n"
1193 "BGP neighbor IP address to debug\n"
1194 "BGP IPv6 neighbor to debug\n"
1195 "BGP neighbor on interface to debug\n")
1201 const char *host
= argv
[idx_peer
]->arg
;
1203 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1208 if (inbound
&& bgp_debug_update_in_peers
&&
1209 !list_isempty(bgp_debug_update_in_peers
))
1211 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_in_peers
, host
, NULL
);
1213 if (list_isempty(bgp_debug_update_in_peers
))
1215 if (vty
->node
== CONFIG_NODE
)
1216 DEBUG_OFF (update
, UPDATE_IN
);
1219 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1220 vty_out (vty
, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE
);
1225 if (!inbound
&& bgp_debug_update_out_peers
&&
1226 !list_isempty(bgp_debug_update_out_peers
))
1228 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_out_peers
, host
, NULL
);
1230 if (list_isempty(bgp_debug_update_out_peers
))
1232 if (vty
->node
== CONFIG_NODE
)
1233 DEBUG_OFF (update
, UPDATE_OUT
);
1236 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1237 vty_out (vty
, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE
);
1242 struct peer_af
*paf
;
1244 peer
= bgp_find_peer (vty
, host
);
1248 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1250 paf
= peer
->peer_af_array
[afidx
];
1253 if (PAF_SUBGRP (paf
))
1255 UPDGRP_PEER_DBG_DIS(PAF_SUBGRP(paf
)->update_group
);
1264 vty_out (vty
, "BGP updates debugging (inbound) is off for %s%s", host
, VTY_NEWLINE
);
1266 vty_out (vty
, "BGP updates debugging (outbound) is off for %s%s", host
, VTY_NEWLINE
);
1269 vty_out (vty
, "BGP updates debugging (inbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1271 vty_out (vty
, "BGP updates debugging (outbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1276 DEFUN (debug_bgp_update_prefix
,
1277 debug_bgp_update_prefix_cmd
,
1278 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1282 "Specify a prefix to debug\n"
1287 int idx_ipv4_ipv6_prefixlen
= 4;
1288 struct prefix
*argv_p
;
1291 argv_p
= prefix_new();
1292 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1295 prefix_free(argv_p
);
1296 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1301 if (!bgp_debug_update_prefixes
)
1302 bgp_debug_update_prefixes
= list_new ();
1304 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
))
1306 vty_out (vty
, "BGP updates debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1310 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1312 if (vty
->node
== CONFIG_NODE
)
1314 DEBUG_ON (update
, UPDATE_PREFIX
);
1318 TERM_DEBUG_ON (update
, UPDATE_PREFIX
);
1319 vty_out (vty
, "BGP updates debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1325 DEFUN (no_debug_bgp_update_prefix
,
1326 no_debug_bgp_update_prefix_cmd
,
1327 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1332 "Specify a prefix to debug\n"
1337 int idx_ipv4_ipv6_prefixlen
= 5;
1338 struct prefix
*argv_p
;
1339 int found_prefix
= 0;
1342 argv_p
= prefix_new();
1343 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1346 prefix_free(argv_p
);
1347 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1351 if (bgp_debug_update_prefixes
&& !list_isempty(bgp_debug_update_prefixes
))
1353 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1355 if (list_isempty(bgp_debug_update_prefixes
))
1357 if (vty
->node
== CONFIG_NODE
)
1359 DEBUG_OFF (update
, UPDATE_PREFIX
);
1363 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1364 vty_out (vty
, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE
);
1370 vty_out (vty
, "BGP updates debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1372 vty_out (vty
, "BGP updates debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1377 DEFUN (no_debug_bgp_update
,
1378 no_debug_bgp_update_cmd
,
1379 "no debug bgp updates",
1385 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1386 bgp_debug_list_free(bgp_debug_update_in_peers
);
1387 bgp_debug_list_free(bgp_debug_update_out_peers
);
1388 bgp_debug_list_free(bgp_debug_update_prefixes
);
1390 bgp_debug_clear_updgrp_update_dbg(bgp
);
1392 if (vty
->node
== CONFIG_NODE
)
1394 DEBUG_OFF (update
, UPDATE_IN
);
1395 DEBUG_OFF (update
, UPDATE_OUT
);
1396 DEBUG_OFF (update
, UPDATE_PREFIX
);
1400 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1401 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1402 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1403 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
1408 /* debug bgp zebra */
1409 DEFUN (debug_bgp_zebra
,
1410 debug_bgp_zebra_cmd
,
1414 "BGP Zebra messages\n")
1416 if (vty
->node
== CONFIG_NODE
)
1417 DEBUG_ON (zebra
, ZEBRA
);
1420 TERM_DEBUG_ON (zebra
, ZEBRA
);
1421 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
1426 DEFUN (debug_bgp_zebra_prefix
,
1427 debug_bgp_zebra_prefix_cmd
,
1428 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1431 "BGP Zebra messages\n"
1432 "Specify a prefix to debug\n"
1437 int idx_ipv4_ipv6_prefixlen
= 4;
1438 struct prefix
*argv_p
;
1441 argv_p
= prefix_new();
1442 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1445 prefix_free(argv_p
);
1446 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1450 if (!bgp_debug_zebra_prefixes
)
1451 bgp_debug_zebra_prefixes
= list_new();
1453 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
))
1455 vty_out (vty
, "BGP zebra debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1459 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1461 if (vty
->node
== CONFIG_NODE
)
1462 DEBUG_ON (zebra
, ZEBRA
);
1465 TERM_DEBUG_ON (zebra
, ZEBRA
);
1466 vty_out (vty
, "BGP zebra debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1472 DEFUN (no_debug_bgp_zebra
,
1473 no_debug_bgp_zebra_cmd
,
1474 "no debug bgp zebra",
1478 "BGP Zebra messages\n")
1480 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1482 if (vty
->node
== CONFIG_NODE
)
1483 DEBUG_OFF (zebra
, ZEBRA
);
1486 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1487 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1492 DEFUN (no_debug_bgp_zebra_prefix
,
1493 no_debug_bgp_zebra_prefix_cmd
,
1494 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1498 "BGP Zebra messages\n"
1499 "Specify a prefix to debug\n"
1504 int idx_ipv4_ipv6_prefixlen
= 5;
1505 struct prefix
*argv_p
;
1506 int found_prefix
= 0;
1509 argv_p
= prefix_new();
1510 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1513 prefix_free(argv_p
);
1514 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1518 if (bgp_debug_zebra_prefixes
&& !list_isempty(bgp_debug_zebra_prefixes
))
1520 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1522 if (list_isempty(bgp_debug_zebra_prefixes
))
1524 if (vty
->node
== CONFIG_NODE
)
1525 DEBUG_OFF (zebra
, ZEBRA
);
1528 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1529 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1535 vty_out (vty
, "BGP zebra debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1537 vty_out (vty
, "BGP zebra debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1542 DEFUN (debug_bgp_allow_martians
,
1543 debug_bgp_allow_martians_cmd
,
1544 "debug bgp allow-martians",
1547 "BGP allow martian next hops\n")
1549 if (vty
->node
== CONFIG_NODE
)
1550 DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1553 TERM_DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1554 vty_out (vty
, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE
);
1559 DEFUN (no_debug_bgp_allow_martians
,
1560 no_debug_bgp_allow_martians_cmd
,
1561 "no debug bgp allow-martians",
1565 "BGP allow martian next hops\n")
1567 if (vty
->node
== CONFIG_NODE
)
1568 DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1571 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1572 vty_out (vty
, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE
);
1578 /* debug bgp update-groups */
1579 DEFUN (debug_bgp_update_groups
,
1580 debug_bgp_update_groups_cmd
,
1581 "debug bgp update-groups",
1584 "BGP update-groups\n")
1586 if (vty
->node
== CONFIG_NODE
)
1587 DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1590 TERM_DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1591 vty_out (vty
, "BGP update-groups debugging is on%s", VTY_NEWLINE
);
1596 DEFUN (no_debug_bgp_update_groups
,
1597 no_debug_bgp_update_groups_cmd
,
1598 "no debug bgp update-groups",
1602 "BGP update-groups\n")
1604 if (vty
->node
== CONFIG_NODE
)
1605 DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1608 TERM_DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1609 vty_out (vty
, "BGP update-groups debugging is off%s", VTY_NEWLINE
);
1614 DEFUN (no_debug_bgp
,
1621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1622 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1623 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1624 bgp_debug_list_free(bgp_debug_update_in_peers
);
1625 bgp_debug_list_free(bgp_debug_update_out_peers
);
1626 bgp_debug_list_free(bgp_debug_update_prefixes
);
1627 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1628 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1630 bgp_debug_clear_updgrp_update_dbg(bgp
);
1632 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
1633 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1634 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1635 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1636 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
1637 TERM_DEBUG_OFF (as4
, AS4
);
1638 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
1639 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
1640 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1641 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1642 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
1647 DEFUN (show_debugging_bgp
,
1648 show_debugging_bgp_cmd
,
1649 "show debugging bgp",
1654 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
1656 if (BGP_DEBUG (as4
, AS4
))
1657 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
1659 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1660 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
1662 if (BGP_DEBUG (bestpath
, BESTPATH
))
1663 bgp_debug_list_print (vty
, " BGP bestpath debugging is on",
1664 bgp_debug_bestpath_prefixes
);
1666 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1667 bgp_debug_list_print (vty
, " BGP keepalives debugging is on",
1668 bgp_debug_keepalive_peers
);
1670 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1671 bgp_debug_list_print (vty
, " BGP neighbor-events debugging is on",
1672 bgp_debug_neighbor_events_peers
);
1674 if (BGP_DEBUG (nht
, NHT
))
1675 vty_out (vty
, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE
);
1677 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1678 vty_out (vty
, " BGP update-groups debugging is on%s", VTY_NEWLINE
);
1680 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1681 bgp_debug_list_print (vty
, " BGP updates debugging is on",
1682 bgp_debug_update_prefixes
);
1684 if (BGP_DEBUG (update
, UPDATE_IN
))
1685 bgp_debug_list_print (vty
, " BGP updates debugging is on (inbound)",
1686 bgp_debug_update_in_peers
);
1688 if (BGP_DEBUG (update
, UPDATE_OUT
))
1689 bgp_debug_list_print (vty
, " BGP updates debugging is on (outbound)",
1690 bgp_debug_update_out_peers
);
1692 if (BGP_DEBUG (zebra
, ZEBRA
))
1693 bgp_debug_list_print (vty
, " BGP zebra debugging is on",
1694 bgp_debug_zebra_prefixes
);
1696 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1697 vty_out (vty
, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE
);
1698 vty_out (vty
, "%s", VTY_NEWLINE
);
1702 /* return count of number of debug flags set */
1704 bgp_debug_count(void)
1707 if (BGP_DEBUG (as4
, AS4
))
1710 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1713 if (BGP_DEBUG (bestpath
, BESTPATH
))
1716 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1719 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1722 if (BGP_DEBUG (nht
, NHT
))
1725 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1728 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1731 if (BGP_DEBUG (update
, UPDATE_IN
))
1734 if (BGP_DEBUG (update
, UPDATE_OUT
))
1737 if (BGP_DEBUG (zebra
, ZEBRA
))
1740 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1747 bgp_config_write_debug (struct vty
*vty
)
1751 if (CONF_BGP_DEBUG (as4
, AS4
))
1753 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
1757 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
1759 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
1763 if (CONF_BGP_DEBUG (bestpath
, BESTPATH
))
1765 write
+= bgp_debug_list_conf_print (vty
, "debug bgp bestpath",
1766 bgp_debug_bestpath_prefixes
);
1769 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
1771 write
+= bgp_debug_list_conf_print (vty
, "debug bgp keepalives",
1772 bgp_debug_keepalive_peers
);
1775 if (CONF_BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1777 write
+= bgp_debug_list_conf_print (vty
, "debug bgp neighbor-events",
1778 bgp_debug_neighbor_events_peers
);
1781 if (CONF_BGP_DEBUG (nht
, NHT
))
1783 vty_out (vty
, "debug bgp nht%s", VTY_NEWLINE
);
1787 if (CONF_BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1789 vty_out (vty
, "debug bgp update-groups%s", VTY_NEWLINE
);
1793 if (CONF_BGP_DEBUG (update
, UPDATE_PREFIX
))
1795 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates prefix",
1796 bgp_debug_update_prefixes
);
1799 if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
1801 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates in",
1802 bgp_debug_update_in_peers
);
1805 if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
1807 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates out",
1808 bgp_debug_update_out_peers
);
1811 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
1813 if (!bgp_debug_zebra_prefixes
|| list_isempty(bgp_debug_zebra_prefixes
))
1815 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
1820 write
+= bgp_debug_list_conf_print (vty
, "debug bgp zebra prefix",
1821 bgp_debug_zebra_prefixes
);
1825 if (CONF_BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1827 vty_out (vty
, "debug bgp allow-martians%s", VTY_NEWLINE
);
1834 static struct cmd_node debug_node
=
1842 bgp_debug_init (void)
1844 install_node (&debug_node
, bgp_config_write_debug
);
1846 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
1848 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
1849 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
1850 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1851 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1853 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1854 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1855 install_element (ENABLE_NODE
, &debug_bgp_nht_cmd
);
1856 install_element (CONFIG_NODE
, &debug_bgp_nht_cmd
);
1857 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1858 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1859 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
1860 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
1861 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1862 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1863 install_element (ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1864 install_element (CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1865 install_element (ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1866 install_element (CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1867 install_element (ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1868 install_element (CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1870 /* debug bgp updates (in|out) */
1871 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1872 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1873 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1874 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1876 /* debug bgp updates (in|out) A.B.C.D */
1877 install_element (ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1878 install_element (CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1879 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1880 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1882 /* debug bgp updates prefix A.B.C.D/M */
1883 install_element (ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1884 install_element (CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1885 install_element (ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1886 install_element (CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1888 /* debug bgp zebra prefix A.B.C.D/M */
1889 install_element (ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1890 install_element (CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1891 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1892 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1894 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1895 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1896 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1897 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1899 /* debug bgp neighbor-events A.B.C.D */
1900 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1901 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1902 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1903 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1905 /* debug bgp keepalive A.B.C.D */
1906 install_element (ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1907 install_element (CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1908 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1909 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1911 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1912 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1913 install_element (ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1914 install_element (CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1915 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1916 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1917 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1918 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1919 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1920 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1921 install_element (ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1922 install_element (CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1923 install_element (ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1924 install_element (CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1925 install_element (ENABLE_NODE
, &no_debug_bgp_cmd
);
1926 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1927 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1928 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1929 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1932 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
1933 * for BGP_DEBUG_TYPE
1936 bgp_debug_per_prefix (struct prefix
*p
, unsigned long term_bgp_debug_type
,
1937 unsigned int BGP_DEBUG_TYPE
, struct list
*per_prefix_list
)
1939 struct bgp_debug_filter
*filter
;
1940 struct listnode
*node
, *nnode
;
1942 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1944 /* We are debugging all prefixes so return true */
1945 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
1953 for (ALL_LIST_ELEMENTS (per_prefix_list
, node
, nnode
, filter
))
1954 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
1964 /* Return true if this peer is on the per_peer_list of peers to debug
1965 * for BGP_DEBUG_TYPE
1968 bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
1969 unsigned int BGP_DEBUG_TYPE
, struct list
*per_peer_list
)
1971 struct bgp_debug_filter
*filter
;
1972 struct listnode
*node
, *nnode
;
1974 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1976 /* We are debugging all peers so return true */
1977 if (!per_peer_list
|| list_isempty(per_peer_list
))
1985 for (ALL_LIST_ELEMENTS (per_peer_list
, node
, nnode
, filter
))
1986 if (strcmp (filter
->host
, host
) == 0)
1997 bgp_debug_neighbor_events (struct peer
*peer
)
2004 return bgp_debug_per_peer (host
,
2005 term_bgp_debug_neighbor_events
,
2006 BGP_DEBUG_NEIGHBOR_EVENTS
,
2007 bgp_debug_neighbor_events_peers
);
2011 bgp_debug_keepalive (struct peer
*peer
)
2018 return bgp_debug_per_peer (host
,
2019 term_bgp_debug_keepalive
,
2020 BGP_DEBUG_KEEPALIVE
,
2021 bgp_debug_keepalive_peers
);
2025 bgp_debug_update (struct peer
*peer
, struct prefix
*p
,
2026 struct update_group
*updgrp
, unsigned int inbound
)
2035 if (bgp_debug_per_peer (host
, term_bgp_debug_update
, BGP_DEBUG_UPDATE_IN
,
2036 bgp_debug_update_in_peers
))
2043 if (bgp_debug_per_peer (host
, term_bgp_debug_update
,
2044 BGP_DEBUG_UPDATE_OUT
,
2045 bgp_debug_update_out_peers
))
2048 /* Check if update debugging implicitly enabled for the group. */
2049 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2054 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
2056 if (bgp_debug_per_prefix (p
, term_bgp_debug_update
,
2057 BGP_DEBUG_UPDATE_PREFIX
,
2058 bgp_debug_update_prefixes
))
2066 bgp_debug_bestpath (struct prefix
*p
)
2068 if (BGP_DEBUG (bestpath
, BESTPATH
))
2070 if (bgp_debug_per_prefix (p
, term_bgp_debug_bestpath
,
2072 bgp_debug_bestpath_prefixes
))
2080 bgp_debug_zebra (struct prefix
*p
)
2082 if (BGP_DEBUG (zebra
, ZEBRA
))
2084 if (bgp_debug_per_prefix (p
, term_bgp_debug_zebra
, BGP_DEBUG_ZEBRA
,
2085 bgp_debug_zebra_prefixes
))