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
]);
397 char addrbuf
[BUFSIZ
];
400 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
401 || attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
402 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", mp_nexthop %s",
403 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
406 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
407 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), "(%s)",
408 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
412 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
413 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %u",
416 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
417 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %u",
420 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
421 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
422 community_str (attr
->community
));
424 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
425 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
427 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
428 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
429 attr
->extra
->aggregator_as
,
430 inet_ntoa (attr
->extra
->aggregator_addr
));
432 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
433 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
434 inet_ntoa (attr
->extra
->originator_id
));
436 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
440 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
441 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
442 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
443 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
446 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
447 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
448 aspath_print (attr
->aspath
));
450 if (strlen (buf
) > 1)
457 bgp_notify_code_str (char code
)
459 return LOOKUP_DEF (bgp_notify_msg
, code
, "Unrecognized Error Code");
463 bgp_notify_subcode_str (char code
, char subcode
)
468 case BGP_NOTIFY_HEADER_ERR
:
469 return LOOKUP_DEF (bgp_notify_head_msg
, subcode
,
470 "Unrecognized Error Subcode");
471 case BGP_NOTIFY_OPEN_ERR
:
472 return LOOKUP_DEF (bgp_notify_open_msg
, subcode
,
473 "Unrecognized Error Subcode");
474 case BGP_NOTIFY_UPDATE_ERR
:
475 return LOOKUP_DEF (bgp_notify_update_msg
, subcode
,
476 "Unrecognized Error Subcode");
477 case BGP_NOTIFY_HOLD_ERR
:
479 case BGP_NOTIFY_FSM_ERR
:
481 case BGP_NOTIFY_CEASE
:
482 return LOOKUP_DEF (bgp_notify_cease_msg
, subcode
,
483 "Unrecognized Error Subcode");
484 case BGP_NOTIFY_CAPABILITY_ERR
:
485 return LOOKUP_DEF (bgp_notify_capability_msg
, subcode
,
486 "Unrecognized Error Subcode");
491 /* dump notify packet */
493 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
496 const char *subcode_str
;
497 const char *code_str
;
499 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
) || bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
501 code_str
= bgp_notify_code_str(bgp_notify
->code
);
502 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
, bgp_notify
->subcode
);
504 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
505 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
506 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
507 code_str
, subcode_str
, bgp_notify
->length
,
508 bgp_notify
->data
? bgp_notify
->data
: "");
513 bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
516 bgp
= bgp_get_default();
517 update_group_walk (bgp
, update_group_clear_update_dbg
, NULL
);
521 /* Debug option setting interface. */
522 unsigned long bgp_debug_option
= 0;
525 debug (unsigned int option
)
527 return bgp_debug_option
& option
;
530 DEFUN (debug_bgp_as4
,
537 if (vty
->node
== CONFIG_NODE
)
541 TERM_DEBUG_ON (as4
, AS4
);
542 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
547 DEFUN (no_debug_bgp_as4
,
548 no_debug_bgp_as4_cmd
,
555 if (vty
->node
== CONFIG_NODE
)
556 DEBUG_OFF (as4
, AS4
);
559 TERM_DEBUG_OFF (as4
, AS4
);
560 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
565 DEFUN (debug_bgp_as4_segment
,
566 debug_bgp_as4_segment_cmd
,
567 "debug bgp as4 segment",
571 "BGP AS4 aspath segment handling\n")
573 if (vty
->node
== CONFIG_NODE
)
574 DEBUG_ON (as4
, AS4_SEGMENT
);
577 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
578 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
583 DEFUN (no_debug_bgp_as4_segment
,
584 no_debug_bgp_as4_segment_cmd
,
585 "no debug bgp as4 segment",
590 "BGP AS4 aspath segment handling\n")
592 if (vty
->node
== CONFIG_NODE
)
593 DEBUG_OFF (as4
, AS4_SEGMENT
);
596 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
597 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
602 /* debug bgp neighbor_events */
603 DEFUN (debug_bgp_neighbor_events
,
604 debug_bgp_neighbor_events_cmd
,
605 "debug bgp neighbor-events",
608 "BGP Neighbor Events\n")
610 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
612 if (vty
->node
== CONFIG_NODE
)
613 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
616 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
617 vty_out (vty
, "BGP neighbor-events debugging is on%s", VTY_NEWLINE
);
622 DEFUN (debug_bgp_neighbor_events_peer
,
623 debug_bgp_neighbor_events_peer_cmd
,
624 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
627 "BGP Neighbor Events\n"
628 "BGP neighbor IP address to debug\n"
629 "BGP IPv6 neighbor to debug\n"
630 "BGP neighbor on interface to debug\n")
633 const char *host
= argv
[idx_peer
]->arg
;
635 if (!bgp_debug_neighbor_events_peers
)
636 bgp_debug_neighbor_events_peers
= list_new ();
638 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
, NULL
))
640 vty_out (vty
, "BGP neighbor-events debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
644 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
646 if (vty
->node
== CONFIG_NODE
)
647 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
650 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
651 vty_out (vty
, "BGP neighbor-events debugging is on for %s%s", host
, VTY_NEWLINE
);
656 DEFUN (no_debug_bgp_neighbor_events
,
657 no_debug_bgp_neighbor_events_cmd
,
658 "no debug bgp neighbor-events",
664 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
666 if (vty
->node
== CONFIG_NODE
)
667 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
670 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
671 vty_out (vty
, "BGP neighbor-events debugging is off%s", VTY_NEWLINE
);
676 DEFUN (no_debug_bgp_neighbor_events_peer
,
677 no_debug_bgp_neighbor_events_peer_cmd
,
678 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
683 "BGP neighbor IP address to debug\n"
684 "BGP IPv6 neighbor to debug\n"
685 "BGP neighbor on interface to debug\n")
689 const char *host
= argv
[idx_peer
]->arg
;
691 if (bgp_debug_neighbor_events_peers
&& !list_isempty(bgp_debug_neighbor_events_peers
))
693 found_peer
= bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
695 if (list_isempty(bgp_debug_neighbor_events_peers
))
697 if (vty
->node
== CONFIG_NODE
)
698 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
700 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
705 vty_out (vty
, "BGP neighbor-events debugging is off for %s%s", host
, VTY_NEWLINE
);
707 vty_out (vty
, "BGP neighbor-events debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
713 DEFUN (debug_bgp_nht
,
718 "BGP nexthop tracking events\n")
720 if (vty
->node
== CONFIG_NODE
)
724 TERM_DEBUG_ON (nht
, NHT
);
725 vty_out (vty
, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE
);
730 DEFUN (no_debug_bgp_nht
,
731 no_debug_bgp_nht_cmd
,
736 "BGP nexthop tracking events\n")
738 if (vty
->node
== CONFIG_NODE
)
739 DEBUG_OFF (nht
, NHT
);
742 TERM_DEBUG_OFF (nht
, NHT
);
743 vty_out (vty
, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE
);
748 /* debug bgp keepalives */
749 DEFUN (debug_bgp_keepalive
,
750 debug_bgp_keepalive_cmd
,
751 "debug bgp keepalives",
756 bgp_debug_list_free(bgp_debug_keepalive_peers
);
758 if (vty
->node
== CONFIG_NODE
)
759 DEBUG_ON (keepalive
, KEEPALIVE
);
762 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
763 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
768 DEFUN (debug_bgp_keepalive_peer
,
769 debug_bgp_keepalive_peer_cmd
,
770 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
773 "BGP Neighbor Events\n"
774 "BGP neighbor IP address to debug\n"
775 "BGP IPv6 neighbor to debug\n"
776 "BGP neighbor on interface to debug\n")
779 const char *host
= argv
[idx_peer
]->arg
;
781 if (!bgp_debug_keepalive_peers
)
782 bgp_debug_keepalive_peers
= list_new ();
784 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
))
786 vty_out (vty
, "BGP keepalive debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
790 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
792 if (vty
->node
== CONFIG_NODE
)
793 DEBUG_ON (keepalive
, KEEPALIVE
);
796 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
797 vty_out (vty
, "BGP keepalives debugging is on for %s%s", host
, VTY_NEWLINE
);
802 DEFUN (no_debug_bgp_keepalive
,
803 no_debug_bgp_keepalive_cmd
,
804 "no debug bgp keepalives",
810 bgp_debug_list_free(bgp_debug_keepalive_peers
);
812 if (vty
->node
== CONFIG_NODE
)
813 DEBUG_OFF (keepalive
, KEEPALIVE
);
816 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
817 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
822 DEFUN (no_debug_bgp_keepalive_peer
,
823 no_debug_bgp_keepalive_peer_cmd
,
824 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
829 "BGP neighbor IP address to debug\n"
830 "BGP IPv6 neighbor to debug\n"
831 "BGP neighbor on interface to debug\n")
835 const char *host
= argv
[idx_peer
]->arg
;
837 if (bgp_debug_keepalive_peers
&& !list_isempty(bgp_debug_keepalive_peers
))
839 found_peer
= bgp_debug_list_remove_entry(bgp_debug_keepalive_peers
, host
, NULL
);
841 if (list_isempty(bgp_debug_keepalive_peers
))
843 if (vty
->node
== CONFIG_NODE
)
844 DEBUG_OFF (keepalive
, KEEPALIVE
);
846 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
851 vty_out (vty
, "BGP keepalives debugging is off for %s%s", host
, VTY_NEWLINE
);
853 vty_out (vty
, "BGP keepalives debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
858 /* debug bgp bestpath */
859 DEFUN (debug_bgp_bestpath_prefix
,
860 debug_bgp_bestpath_prefix_cmd
,
861 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
869 int idx_ipv4_ipv6_prefixlen
= 3;
870 struct prefix
*argv_p
;
873 argv_p
= prefix_new();
874 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
878 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
883 if (!bgp_debug_bestpath_prefixes
)
884 bgp_debug_bestpath_prefixes
= list_new ();
886 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
))
888 vty_out (vty
, "BGP bestptah debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
892 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
894 if (vty
->node
== CONFIG_NODE
)
896 DEBUG_ON (bestpath
, BESTPATH
);
900 TERM_DEBUG_ON (bestpath
, BESTPATH
);
901 vty_out (vty
, "BGP bestpath debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
907 DEFUN (no_debug_bgp_bestpath_prefix
,
908 no_debug_bgp_bestpath_prefix_cmd
,
909 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
918 int idx_ipv4_ipv6_prefixlen
= 4;
919 struct prefix
*argv_p
;
920 int found_prefix
= 0;
923 argv_p
= prefix_new();
924 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
928 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
932 if (bgp_debug_bestpath_prefixes
&& !list_isempty(bgp_debug_bestpath_prefixes
))
934 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
936 if (list_isempty(bgp_debug_bestpath_prefixes
))
938 if (vty
->node
== CONFIG_NODE
)
940 DEBUG_OFF (bestpath
, BESTPATH
);
944 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
945 vty_out (vty
, "BGP bestpath debugging (per prefix) is off%s", VTY_NEWLINE
);
951 vty_out (vty
, "BGP bestpath debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
953 vty_out (vty
, "BGP bestpath debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
958 DEFUN (no_debug_bgp_bestpath
,
959 no_debug_bgp_bestpath_cmd
,
960 "no debug bgp bestpath",
966 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
968 if (vty
->node
== CONFIG_NODE
)
969 DEBUG_OFF (bestpath
, BESTPATH
);
972 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
973 vty_out (vty
, "BGP bestpath debugging is off%s", VTY_NEWLINE
);
978 /* debug bgp updates */
979 DEFUN (debug_bgp_update
,
980 debug_bgp_update_cmd
,
986 bgp_debug_list_free(bgp_debug_update_in_peers
);
987 bgp_debug_list_free(bgp_debug_update_out_peers
);
988 bgp_debug_list_free(bgp_debug_update_prefixes
);
990 if (vty
->node
== CONFIG_NODE
)
992 DEBUG_ON (update
, UPDATE_IN
);
993 DEBUG_ON (update
, UPDATE_OUT
);
997 TERM_DEBUG_ON (update
, UPDATE_IN
);
998 TERM_DEBUG_ON (update
, UPDATE_OUT
);
999 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
1004 DEFUN (debug_bgp_update_direct
,
1005 debug_bgp_update_direct_cmd
,
1006 "debug bgp updates <in|out>",
1011 "Outbound updates\n")
1015 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1016 bgp_debug_list_free(bgp_debug_update_in_peers
);
1018 bgp_debug_list_free(bgp_debug_update_out_peers
);
1020 if (vty
->node
== CONFIG_NODE
)
1022 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1023 DEBUG_ON (update
, UPDATE_IN
);
1025 DEBUG_ON (update
, UPDATE_OUT
);
1029 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1031 TERM_DEBUG_ON (update
, UPDATE_IN
);
1032 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
1036 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1037 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
1043 DEFUN (debug_bgp_update_direct_peer
,
1044 debug_bgp_update_direct_peer_cmd
,
1045 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1050 "Outbound updates\n"
1051 "BGP neighbor IP address to debug\n"
1052 "BGP IPv6 neighbor to debug\n"
1053 "BGP neighbor on interface to debug\n")
1057 const char *host
= argv
[idx_peer
]->arg
;
1060 if (!bgp_debug_update_in_peers
)
1061 bgp_debug_update_in_peers
= list_new ();
1063 if (!bgp_debug_update_out_peers
)
1064 bgp_debug_update_out_peers
= list_new ();
1066 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1073 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
, NULL
))
1075 vty_out (vty
, "BGP inbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1082 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
))
1084 vty_out (vty
, "BGP outbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1090 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1094 struct peer_af
*paf
;
1097 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
, NULL
);
1098 peer
= bgp_find_peer (vty
, host
);
1102 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1104 paf
= peer
->peer_af_array
[afidx
];
1107 if (PAF_SUBGRP (paf
))
1109 UPDGRP_PEER_DBG_EN(PAF_SUBGRP(paf
)->update_group
);
1116 if (vty
->node
== CONFIG_NODE
)
1119 DEBUG_ON (update
, UPDATE_IN
);
1121 DEBUG_ON (update
, UPDATE_OUT
);
1127 TERM_DEBUG_ON (update
, UPDATE_IN
);
1128 vty_out (vty
, "BGP updates debugging is on (inbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1132 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1133 vty_out (vty
, "BGP updates debugging is on (outbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1139 DEFUN (no_debug_bgp_update_direct
,
1140 no_debug_bgp_update_direct_cmd
,
1141 "no debug bgp updates <in|out>",
1147 "Outbound updates\n")
1150 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1152 bgp_debug_list_free(bgp_debug_update_in_peers
);
1154 if (vty
->node
== CONFIG_NODE
)
1156 DEBUG_OFF (update
, UPDATE_IN
);
1160 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1161 vty_out (vty
, "BGP updates debugging is off (inbound)%s", VTY_NEWLINE
);
1166 bgp_debug_list_free(bgp_debug_update_out_peers
);
1168 if (vty
->node
== CONFIG_NODE
)
1170 DEBUG_OFF (update
, UPDATE_OUT
);
1174 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1175 vty_out (vty
, "BGP updates debugging is off (outbound)%s", VTY_NEWLINE
);
1182 DEFUN (no_debug_bgp_update_direct_peer
,
1183 no_debug_bgp_update_direct_peer_cmd
,
1184 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1190 "Outbound updates\n"
1191 "BGP neighbor IP address to debug\n"
1192 "BGP IPv6 neighbor to debug\n"
1193 "BGP neighbor on interface to debug\n")
1199 const char *host
= argv
[idx_peer
]->arg
;
1201 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1206 if (inbound
&& bgp_debug_update_in_peers
&&
1207 !list_isempty(bgp_debug_update_in_peers
))
1209 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_in_peers
, host
, NULL
);
1211 if (list_isempty(bgp_debug_update_in_peers
))
1213 if (vty
->node
== CONFIG_NODE
)
1214 DEBUG_OFF (update
, UPDATE_IN
);
1217 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1218 vty_out (vty
, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE
);
1223 if (!inbound
&& bgp_debug_update_out_peers
&&
1224 !list_isempty(bgp_debug_update_out_peers
))
1226 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_out_peers
, host
, NULL
);
1228 if (list_isempty(bgp_debug_update_out_peers
))
1230 if (vty
->node
== CONFIG_NODE
)
1231 DEBUG_OFF (update
, UPDATE_OUT
);
1234 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1235 vty_out (vty
, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE
);
1240 struct peer_af
*paf
;
1242 peer
= bgp_find_peer (vty
, host
);
1246 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1248 paf
= peer
->peer_af_array
[afidx
];
1251 if (PAF_SUBGRP (paf
))
1253 UPDGRP_PEER_DBG_DIS(PAF_SUBGRP(paf
)->update_group
);
1262 vty_out (vty
, "BGP updates debugging (inbound) is off for %s%s", host
, VTY_NEWLINE
);
1264 vty_out (vty
, "BGP updates debugging (outbound) is off for %s%s", host
, VTY_NEWLINE
);
1267 vty_out (vty
, "BGP updates debugging (inbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1269 vty_out (vty
, "BGP updates debugging (outbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1274 DEFUN (debug_bgp_update_prefix
,
1275 debug_bgp_update_prefix_cmd
,
1276 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1280 "Specify a prefix to debug\n"
1285 int idx_ipv4_ipv6_prefixlen
= 4;
1286 struct prefix
*argv_p
;
1289 argv_p
= prefix_new();
1290 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1293 prefix_free(argv_p
);
1294 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1299 if (!bgp_debug_update_prefixes
)
1300 bgp_debug_update_prefixes
= list_new ();
1302 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
))
1304 vty_out (vty
, "BGP updates debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1308 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1310 if (vty
->node
== CONFIG_NODE
)
1312 DEBUG_ON (update
, UPDATE_PREFIX
);
1316 TERM_DEBUG_ON (update
, UPDATE_PREFIX
);
1317 vty_out (vty
, "BGP updates debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1323 DEFUN (no_debug_bgp_update_prefix
,
1324 no_debug_bgp_update_prefix_cmd
,
1325 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1330 "Specify a prefix to debug\n"
1335 int idx_ipv4_ipv6_prefixlen
= 5;
1336 struct prefix
*argv_p
;
1337 int found_prefix
= 0;
1340 argv_p
= prefix_new();
1341 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1344 prefix_free(argv_p
);
1345 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1349 if (bgp_debug_update_prefixes
&& !list_isempty(bgp_debug_update_prefixes
))
1351 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1353 if (list_isempty(bgp_debug_update_prefixes
))
1355 if (vty
->node
== CONFIG_NODE
)
1357 DEBUG_OFF (update
, UPDATE_PREFIX
);
1361 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1362 vty_out (vty
, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE
);
1368 vty_out (vty
, "BGP updates debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1370 vty_out (vty
, "BGP updates debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1375 DEFUN (no_debug_bgp_update
,
1376 no_debug_bgp_update_cmd
,
1377 "no debug bgp updates",
1383 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1384 bgp_debug_list_free(bgp_debug_update_in_peers
);
1385 bgp_debug_list_free(bgp_debug_update_out_peers
);
1386 bgp_debug_list_free(bgp_debug_update_prefixes
);
1388 bgp_debug_clear_updgrp_update_dbg(bgp
);
1390 if (vty
->node
== CONFIG_NODE
)
1392 DEBUG_OFF (update
, UPDATE_IN
);
1393 DEBUG_OFF (update
, UPDATE_OUT
);
1394 DEBUG_OFF (update
, UPDATE_PREFIX
);
1398 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1399 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1400 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1401 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
1406 /* debug bgp zebra */
1407 DEFUN (debug_bgp_zebra
,
1408 debug_bgp_zebra_cmd
,
1412 "BGP Zebra messages\n")
1414 if (vty
->node
== CONFIG_NODE
)
1415 DEBUG_ON (zebra
, ZEBRA
);
1418 TERM_DEBUG_ON (zebra
, ZEBRA
);
1419 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
1424 DEFUN (debug_bgp_zebra_prefix
,
1425 debug_bgp_zebra_prefix_cmd
,
1426 "debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1429 "BGP Zebra messages\n"
1430 "Specify a prefix to debug\n"
1435 int idx_ipv4_ipv6_prefixlen
= 4;
1436 struct prefix
*argv_p
;
1439 argv_p
= prefix_new();
1440 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1443 prefix_free(argv_p
);
1444 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1448 if (!bgp_debug_zebra_prefixes
)
1449 bgp_debug_zebra_prefixes
= list_new();
1451 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
))
1453 vty_out (vty
, "BGP zebra debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1457 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1459 if (vty
->node
== CONFIG_NODE
)
1460 DEBUG_ON (zebra
, ZEBRA
);
1463 TERM_DEBUG_ON (zebra
, ZEBRA
);
1464 vty_out (vty
, "BGP zebra debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1470 DEFUN (no_debug_bgp_zebra
,
1471 no_debug_bgp_zebra_cmd
,
1472 "no debug bgp zebra",
1476 "BGP Zebra messages\n")
1478 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1480 if (vty
->node
== CONFIG_NODE
)
1481 DEBUG_OFF (zebra
, ZEBRA
);
1484 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1485 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1490 DEFUN (no_debug_bgp_zebra_prefix
,
1491 no_debug_bgp_zebra_prefix_cmd
,
1492 "no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
1496 "BGP Zebra messages\n"
1497 "Specify a prefix to debug\n"
1502 int idx_ipv4_ipv6_prefixlen
= 5;
1503 struct prefix
*argv_p
;
1504 int found_prefix
= 0;
1507 argv_p
= prefix_new();
1508 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1511 prefix_free(argv_p
);
1512 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1516 if (bgp_debug_zebra_prefixes
&& !list_isempty(bgp_debug_zebra_prefixes
))
1518 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1520 if (list_isempty(bgp_debug_zebra_prefixes
))
1522 if (vty
->node
== CONFIG_NODE
)
1523 DEBUG_OFF (zebra
, ZEBRA
);
1526 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1527 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1533 vty_out (vty
, "BGP zebra debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1535 vty_out (vty
, "BGP zebra debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1540 DEFUN (debug_bgp_allow_martians
,
1541 debug_bgp_allow_martians_cmd
,
1542 "debug bgp allow-martians",
1545 "BGP allow martian next hops\n")
1547 if (vty
->node
== CONFIG_NODE
)
1548 DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1551 TERM_DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1552 vty_out (vty
, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE
);
1557 DEFUN (no_debug_bgp_allow_martians
,
1558 no_debug_bgp_allow_martians_cmd
,
1559 "no debug bgp allow-martians",
1563 "BGP allow martian next hops\n")
1565 if (vty
->node
== CONFIG_NODE
)
1566 DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1569 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1570 vty_out (vty
, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE
);
1576 /* debug bgp update-groups */
1577 DEFUN (debug_bgp_update_groups
,
1578 debug_bgp_update_groups_cmd
,
1579 "debug bgp update-groups",
1582 "BGP update-groups\n")
1584 if (vty
->node
== CONFIG_NODE
)
1585 DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1588 TERM_DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1589 vty_out (vty
, "BGP update-groups debugging is on%s", VTY_NEWLINE
);
1594 DEFUN (no_debug_bgp_update_groups
,
1595 no_debug_bgp_update_groups_cmd
,
1596 "no debug bgp update-groups",
1600 "BGP update-groups\n")
1602 if (vty
->node
== CONFIG_NODE
)
1603 DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1606 TERM_DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1607 vty_out (vty
, "BGP update-groups debugging is off%s", VTY_NEWLINE
);
1612 DEFUN (no_debug_bgp
,
1619 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1620 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1621 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1622 bgp_debug_list_free(bgp_debug_update_in_peers
);
1623 bgp_debug_list_free(bgp_debug_update_out_peers
);
1624 bgp_debug_list_free(bgp_debug_update_prefixes
);
1625 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1626 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1628 bgp_debug_clear_updgrp_update_dbg(bgp
);
1630 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
1631 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1632 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1633 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1634 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
1635 TERM_DEBUG_OFF (as4
, AS4
);
1636 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
1637 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
1638 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1639 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1640 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
1645 DEFUN (show_debugging_bgp
,
1646 show_debugging_bgp_cmd
,
1647 "show debugging bgp",
1652 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
1654 if (BGP_DEBUG (as4
, AS4
))
1655 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
1657 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1658 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
1660 if (BGP_DEBUG (bestpath
, BESTPATH
))
1661 bgp_debug_list_print (vty
, " BGP bestpath debugging is on",
1662 bgp_debug_bestpath_prefixes
);
1664 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1665 bgp_debug_list_print (vty
, " BGP keepalives debugging is on",
1666 bgp_debug_keepalive_peers
);
1668 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1669 bgp_debug_list_print (vty
, " BGP neighbor-events debugging is on",
1670 bgp_debug_neighbor_events_peers
);
1672 if (BGP_DEBUG (nht
, NHT
))
1673 vty_out (vty
, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE
);
1675 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1676 vty_out (vty
, " BGP update-groups debugging is on%s", VTY_NEWLINE
);
1678 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1679 bgp_debug_list_print (vty
, " BGP updates debugging is on",
1680 bgp_debug_update_prefixes
);
1682 if (BGP_DEBUG (update
, UPDATE_IN
))
1683 bgp_debug_list_print (vty
, " BGP updates debugging is on (inbound)",
1684 bgp_debug_update_in_peers
);
1686 if (BGP_DEBUG (update
, UPDATE_OUT
))
1687 bgp_debug_list_print (vty
, " BGP updates debugging is on (outbound)",
1688 bgp_debug_update_out_peers
);
1690 if (BGP_DEBUG (zebra
, ZEBRA
))
1691 bgp_debug_list_print (vty
, " BGP zebra debugging is on",
1692 bgp_debug_zebra_prefixes
);
1694 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1695 vty_out (vty
, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE
);
1696 vty_out (vty
, "%s", VTY_NEWLINE
);
1700 /* return count of number of debug flags set */
1702 bgp_debug_count(void)
1705 if (BGP_DEBUG (as4
, AS4
))
1708 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1711 if (BGP_DEBUG (bestpath
, BESTPATH
))
1714 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1717 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1720 if (BGP_DEBUG (nht
, NHT
))
1723 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1726 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1729 if (BGP_DEBUG (update
, UPDATE_IN
))
1732 if (BGP_DEBUG (update
, UPDATE_OUT
))
1735 if (BGP_DEBUG (zebra
, ZEBRA
))
1738 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1745 bgp_config_write_debug (struct vty
*vty
)
1749 if (CONF_BGP_DEBUG (as4
, AS4
))
1751 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
1755 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
1757 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
1761 if (CONF_BGP_DEBUG (bestpath
, BESTPATH
))
1763 write
+= bgp_debug_list_conf_print (vty
, "debug bgp bestpath",
1764 bgp_debug_bestpath_prefixes
);
1767 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
1769 write
+= bgp_debug_list_conf_print (vty
, "debug bgp keepalives",
1770 bgp_debug_keepalive_peers
);
1773 if (CONF_BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1775 write
+= bgp_debug_list_conf_print (vty
, "debug bgp neighbor-events",
1776 bgp_debug_neighbor_events_peers
);
1779 if (CONF_BGP_DEBUG (nht
, NHT
))
1781 vty_out (vty
, "debug bgp nht%s", VTY_NEWLINE
);
1785 if (CONF_BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1787 vty_out (vty
, "debug bgp update-groups%s", VTY_NEWLINE
);
1791 if (CONF_BGP_DEBUG (update
, UPDATE_PREFIX
))
1793 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates prefix",
1794 bgp_debug_update_prefixes
);
1797 if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
1799 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates in",
1800 bgp_debug_update_in_peers
);
1803 if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
1805 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates out",
1806 bgp_debug_update_out_peers
);
1809 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
1811 if (!bgp_debug_zebra_prefixes
|| list_isempty(bgp_debug_zebra_prefixes
))
1813 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
1818 write
+= bgp_debug_list_conf_print (vty
, "debug bgp zebra prefix",
1819 bgp_debug_zebra_prefixes
);
1823 if (CONF_BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1825 vty_out (vty
, "debug bgp allow-martians%s", VTY_NEWLINE
);
1832 static struct cmd_node debug_node
=
1840 bgp_debug_init (void)
1842 install_node (&debug_node
, bgp_config_write_debug
);
1844 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
1846 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
1847 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
1848 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1849 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1851 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1852 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1853 install_element (ENABLE_NODE
, &debug_bgp_nht_cmd
);
1854 install_element (CONFIG_NODE
, &debug_bgp_nht_cmd
);
1855 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1856 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1857 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
1858 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
1859 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1860 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1861 install_element (ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1862 install_element (CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1863 install_element (ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1864 install_element (CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1865 install_element (ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1866 install_element (CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1868 /* debug bgp updates (in|out) */
1869 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1870 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1871 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1872 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1874 /* debug bgp updates (in|out) A.B.C.D */
1875 install_element (ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1876 install_element (CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1877 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1878 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1880 /* debug bgp updates prefix A.B.C.D/M */
1881 install_element (ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1882 install_element (CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1883 install_element (ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1884 install_element (CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1886 /* debug bgp zebra prefix A.B.C.D/M */
1887 install_element (ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1888 install_element (CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1889 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1890 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1892 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1893 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1894 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1895 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1897 /* debug bgp neighbor-events A.B.C.D */
1898 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1899 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1900 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1901 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1903 /* debug bgp keepalive A.B.C.D */
1904 install_element (ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1905 install_element (CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1906 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1907 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1909 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1910 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1911 install_element (ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1912 install_element (CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1913 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1914 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1915 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1916 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1917 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1918 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1919 install_element (ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1920 install_element (CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1921 install_element (ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1922 install_element (CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1923 install_element (ENABLE_NODE
, &no_debug_bgp_cmd
);
1924 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1925 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1926 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1927 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1930 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
1931 * for BGP_DEBUG_TYPE
1934 bgp_debug_per_prefix (struct prefix
*p
, unsigned long term_bgp_debug_type
,
1935 unsigned int BGP_DEBUG_TYPE
, struct list
*per_prefix_list
)
1937 struct bgp_debug_filter
*filter
;
1938 struct listnode
*node
, *nnode
;
1940 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1942 /* We are debugging all prefixes so return true */
1943 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
1951 for (ALL_LIST_ELEMENTS (per_prefix_list
, node
, nnode
, filter
))
1952 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
1962 /* Return true if this peer is on the per_peer_list of peers to debug
1963 * for BGP_DEBUG_TYPE
1966 bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
1967 unsigned int BGP_DEBUG_TYPE
, struct list
*per_peer_list
)
1969 struct bgp_debug_filter
*filter
;
1970 struct listnode
*node
, *nnode
;
1972 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1974 /* We are debugging all peers so return true */
1975 if (!per_peer_list
|| list_isempty(per_peer_list
))
1983 for (ALL_LIST_ELEMENTS (per_peer_list
, node
, nnode
, filter
))
1984 if (strcmp (filter
->host
, host
) == 0)
1995 bgp_debug_neighbor_events (struct peer
*peer
)
2002 return bgp_debug_per_peer (host
,
2003 term_bgp_debug_neighbor_events
,
2004 BGP_DEBUG_NEIGHBOR_EVENTS
,
2005 bgp_debug_neighbor_events_peers
);
2009 bgp_debug_keepalive (struct peer
*peer
)
2016 return bgp_debug_per_peer (host
,
2017 term_bgp_debug_keepalive
,
2018 BGP_DEBUG_KEEPALIVE
,
2019 bgp_debug_keepalive_peers
);
2023 bgp_debug_update (struct peer
*peer
, struct prefix
*p
,
2024 struct update_group
*updgrp
, unsigned int inbound
)
2033 if (bgp_debug_per_peer (host
, term_bgp_debug_update
, BGP_DEBUG_UPDATE_IN
,
2034 bgp_debug_update_in_peers
))
2041 if (bgp_debug_per_peer (host
, term_bgp_debug_update
,
2042 BGP_DEBUG_UPDATE_OUT
,
2043 bgp_debug_update_out_peers
))
2046 /* Check if update debugging implicitly enabled for the group. */
2047 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2052 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
2054 if (bgp_debug_per_prefix (p
, term_bgp_debug_update
,
2055 BGP_DEBUG_UPDATE_PREFIX
,
2056 bgp_debug_update_prefixes
))
2064 bgp_debug_bestpath (struct prefix
*p
)
2066 if (BGP_DEBUG (bestpath
, BESTPATH
))
2068 if (bgp_debug_per_prefix (p
, term_bgp_debug_bestpath
,
2070 bgp_debug_bestpath_prefixes
))
2078 bgp_debug_zebra (struct prefix
*p
)
2080 if (BGP_DEBUG (zebra
, ZEBRA
))
2082 if (bgp_debug_per_prefix (p
, term_bgp_debug_zebra
, BGP_DEBUG_ZEBRA
,
2083 bgp_debug_zebra_prefixes
))