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"
41 #include "bgpd/bgp_mplsvpn.h"
43 #define BGP_ADDPATH_STR 20
45 unsigned long conf_bgp_debug_as4
;
46 unsigned long conf_bgp_debug_neighbor_events
;
47 unsigned long conf_bgp_debug_events
;
48 unsigned long conf_bgp_debug_packet
;
49 unsigned long conf_bgp_debug_filter
;
50 unsigned long conf_bgp_debug_keepalive
;
51 unsigned long conf_bgp_debug_update
;
52 unsigned long conf_bgp_debug_bestpath
;
53 unsigned long conf_bgp_debug_zebra
;
54 unsigned long conf_bgp_debug_allow_martians
;
55 unsigned long conf_bgp_debug_nht
;
56 unsigned long conf_bgp_debug_update_groups
;
58 unsigned long term_bgp_debug_as4
;
59 unsigned long term_bgp_debug_neighbor_events
;
60 unsigned long term_bgp_debug_events
;
61 unsigned long term_bgp_debug_packet
;
62 unsigned long term_bgp_debug_filter
;
63 unsigned long term_bgp_debug_keepalive
;
64 unsigned long term_bgp_debug_update
;
65 unsigned long term_bgp_debug_bestpath
;
66 unsigned long term_bgp_debug_zebra
;
67 unsigned long term_bgp_debug_allow_martians
;
68 unsigned long term_bgp_debug_nht
;
69 unsigned long term_bgp_debug_update_groups
;
71 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
72 struct list
*bgp_debug_keepalive_peers
= NULL
;
73 struct list
*bgp_debug_update_out_peers
= NULL
;
74 struct list
*bgp_debug_update_in_peers
= NULL
;
75 struct list
*bgp_debug_update_prefixes
= NULL
;
76 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
77 struct list
*bgp_debug_zebra_prefixes
= NULL
;
79 /* messages for BGP-4 status */
80 const struct message bgp_status_msg
[] =
83 { Connect
, "Connect" },
85 { OpenSent
, "OpenSent" },
86 { OpenConfirm
, "OpenConfirm" },
87 { Established
, "Established" },
88 { Clearing
, "Clearing" },
89 { Deleted
, "Deleted" },
91 const int bgp_status_msg_max
= BGP_STATUS_MAX
;
93 /* BGP message type string. */
94 const char *bgp_type_str
[] =
105 /* message for BGP-4 Notify */
106 static const struct message bgp_notify_msg
[] =
108 { BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
109 { BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
110 { BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
111 { BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
112 { BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
113 { BGP_NOTIFY_CEASE
, "Cease"},
114 { BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
116 static const int bgp_notify_msg_max
= BGP_NOTIFY_MAX
;
118 static const struct message bgp_notify_head_msg
[] =
120 { BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
121 { BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
122 { BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"}
124 static const int bgp_notify_head_msg_max
= BGP_NOTIFY_HEADER_MAX
;
126 static const struct message bgp_notify_open_msg
[] =
128 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
129 { BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
130 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
131 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
132 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
133 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
134 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
135 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
137 static const int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
139 static const struct message bgp_notify_update_msg
[] =
141 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
142 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
143 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
144 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
145 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
146 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
147 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
148 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
149 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
150 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
151 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
152 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
154 static const int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
156 static const struct message bgp_notify_cease_msg
[] =
158 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
159 { BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
160 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
161 { BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
162 { BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
163 { BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
164 { BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
165 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
, "/Connection collision resolution"},
166 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
168 static const int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
170 static const struct message bgp_notify_capability_msg
[] =
172 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
173 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
174 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
175 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
177 static const int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
179 /* Origin strings. */
180 const char *bgp_origin_str
[] = {"i","e","?"};
181 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
184 /* Given a string return a pointer the corresponding peer structure */
186 bgp_find_peer (struct vty
*vty
, const char *peer_str
)
188 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
196 ret
= str2sockunion (peer_str
, &su
);
201 peer
= peer_lookup_by_conf_if (bgp
, peer_str
);
204 peer
= peer_lookup_by_hostname (bgp
, peer_str
);
209 return peer_lookup (bgp
, &su
);
213 bgp_debug_list_free(struct list
*list
)
215 struct bgp_debug_filter
*filter
;
216 struct listnode
*node
, *nnode
;
219 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
221 listnode_delete (list
, filter
);
224 prefix_free(filter
->p
);
227 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
229 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
233 /* Print the desc along with a list of peers/prefixes this debug is
236 bgp_debug_list_print (struct vty
*vty
, const char *desc
, struct list
*list
)
238 struct bgp_debug_filter
*filter
;
239 struct listnode
*node
, *nnode
;
240 char buf
[INET6_ADDRSTRLEN
];
242 vty_out (vty
, "%s", desc
);
244 if (list
&& !list_isempty(list
))
246 vty_out (vty
, " for");
247 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
250 vty_out (vty
, " %s", filter
->host
);
253 vty_out (vty
, " %s/%d",
254 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
255 filter
->p
->prefixlen
);
259 vty_out (vty
, "%s", VTY_NEWLINE
);
262 /* Print the command to enable the debug for each peer/prefix this debug is
266 bgp_debug_list_conf_print (struct vty
*vty
, const char *desc
, struct list
*list
)
268 struct bgp_debug_filter
*filter
;
269 struct listnode
*node
, *nnode
;
270 char buf
[INET6_ADDRSTRLEN
];
273 if (list
&& !list_isempty(list
))
275 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
279 vty_out (vty
, "%s %s%s", desc
, filter
->host
, VTY_NEWLINE
);
286 vty_out (vty
, "%s %s/%d%s", desc
,
287 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
288 filter
->p
->prefixlen
, VTY_NEWLINE
);
296 vty_out (vty
, "%s%s", desc
, VTY_NEWLINE
);
304 bgp_debug_list_add_entry(struct list
*list
, const char *host
, struct prefix
*p
)
306 struct bgp_debug_filter
*filter
;
308 filter
= XCALLOC (MTYPE_BGP_DEBUG_FILTER
, sizeof (struct bgp_debug_filter
));
312 filter
->host
= XSTRDUP (MTYPE_BGP_DEBUG_STR
, host
);
321 listnode_add(list
, filter
);
325 bgp_debug_list_remove_entry(struct list
*list
, const char *host
, struct prefix
*p
)
327 struct bgp_debug_filter
*filter
;
328 struct listnode
*node
, *nnode
;
330 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
332 if (host
&& strcmp (filter
->host
, host
) == 0)
334 listnode_delete (list
, filter
);
335 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
336 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
339 else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
341 listnode_delete (list
, filter
);
342 prefix_free (filter
->p
);
343 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
352 bgp_debug_list_has_entry(struct list
*list
, const char *host
, struct prefix
*p
)
354 struct bgp_debug_filter
*filter
;
355 struct listnode
*node
, *nnode
;
357 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
361 if (strcmp (filter
->host
, host
) == 0)
368 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
379 bgp_debug_peer_updout_enabled(char *host
)
381 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
));
384 /* Dump attribute. */
386 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
391 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
392 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
394 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
395 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
396 bgp_origin_str
[attr
->origin
]);
400 char addrbuf
[BUFSIZ
];
403 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
404 || attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
405 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
406 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
409 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
410 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
411 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
415 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
416 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %u",
419 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
420 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %u",
423 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
424 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
425 community_str (attr
->community
));
427 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
428 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
430 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
431 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
432 attr
->extra
->aggregator_as
,
433 inet_ntoa (attr
->extra
->aggregator_addr
));
435 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
436 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
437 inet_ntoa (attr
->extra
->originator_id
));
439 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
443 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
444 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
445 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
446 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
449 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
450 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
451 aspath_print (attr
->aspath
));
453 if (strlen (buf
) > 1)
460 bgp_notify_code_str (char code
)
462 return LOOKUP_DEF (bgp_notify_msg
, code
, "Unrecognized Error Code");
466 bgp_notify_subcode_str (char code
, char subcode
)
471 case BGP_NOTIFY_HEADER_ERR
:
472 return LOOKUP_DEF (bgp_notify_head_msg
, subcode
,
473 "Unrecognized Error Subcode");
474 case BGP_NOTIFY_OPEN_ERR
:
475 return LOOKUP_DEF (bgp_notify_open_msg
, subcode
,
476 "Unrecognized Error Subcode");
477 case BGP_NOTIFY_UPDATE_ERR
:
478 return LOOKUP_DEF (bgp_notify_update_msg
, subcode
,
479 "Unrecognized Error Subcode");
480 case BGP_NOTIFY_HOLD_ERR
:
482 case BGP_NOTIFY_FSM_ERR
:
484 case BGP_NOTIFY_CEASE
:
485 return LOOKUP_DEF (bgp_notify_cease_msg
, subcode
,
486 "Unrecognized Error Subcode");
487 case BGP_NOTIFY_CAPABILITY_ERR
:
488 return LOOKUP_DEF (bgp_notify_capability_msg
, subcode
,
489 "Unrecognized Error Subcode");
494 /* dump notify packet */
496 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
499 const char *subcode_str
;
500 const char *code_str
;
502 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
) || bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
504 code_str
= bgp_notify_code_str(bgp_notify
->code
);
505 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
, bgp_notify
->subcode
);
507 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
508 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
509 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
510 code_str
, subcode_str
, bgp_notify
->length
,
511 bgp_notify
->data
? bgp_notify
->data
: "");
516 bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
519 bgp
= bgp_get_default();
520 update_group_walk (bgp
, update_group_clear_update_dbg
, NULL
);
524 /* Debug option setting interface. */
525 unsigned long bgp_debug_option
= 0;
528 debug (unsigned int option
)
530 return bgp_debug_option
& option
;
533 DEFUN (debug_bgp_as4
,
540 if (vty
->node
== CONFIG_NODE
)
544 TERM_DEBUG_ON (as4
, AS4
);
545 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
550 DEFUN (no_debug_bgp_as4
,
551 no_debug_bgp_as4_cmd
,
558 if (vty
->node
== CONFIG_NODE
)
559 DEBUG_OFF (as4
, AS4
);
562 TERM_DEBUG_OFF (as4
, AS4
);
563 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
568 DEFUN (debug_bgp_as4_segment
,
569 debug_bgp_as4_segment_cmd
,
570 "debug bgp as4 segment",
574 "BGP AS4 aspath segment handling\n")
576 if (vty
->node
== CONFIG_NODE
)
577 DEBUG_ON (as4
, AS4_SEGMENT
);
580 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
581 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
586 DEFUN (no_debug_bgp_as4_segment
,
587 no_debug_bgp_as4_segment_cmd
,
588 "no debug bgp as4 segment",
593 "BGP AS4 aspath segment handling\n")
595 if (vty
->node
== CONFIG_NODE
)
596 DEBUG_OFF (as4
, AS4_SEGMENT
);
599 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
600 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
605 /* debug bgp neighbor_events */
606 DEFUN (debug_bgp_neighbor_events
,
607 debug_bgp_neighbor_events_cmd
,
608 "debug bgp neighbor-events",
611 "BGP Neighbor Events\n")
613 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
615 if (vty
->node
== CONFIG_NODE
)
616 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
619 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
620 vty_out (vty
, "BGP neighbor-events debugging is on%s", VTY_NEWLINE
);
625 DEFUN (debug_bgp_neighbor_events_peer
,
626 debug_bgp_neighbor_events_peer_cmd
,
627 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
630 "BGP Neighbor Events\n"
631 "BGP neighbor IP address to debug\n"
632 "BGP IPv6 neighbor to debug\n"
633 "BGP neighbor on interface to debug\n")
636 const char *host
= argv
[idx_peer
]->arg
;
638 if (!bgp_debug_neighbor_events_peers
)
639 bgp_debug_neighbor_events_peers
= list_new ();
641 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
, NULL
))
643 vty_out (vty
, "BGP neighbor-events debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
647 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
649 if (vty
->node
== CONFIG_NODE
)
650 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
653 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
654 vty_out (vty
, "BGP neighbor-events debugging is on for %s%s", host
, VTY_NEWLINE
);
659 DEFUN (no_debug_bgp_neighbor_events
,
660 no_debug_bgp_neighbor_events_cmd
,
661 "no debug bgp neighbor-events",
667 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
669 if (vty
->node
== CONFIG_NODE
)
670 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
673 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
674 vty_out (vty
, "BGP neighbor-events debugging is off%s", VTY_NEWLINE
);
679 DEFUN (no_debug_bgp_neighbor_events_peer
,
680 no_debug_bgp_neighbor_events_peer_cmd
,
681 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
686 "BGP neighbor IP address to debug\n"
687 "BGP IPv6 neighbor to debug\n"
688 "BGP neighbor on interface to debug\n")
692 const char *host
= argv
[idx_peer
]->arg
;
694 if (bgp_debug_neighbor_events_peers
&& !list_isempty(bgp_debug_neighbor_events_peers
))
696 found_peer
= bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
698 if (list_isempty(bgp_debug_neighbor_events_peers
))
700 if (vty
->node
== CONFIG_NODE
)
701 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
703 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
708 vty_out (vty
, "BGP neighbor-events debugging is off for %s%s", host
, VTY_NEWLINE
);
710 vty_out (vty
, "BGP neighbor-events debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
716 DEFUN (debug_bgp_nht
,
721 "BGP nexthop tracking events\n")
723 if (vty
->node
== CONFIG_NODE
)
727 TERM_DEBUG_ON (nht
, NHT
);
728 vty_out (vty
, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE
);
733 DEFUN (no_debug_bgp_nht
,
734 no_debug_bgp_nht_cmd
,
739 "BGP nexthop tracking events\n")
741 if (vty
->node
== CONFIG_NODE
)
742 DEBUG_OFF (nht
, NHT
);
745 TERM_DEBUG_OFF (nht
, NHT
);
746 vty_out (vty
, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE
);
751 /* debug bgp keepalives */
752 DEFUN (debug_bgp_keepalive
,
753 debug_bgp_keepalive_cmd
,
754 "debug bgp keepalives",
759 bgp_debug_list_free(bgp_debug_keepalive_peers
);
761 if (vty
->node
== CONFIG_NODE
)
762 DEBUG_ON (keepalive
, KEEPALIVE
);
765 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
766 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
771 DEFUN (debug_bgp_keepalive_peer
,
772 debug_bgp_keepalive_peer_cmd
,
773 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
776 "BGP Neighbor Events\n"
777 "BGP neighbor IP address to debug\n"
778 "BGP IPv6 neighbor to debug\n"
779 "BGP neighbor on interface to debug\n")
782 const char *host
= argv
[idx_peer
]->arg
;
784 if (!bgp_debug_keepalive_peers
)
785 bgp_debug_keepalive_peers
= list_new ();
787 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
))
789 vty_out (vty
, "BGP keepalive debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
793 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
795 if (vty
->node
== CONFIG_NODE
)
796 DEBUG_ON (keepalive
, KEEPALIVE
);
799 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
800 vty_out (vty
, "BGP keepalives debugging is on for %s%s", host
, VTY_NEWLINE
);
805 DEFUN (no_debug_bgp_keepalive
,
806 no_debug_bgp_keepalive_cmd
,
807 "no debug bgp keepalives",
813 bgp_debug_list_free(bgp_debug_keepalive_peers
);
815 if (vty
->node
== CONFIG_NODE
)
816 DEBUG_OFF (keepalive
, KEEPALIVE
);
819 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
820 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
825 DEFUN (no_debug_bgp_keepalive_peer
,
826 no_debug_bgp_keepalive_peer_cmd
,
827 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
832 "BGP neighbor IP address to debug\n"
833 "BGP IPv6 neighbor to debug\n"
834 "BGP neighbor on interface to debug\n")
838 const char *host
= argv
[idx_peer
]->arg
;
840 if (bgp_debug_keepalive_peers
&& !list_isempty(bgp_debug_keepalive_peers
))
842 found_peer
= bgp_debug_list_remove_entry(bgp_debug_keepalive_peers
, host
, NULL
);
844 if (list_isempty(bgp_debug_keepalive_peers
))
846 if (vty
->node
== CONFIG_NODE
)
847 DEBUG_OFF (keepalive
, KEEPALIVE
);
849 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
854 vty_out (vty
, "BGP keepalives debugging is off for %s%s", host
, VTY_NEWLINE
);
856 vty_out (vty
, "BGP keepalives debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
861 /* debug bgp bestpath */
862 DEFUN (debug_bgp_bestpath_prefix
,
863 debug_bgp_bestpath_prefix_cmd
,
864 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
872 int idx_ipv4_ipv6_prefixlen
= 3;
873 struct prefix
*argv_p
;
876 argv_p
= prefix_new();
877 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
881 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
886 if (!bgp_debug_bestpath_prefixes
)
887 bgp_debug_bestpath_prefixes
= list_new ();
889 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
))
891 vty_out (vty
, "BGP bestptah debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
895 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
897 if (vty
->node
== CONFIG_NODE
)
899 DEBUG_ON (bestpath
, BESTPATH
);
903 TERM_DEBUG_ON (bestpath
, BESTPATH
);
904 vty_out (vty
, "BGP bestpath debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
910 DEFUN (no_debug_bgp_bestpath_prefix
,
911 no_debug_bgp_bestpath_prefix_cmd
,
912 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
921 int idx_ipv4_ipv6_prefixlen
= 4;
922 struct prefix
*argv_p
;
923 int found_prefix
= 0;
926 argv_p
= prefix_new();
927 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
931 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
935 if (bgp_debug_bestpath_prefixes
&& !list_isempty(bgp_debug_bestpath_prefixes
))
937 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
939 if (list_isempty(bgp_debug_bestpath_prefixes
))
941 if (vty
->node
== CONFIG_NODE
)
943 DEBUG_OFF (bestpath
, BESTPATH
);
947 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
948 vty_out (vty
, "BGP bestpath debugging (per prefix) is off%s", VTY_NEWLINE
);
954 vty_out (vty
, "BGP bestpath debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
956 vty_out (vty
, "BGP bestpath debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
961 DEFUN (no_debug_bgp_bestpath
,
962 no_debug_bgp_bestpath_cmd
,
963 "no debug bgp bestpath",
969 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
971 if (vty
->node
== CONFIG_NODE
)
972 DEBUG_OFF (bestpath
, BESTPATH
);
975 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
976 vty_out (vty
, "BGP bestpath debugging is off%s", VTY_NEWLINE
);
981 /* debug bgp updates */
982 DEFUN (debug_bgp_update
,
983 debug_bgp_update_cmd
,
989 bgp_debug_list_free(bgp_debug_update_in_peers
);
990 bgp_debug_list_free(bgp_debug_update_out_peers
);
991 bgp_debug_list_free(bgp_debug_update_prefixes
);
993 if (vty
->node
== CONFIG_NODE
)
995 DEBUG_ON (update
, UPDATE_IN
);
996 DEBUG_ON (update
, UPDATE_OUT
);
1000 TERM_DEBUG_ON (update
, UPDATE_IN
);
1001 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1002 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
1007 DEFUN (debug_bgp_update_direct
,
1008 debug_bgp_update_direct_cmd
,
1009 "debug bgp updates <in|out>",
1014 "Outbound updates\n")
1018 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1019 bgp_debug_list_free(bgp_debug_update_in_peers
);
1021 bgp_debug_list_free(bgp_debug_update_out_peers
);
1023 if (vty
->node
== CONFIG_NODE
)
1025 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1026 DEBUG_ON (update
, UPDATE_IN
);
1028 DEBUG_ON (update
, UPDATE_OUT
);
1032 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1034 TERM_DEBUG_ON (update
, UPDATE_IN
);
1035 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
1039 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1040 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
1046 DEFUN (debug_bgp_update_direct_peer
,
1047 debug_bgp_update_direct_peer_cmd
,
1048 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1053 "Outbound updates\n"
1054 "BGP neighbor IP address to debug\n"
1055 "BGP IPv6 neighbor to debug\n"
1056 "BGP neighbor on interface to debug\n")
1060 const char *host
= argv
[idx_peer
]->arg
;
1063 if (!bgp_debug_update_in_peers
)
1064 bgp_debug_update_in_peers
= list_new ();
1066 if (!bgp_debug_update_out_peers
)
1067 bgp_debug_update_out_peers
= list_new ();
1069 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1076 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
, NULL
))
1078 vty_out (vty
, "BGP inbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1085 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
))
1087 vty_out (vty
, "BGP outbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1093 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1097 struct peer_af
*paf
;
1100 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
, NULL
);
1101 peer
= bgp_find_peer (vty
, host
);
1105 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1107 paf
= peer
->peer_af_array
[afidx
];
1110 if (PAF_SUBGRP (paf
))
1112 UPDGRP_PEER_DBG_EN(PAF_SUBGRP(paf
)->update_group
);
1119 if (vty
->node
== CONFIG_NODE
)
1122 DEBUG_ON (update
, UPDATE_IN
);
1124 DEBUG_ON (update
, UPDATE_OUT
);
1130 TERM_DEBUG_ON (update
, UPDATE_IN
);
1131 vty_out (vty
, "BGP updates debugging is on (inbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1135 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1136 vty_out (vty
, "BGP updates debugging is on (outbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1142 DEFUN (no_debug_bgp_update_direct
,
1143 no_debug_bgp_update_direct_cmd
,
1144 "no debug bgp updates <in|out>",
1150 "Outbound updates\n")
1153 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1155 bgp_debug_list_free(bgp_debug_update_in_peers
);
1157 if (vty
->node
== CONFIG_NODE
)
1159 DEBUG_OFF (update
, UPDATE_IN
);
1163 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1164 vty_out (vty
, "BGP updates debugging is off (inbound)%s", VTY_NEWLINE
);
1169 bgp_debug_list_free(bgp_debug_update_out_peers
);
1171 if (vty
->node
== CONFIG_NODE
)
1173 DEBUG_OFF (update
, UPDATE_OUT
);
1177 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1178 vty_out (vty
, "BGP updates debugging is off (outbound)%s", VTY_NEWLINE
);
1185 DEFUN (no_debug_bgp_update_direct_peer
,
1186 no_debug_bgp_update_direct_peer_cmd
,
1187 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1193 "Outbound updates\n"
1194 "BGP neighbor IP address to debug\n"
1195 "BGP IPv6 neighbor to debug\n"
1196 "BGP neighbor on interface to debug\n")
1202 const char *host
= argv
[idx_peer
]->arg
;
1204 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1209 if (inbound
&& bgp_debug_update_in_peers
&&
1210 !list_isempty(bgp_debug_update_in_peers
))
1212 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_in_peers
, host
, NULL
);
1214 if (list_isempty(bgp_debug_update_in_peers
))
1216 if (vty
->node
== CONFIG_NODE
)
1217 DEBUG_OFF (update
, UPDATE_IN
);
1220 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1221 vty_out (vty
, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE
);
1226 if (!inbound
&& bgp_debug_update_out_peers
&&
1227 !list_isempty(bgp_debug_update_out_peers
))
1229 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_out_peers
, host
, NULL
);
1231 if (list_isempty(bgp_debug_update_out_peers
))
1233 if (vty
->node
== CONFIG_NODE
)
1234 DEBUG_OFF (update
, UPDATE_OUT
);
1237 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1238 vty_out (vty
, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE
);
1243 struct peer_af
*paf
;
1245 peer
= bgp_find_peer (vty
, host
);
1249 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1251 paf
= peer
->peer_af_array
[afidx
];
1254 if (PAF_SUBGRP (paf
))
1256 UPDGRP_PEER_DBG_DIS(PAF_SUBGRP(paf
)->update_group
);
1265 vty_out (vty
, "BGP updates debugging (inbound) is off for %s%s", host
, VTY_NEWLINE
);
1267 vty_out (vty
, "BGP updates debugging (outbound) is off for %s%s", host
, VTY_NEWLINE
);
1270 vty_out (vty
, "BGP updates debugging (inbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1272 vty_out (vty
, "BGP updates debugging (outbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1277 DEFUN (debug_bgp_update_prefix
,
1278 debug_bgp_update_prefix_cmd
,
1279 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1283 "Specify a prefix to debug\n"
1288 int idx_ipv4_ipv6_prefixlen
= 4;
1289 struct prefix
*argv_p
;
1292 argv_p
= prefix_new();
1293 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1296 prefix_free(argv_p
);
1297 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1302 if (!bgp_debug_update_prefixes
)
1303 bgp_debug_update_prefixes
= list_new ();
1305 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
))
1307 vty_out (vty
, "BGP updates debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1311 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1313 if (vty
->node
== CONFIG_NODE
)
1315 DEBUG_ON (update
, UPDATE_PREFIX
);
1319 TERM_DEBUG_ON (update
, UPDATE_PREFIX
);
1320 vty_out (vty
, "BGP updates debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1326 DEFUN (no_debug_bgp_update_prefix
,
1327 no_debug_bgp_update_prefix_cmd
,
1328 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1333 "Specify a prefix to debug\n"
1338 int idx_ipv4_ipv6_prefixlen
= 5;
1339 struct prefix
*argv_p
;
1340 int found_prefix
= 0;
1343 argv_p
= prefix_new();
1344 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1347 prefix_free(argv_p
);
1348 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1352 if (bgp_debug_update_prefixes
&& !list_isempty(bgp_debug_update_prefixes
))
1354 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1356 if (list_isempty(bgp_debug_update_prefixes
))
1358 if (vty
->node
== CONFIG_NODE
)
1360 DEBUG_OFF (update
, UPDATE_PREFIX
);
1364 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1365 vty_out (vty
, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE
);
1371 vty_out (vty
, "BGP updates debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1373 vty_out (vty
, "BGP updates debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1378 DEFUN (no_debug_bgp_update
,
1379 no_debug_bgp_update_cmd
,
1380 "no debug bgp updates",
1386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1387 bgp_debug_list_free(bgp_debug_update_in_peers
);
1388 bgp_debug_list_free(bgp_debug_update_out_peers
);
1389 bgp_debug_list_free(bgp_debug_update_prefixes
);
1391 bgp_debug_clear_updgrp_update_dbg(bgp
);
1393 if (vty
->node
== CONFIG_NODE
)
1395 DEBUG_OFF (update
, UPDATE_IN
);
1396 DEBUG_OFF (update
, UPDATE_OUT
);
1397 DEBUG_OFF (update
, UPDATE_PREFIX
);
1401 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1402 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1403 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1404 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
1409 /* debug bgp zebra */
1410 DEFUN (debug_bgp_zebra
,
1411 debug_bgp_zebra_cmd
,
1415 "BGP Zebra messages\n")
1417 if (vty
->node
== CONFIG_NODE
)
1418 DEBUG_ON (zebra
, ZEBRA
);
1421 TERM_DEBUG_ON (zebra
, ZEBRA
);
1422 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
1427 DEFUN (debug_bgp_zebra_prefix
,
1428 debug_bgp_zebra_prefix_cmd
,
1429 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1432 "BGP Zebra messages\n"
1433 "Specify a prefix to debug\n"
1438 int idx_ipv4_ipv6_prefixlen
= 4;
1439 struct prefix
*argv_p
;
1442 argv_p
= prefix_new();
1443 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1446 prefix_free(argv_p
);
1447 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1451 if (!bgp_debug_zebra_prefixes
)
1452 bgp_debug_zebra_prefixes
= list_new();
1454 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
))
1456 vty_out (vty
, "BGP zebra debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1460 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1462 if (vty
->node
== CONFIG_NODE
)
1463 DEBUG_ON (zebra
, ZEBRA
);
1466 TERM_DEBUG_ON (zebra
, ZEBRA
);
1467 vty_out (vty
, "BGP zebra debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1473 DEFUN (no_debug_bgp_zebra
,
1474 no_debug_bgp_zebra_cmd
,
1475 "no debug bgp zebra",
1479 "BGP Zebra messages\n")
1481 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1483 if (vty
->node
== CONFIG_NODE
)
1484 DEBUG_OFF (zebra
, ZEBRA
);
1487 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1488 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1493 DEFUN (no_debug_bgp_zebra_prefix
,
1494 no_debug_bgp_zebra_prefix_cmd
,
1495 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1499 "BGP Zebra messages\n"
1500 "Specify a prefix to debug\n"
1505 int idx_ipv4_ipv6_prefixlen
= 5;
1506 struct prefix
*argv_p
;
1507 int found_prefix
= 0;
1510 argv_p
= prefix_new();
1511 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1514 prefix_free(argv_p
);
1515 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1519 if (bgp_debug_zebra_prefixes
&& !list_isempty(bgp_debug_zebra_prefixes
))
1521 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1523 if (list_isempty(bgp_debug_zebra_prefixes
))
1525 if (vty
->node
== CONFIG_NODE
)
1526 DEBUG_OFF (zebra
, ZEBRA
);
1529 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1530 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1536 vty_out (vty
, "BGP zebra debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1538 vty_out (vty
, "BGP zebra debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1543 DEFUN (debug_bgp_allow_martians
,
1544 debug_bgp_allow_martians_cmd
,
1545 "debug bgp allow-martians",
1548 "BGP allow martian next hops\n")
1550 if (vty
->node
== CONFIG_NODE
)
1551 DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1554 TERM_DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1555 vty_out (vty
, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE
);
1560 DEFUN (no_debug_bgp_allow_martians
,
1561 no_debug_bgp_allow_martians_cmd
,
1562 "no debug bgp allow-martians",
1566 "BGP allow martian next hops\n")
1568 if (vty
->node
== CONFIG_NODE
)
1569 DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1572 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1573 vty_out (vty
, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE
);
1579 /* debug bgp update-groups */
1580 DEFUN (debug_bgp_update_groups
,
1581 debug_bgp_update_groups_cmd
,
1582 "debug bgp update-groups",
1585 "BGP update-groups\n")
1587 if (vty
->node
== CONFIG_NODE
)
1588 DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1591 TERM_DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1592 vty_out (vty
, "BGP update-groups debugging is on%s", VTY_NEWLINE
);
1597 DEFUN (no_debug_bgp_update_groups
,
1598 no_debug_bgp_update_groups_cmd
,
1599 "no debug bgp update-groups",
1603 "BGP update-groups\n")
1605 if (vty
->node
== CONFIG_NODE
)
1606 DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1609 TERM_DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1610 vty_out (vty
, "BGP update-groups debugging is off%s", VTY_NEWLINE
);
1615 DEFUN (no_debug_bgp
,
1622 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1623 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1624 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1625 bgp_debug_list_free(bgp_debug_update_in_peers
);
1626 bgp_debug_list_free(bgp_debug_update_out_peers
);
1627 bgp_debug_list_free(bgp_debug_update_prefixes
);
1628 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1629 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1631 bgp_debug_clear_updgrp_update_dbg(bgp
);
1633 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
1634 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1635 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1636 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1637 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
1638 TERM_DEBUG_OFF (as4
, AS4
);
1639 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
1640 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
1641 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1642 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1643 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
1648 DEFUN (show_debugging_bgp
,
1649 show_debugging_bgp_cmd
,
1650 "show debugging bgp",
1655 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
1657 if (BGP_DEBUG (as4
, AS4
))
1658 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
1660 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1661 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
1663 if (BGP_DEBUG (bestpath
, BESTPATH
))
1664 bgp_debug_list_print (vty
, " BGP bestpath debugging is on",
1665 bgp_debug_bestpath_prefixes
);
1667 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1668 bgp_debug_list_print (vty
, " BGP keepalives debugging is on",
1669 bgp_debug_keepalive_peers
);
1671 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1672 bgp_debug_list_print (vty
, " BGP neighbor-events debugging is on",
1673 bgp_debug_neighbor_events_peers
);
1675 if (BGP_DEBUG (nht
, NHT
))
1676 vty_out (vty
, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE
);
1678 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1679 vty_out (vty
, " BGP update-groups debugging is on%s", VTY_NEWLINE
);
1681 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1682 bgp_debug_list_print (vty
, " BGP updates debugging is on",
1683 bgp_debug_update_prefixes
);
1685 if (BGP_DEBUG (update
, UPDATE_IN
))
1686 bgp_debug_list_print (vty
, " BGP updates debugging is on (inbound)",
1687 bgp_debug_update_in_peers
);
1689 if (BGP_DEBUG (update
, UPDATE_OUT
))
1690 bgp_debug_list_print (vty
, " BGP updates debugging is on (outbound)",
1691 bgp_debug_update_out_peers
);
1693 if (BGP_DEBUG (zebra
, ZEBRA
))
1694 bgp_debug_list_print (vty
, " BGP zebra debugging is on",
1695 bgp_debug_zebra_prefixes
);
1697 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1698 vty_out (vty
, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE
);
1699 vty_out (vty
, "%s", VTY_NEWLINE
);
1703 /* return count of number of debug flags set */
1705 bgp_debug_count(void)
1708 if (BGP_DEBUG (as4
, AS4
))
1711 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1714 if (BGP_DEBUG (bestpath
, BESTPATH
))
1717 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1720 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1723 if (BGP_DEBUG (nht
, NHT
))
1726 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1729 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1732 if (BGP_DEBUG (update
, UPDATE_IN
))
1735 if (BGP_DEBUG (update
, UPDATE_OUT
))
1738 if (BGP_DEBUG (zebra
, ZEBRA
))
1741 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1748 bgp_config_write_debug (struct vty
*vty
)
1752 if (CONF_BGP_DEBUG (as4
, AS4
))
1754 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
1758 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
1760 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
1764 if (CONF_BGP_DEBUG (bestpath
, BESTPATH
))
1766 write
+= bgp_debug_list_conf_print (vty
, "debug bgp bestpath",
1767 bgp_debug_bestpath_prefixes
);
1770 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
1772 write
+= bgp_debug_list_conf_print (vty
, "debug bgp keepalives",
1773 bgp_debug_keepalive_peers
);
1776 if (CONF_BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1778 write
+= bgp_debug_list_conf_print (vty
, "debug bgp neighbor-events",
1779 bgp_debug_neighbor_events_peers
);
1782 if (CONF_BGP_DEBUG (nht
, NHT
))
1784 vty_out (vty
, "debug bgp nht%s", VTY_NEWLINE
);
1788 if (CONF_BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1790 vty_out (vty
, "debug bgp update-groups%s", VTY_NEWLINE
);
1794 if (CONF_BGP_DEBUG (update
, UPDATE_PREFIX
))
1796 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates prefix",
1797 bgp_debug_update_prefixes
);
1800 if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
1802 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates in",
1803 bgp_debug_update_in_peers
);
1806 if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
1808 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates out",
1809 bgp_debug_update_out_peers
);
1812 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
1814 if (!bgp_debug_zebra_prefixes
|| list_isempty(bgp_debug_zebra_prefixes
))
1816 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
1821 write
+= bgp_debug_list_conf_print (vty
, "debug bgp zebra prefix",
1822 bgp_debug_zebra_prefixes
);
1826 if (CONF_BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1828 vty_out (vty
, "debug bgp allow-martians%s", VTY_NEWLINE
);
1835 static struct cmd_node debug_node
=
1843 bgp_debug_init (void)
1845 install_node (&debug_node
, bgp_config_write_debug
);
1847 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
1849 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
1850 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
1851 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1852 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1854 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1855 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1856 install_element (ENABLE_NODE
, &debug_bgp_nht_cmd
);
1857 install_element (CONFIG_NODE
, &debug_bgp_nht_cmd
);
1858 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1859 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1860 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
1861 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
1862 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1863 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1864 install_element (ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1865 install_element (CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1866 install_element (ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1867 install_element (CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1868 install_element (ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1869 install_element (CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1871 /* debug bgp updates (in|out) */
1872 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1873 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1874 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1875 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1877 /* debug bgp updates (in|out) A.B.C.D */
1878 install_element (ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1879 install_element (CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1880 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1881 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1883 /* debug bgp updates prefix A.B.C.D/M */
1884 install_element (ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1885 install_element (CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1886 install_element (ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1887 install_element (CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1889 /* debug bgp zebra prefix A.B.C.D/M */
1890 install_element (ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1891 install_element (CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1892 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1893 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1895 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1896 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1897 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1898 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1900 /* debug bgp neighbor-events A.B.C.D */
1901 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1902 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1903 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1904 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1906 /* debug bgp keepalive A.B.C.D */
1907 install_element (ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1908 install_element (CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1909 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1910 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1912 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1913 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1914 install_element (ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1915 install_element (CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1916 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1917 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1918 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1919 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1920 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1921 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1922 install_element (ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1923 install_element (CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1924 install_element (ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1925 install_element (CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1926 install_element (ENABLE_NODE
, &no_debug_bgp_cmd
);
1927 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1928 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1929 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1930 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1933 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
1934 * for BGP_DEBUG_TYPE
1937 bgp_debug_per_prefix (struct prefix
*p
, unsigned long term_bgp_debug_type
,
1938 unsigned int BGP_DEBUG_TYPE
, struct list
*per_prefix_list
)
1940 struct bgp_debug_filter
*filter
;
1941 struct listnode
*node
, *nnode
;
1943 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1945 /* We are debugging all prefixes so return true */
1946 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
1954 for (ALL_LIST_ELEMENTS (per_prefix_list
, node
, nnode
, filter
))
1955 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
1965 /* Return true if this peer is on the per_peer_list of peers to debug
1966 * for BGP_DEBUG_TYPE
1969 bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
1970 unsigned int BGP_DEBUG_TYPE
, struct list
*per_peer_list
)
1972 struct bgp_debug_filter
*filter
;
1973 struct listnode
*node
, *nnode
;
1975 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1977 /* We are debugging all peers so return true */
1978 if (!per_peer_list
|| list_isempty(per_peer_list
))
1986 for (ALL_LIST_ELEMENTS (per_peer_list
, node
, nnode
, filter
))
1987 if (strcmp (filter
->host
, host
) == 0)
1998 bgp_debug_neighbor_events (struct peer
*peer
)
2005 return bgp_debug_per_peer (host
,
2006 term_bgp_debug_neighbor_events
,
2007 BGP_DEBUG_NEIGHBOR_EVENTS
,
2008 bgp_debug_neighbor_events_peers
);
2012 bgp_debug_keepalive (struct peer
*peer
)
2019 return bgp_debug_per_peer (host
,
2020 term_bgp_debug_keepalive
,
2021 BGP_DEBUG_KEEPALIVE
,
2022 bgp_debug_keepalive_peers
);
2026 bgp_debug_update (struct peer
*peer
, struct prefix
*p
,
2027 struct update_group
*updgrp
, unsigned int inbound
)
2036 if (bgp_debug_per_peer (host
, term_bgp_debug_update
, BGP_DEBUG_UPDATE_IN
,
2037 bgp_debug_update_in_peers
))
2044 if (bgp_debug_per_peer (host
, term_bgp_debug_update
,
2045 BGP_DEBUG_UPDATE_OUT
,
2046 bgp_debug_update_out_peers
))
2049 /* Check if update debugging implicitly enabled for the group. */
2050 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2055 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
2057 if (bgp_debug_per_prefix (p
, term_bgp_debug_update
,
2058 BGP_DEBUG_UPDATE_PREFIX
,
2059 bgp_debug_update_prefixes
))
2067 bgp_debug_bestpath (struct prefix
*p
)
2069 if (BGP_DEBUG (bestpath
, BESTPATH
))
2071 if (bgp_debug_per_prefix (p
, term_bgp_debug_bestpath
,
2073 bgp_debug_bestpath_prefixes
))
2081 bgp_debug_zebra (struct prefix
*p
)
2083 if (BGP_DEBUG (zebra
, ZEBRA
))
2085 if (bgp_debug_per_prefix (p
, term_bgp_debug_zebra
, BGP_DEBUG_ZEBRA
,
2086 bgp_debug_zebra_prefixes
))
2094 bgp_debug_rdpfxpath2str (struct prefix_rd
*prd
, union prefixconstptr pu
,
2095 int addpath_valid
, u_int32_t addpath_id
,
2096 char *str
, int size
)
2098 char rd_buf
[RD_ADDRSTRLEN
];
2099 char pfx_buf
[PREFIX_STRLEN
];
2100 char pathid_buf
[BGP_ADDPATH_STR
];
2102 if (size
< BGP_PRD_PATH_STRLEN
)
2105 /* Note: Path-id is created by default, but only included in update sometimes. */
2106 pathid_buf
[0] = '\0';
2108 sprintf(pathid_buf
, " with addpath ID %d", addpath_id
);
2111 snprintf (str
, size
, "RD %s %s%s",
2112 prefix_rd2str(prd
, rd_buf
, sizeof (rd_buf
)),
2113 prefix2str (pu
, pfx_buf
, sizeof (pfx_buf
)), pathid_buf
);
2115 snprintf (str
, size
, "%s%s",
2116 prefix2str (pu
, pfx_buf
, sizeof (pfx_buf
)), pathid_buf
);