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>
30 #include "sockunion.h"
35 #include "bgpd/bgpd.h"
36 #include "bgpd/bgp_aspath.h"
37 #include "bgpd/bgp_route.h"
38 #include "bgpd/bgp_attr.h"
39 #include "bgpd/bgp_debug.h"
40 #include "bgpd/bgp_community.h"
41 #include "bgpd/bgp_updgrp.h"
43 unsigned long conf_bgp_debug_as4
;
44 unsigned long conf_bgp_debug_neighbor_events
;
45 unsigned long conf_bgp_debug_events
;
46 unsigned long conf_bgp_debug_packet
;
47 unsigned long conf_bgp_debug_filter
;
48 unsigned long conf_bgp_debug_keepalive
;
49 unsigned long conf_bgp_debug_update
;
50 unsigned long conf_bgp_debug_bestpath
;
51 unsigned long conf_bgp_debug_zebra
;
52 unsigned long conf_bgp_debug_allow_martians
;
53 unsigned long conf_bgp_debug_nht
;
54 unsigned long conf_bgp_debug_update_groups
;
56 unsigned long term_bgp_debug_as4
;
57 unsigned long term_bgp_debug_neighbor_events
;
58 unsigned long term_bgp_debug_events
;
59 unsigned long term_bgp_debug_packet
;
60 unsigned long term_bgp_debug_filter
;
61 unsigned long term_bgp_debug_keepalive
;
62 unsigned long term_bgp_debug_update
;
63 unsigned long term_bgp_debug_bestpath
;
64 unsigned long term_bgp_debug_zebra
;
65 unsigned long term_bgp_debug_allow_martians
;
66 unsigned long term_bgp_debug_nht
;
67 unsigned long term_bgp_debug_update_groups
;
69 struct list
*bgp_debug_neighbor_events_peers
= NULL
;
70 struct list
*bgp_debug_keepalive_peers
= NULL
;
71 struct list
*bgp_debug_update_out_peers
= NULL
;
72 struct list
*bgp_debug_update_in_peers
= NULL
;
73 struct list
*bgp_debug_update_prefixes
= NULL
;
74 struct list
*bgp_debug_bestpath_prefixes
= NULL
;
75 struct list
*bgp_debug_zebra_prefixes
= NULL
;
77 /* messages for BGP-4 status */
78 const struct message bgp_status_msg
[] =
81 { Connect
, "Connect" },
83 { OpenSent
, "OpenSent" },
84 { OpenConfirm
, "OpenConfirm" },
85 { Established
, "Established" },
86 { Clearing
, "Clearing" },
87 { Deleted
, "Deleted" },
89 const int bgp_status_msg_max
= BGP_STATUS_MAX
;
91 /* BGP message type string. */
92 const char *bgp_type_str
[] =
103 /* message for BGP-4 Notify */
104 static const struct message bgp_notify_msg
[] =
106 { BGP_NOTIFY_HEADER_ERR
, "Message Header Error"},
107 { BGP_NOTIFY_OPEN_ERR
, "OPEN Message Error"},
108 { BGP_NOTIFY_UPDATE_ERR
, "UPDATE Message Error"},
109 { BGP_NOTIFY_HOLD_ERR
, "Hold Timer Expired"},
110 { BGP_NOTIFY_FSM_ERR
, "Neighbor Events Error"},
111 { BGP_NOTIFY_CEASE
, "Cease"},
112 { BGP_NOTIFY_CAPABILITY_ERR
, "CAPABILITY Message Error"},
114 static const int bgp_notify_msg_max
= BGP_NOTIFY_MAX
;
116 static const struct message bgp_notify_head_msg
[] =
118 { BGP_NOTIFY_HEADER_NOT_SYNC
, "/Connection Not Synchronized"},
119 { BGP_NOTIFY_HEADER_BAD_MESLEN
, "/Bad Message Length"},
120 { BGP_NOTIFY_HEADER_BAD_MESTYPE
, "/Bad Message Type"}
122 static const int bgp_notify_head_msg_max
= BGP_NOTIFY_HEADER_MAX
;
124 static const struct message bgp_notify_open_msg
[] =
126 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
127 { BGP_NOTIFY_OPEN_UNSUP_VERSION
, "/Unsupported Version Number" },
128 { BGP_NOTIFY_OPEN_BAD_PEER_AS
, "/Bad Peer AS"},
129 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT
, "/Bad BGP Identifier"},
130 { BGP_NOTIFY_OPEN_UNSUP_PARAM
, "/Unsupported Optional Parameter"},
131 { BGP_NOTIFY_OPEN_AUTH_FAILURE
, "/Authentication Failure"},
132 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
, "/Unacceptable Hold Time"},
133 { BGP_NOTIFY_OPEN_UNSUP_CAPBL
, "/Unsupported Capability"},
135 static const int bgp_notify_open_msg_max
= BGP_NOTIFY_OPEN_MAX
;
137 static const struct message bgp_notify_update_msg
[] =
139 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
140 { BGP_NOTIFY_UPDATE_MAL_ATTR
, "/Malformed Attribute List"},
141 { BGP_NOTIFY_UPDATE_UNREC_ATTR
, "/Unrecognized Well-known Attribute"},
142 { BGP_NOTIFY_UPDATE_MISS_ATTR
, "/Missing Well-known Attribute"},
143 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR
, "/Attribute Flags Error"},
144 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR
, "/Attribute Length Error"},
145 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN
, "/Invalid ORIGIN Attribute"},
146 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP
, "/AS Routing Loop"},
147 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP
, "/Invalid NEXT_HOP Attribute"},
148 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR
, "/Optional Attribute Error"},
149 { BGP_NOTIFY_UPDATE_INVAL_NETWORK
, "/Invalid Network Field"},
150 { BGP_NOTIFY_UPDATE_MAL_AS_PATH
, "/Malformed AS_PATH"},
152 static const int bgp_notify_update_msg_max
= BGP_NOTIFY_UPDATE_MAX
;
154 static const struct message bgp_notify_cease_msg
[] =
156 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
157 { BGP_NOTIFY_CEASE_MAX_PREFIX
, "/Maximum Number of Prefixes Reached"},
158 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
, "/Administratively Shutdown"},
159 { BGP_NOTIFY_CEASE_PEER_UNCONFIG
, "/Peer Unconfigured"},
160 { BGP_NOTIFY_CEASE_ADMIN_RESET
, "/Administratively Reset"},
161 { BGP_NOTIFY_CEASE_CONNECT_REJECT
, "/Connection Rejected"},
162 { BGP_NOTIFY_CEASE_CONFIG_CHANGE
, "/Other Configuration Change"},
163 { BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
, "/Connection collision resolution"},
164 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE
, "/Out of Resource"},
166 static const int bgp_notify_cease_msg_max
= BGP_NOTIFY_CEASE_MAX
;
168 static const struct message bgp_notify_capability_msg
[] =
170 { BGP_NOTIFY_SUBCODE_UNSPECIFIC
, "/Unspecific"},
171 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION
, "/Invalid Action Value" },
172 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH
, "/Invalid Capability Length"},
173 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE
, "/Malformed Capability Value"},
175 static const int bgp_notify_capability_msg_max
= BGP_NOTIFY_CAPABILITY_MAX
;
177 /* Origin strings. */
178 const char *bgp_origin_str
[] = {"i","e","?"};
179 const char *bgp_origin_long_str
[] = {"IGP","EGP","incomplete"};
182 /* Given a string return a pointer the corresponding peer structure */
184 bgp_find_peer (struct vty
*vty
, const char *peer_str
)
192 ret
= str2sockunion (peer_str
, &su
);
197 peer
= peer_lookup_by_conf_if (bgp
, peer_str
);
200 peer
= peer_lookup_by_hostname (bgp
, peer_str
);
205 return peer_lookup (bgp
, &su
);
209 bgp_debug_list_free(struct list
*list
)
211 struct bgp_debug_filter
*filter
;
212 struct listnode
*node
, *nnode
;
215 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
217 listnode_delete (list
, filter
);
220 prefix_free(filter
->p
);
223 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
225 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
229 /* Print the desc along with a list of peers/prefixes this debug is
232 bgp_debug_list_print (struct vty
*vty
, const char *desc
, struct list
*list
)
234 struct bgp_debug_filter
*filter
;
235 struct listnode
*node
, *nnode
;
236 char buf
[INET6_ADDRSTRLEN
];
238 vty_out (vty
, "%s", desc
);
240 if (list
&& !list_isempty(list
))
242 vty_out (vty
, " for");
243 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
246 vty_out (vty
, " %s", filter
->host
);
249 vty_out (vty
, " %s/%d",
250 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
251 filter
->p
->prefixlen
);
255 vty_out (vty
, "%s", VTY_NEWLINE
);
258 /* Print the command to enable the debug for each peer/prefix this debug is
262 bgp_debug_list_conf_print (struct vty
*vty
, const char *desc
, struct list
*list
)
264 struct bgp_debug_filter
*filter
;
265 struct listnode
*node
, *nnode
;
266 char buf
[INET6_ADDRSTRLEN
];
269 if (list
&& !list_isempty(list
))
271 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
275 vty_out (vty
, "%s %s%s", desc
, filter
->host
, VTY_NEWLINE
);
282 vty_out (vty
, "%s %s/%d%s", desc
,
283 inet_ntop (filter
->p
->family
, &filter
->p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
284 filter
->p
->prefixlen
, VTY_NEWLINE
);
292 vty_out (vty
, "%s%s", desc
, VTY_NEWLINE
);
300 bgp_debug_list_add_entry(struct list
*list
, const char *host
, struct prefix
*p
)
302 struct bgp_debug_filter
*filter
;
304 filter
= XCALLOC (MTYPE_BGP_DEBUG_FILTER
, sizeof (struct bgp_debug_filter
));
308 filter
->host
= XSTRDUP (MTYPE_BGP_DEBUG_STR
, host
);
317 listnode_add(list
, filter
);
321 bgp_debug_list_remove_entry(struct list
*list
, const char *host
, struct prefix
*p
)
323 struct bgp_debug_filter
*filter
;
324 struct listnode
*node
, *nnode
;
326 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
328 if (host
&& strcmp (filter
->host
, host
) == 0)
330 listnode_delete (list
, filter
);
331 XFREE (MTYPE_BGP_DEBUG_STR
, filter
->host
);
332 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
335 else if (p
&& filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
337 listnode_delete (list
, filter
);
338 prefix_free (filter
->p
);
339 XFREE (MTYPE_BGP_DEBUG_FILTER
, filter
);
348 bgp_debug_list_has_entry(struct list
*list
, const char *host
, struct prefix
*p
)
350 struct bgp_debug_filter
*filter
;
351 struct listnode
*node
, *nnode
;
353 for (ALL_LIST_ELEMENTS (list
, node
, nnode
, filter
))
357 if (strcmp (filter
->host
, host
) == 0)
364 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
375 bgp_debug_peer_updout_enabled(char *host
)
377 return (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
));
380 /* Dump attribute. */
382 bgp_dump_attr (struct peer
*peer
, struct attr
*attr
, char *buf
, size_t size
)
387 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
)))
388 snprintf (buf
, size
, "nexthop %s", inet_ntoa (attr
->nexthop
));
390 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN
)))
391 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", origin %s",
392 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
,
411 #endif /* HAVE_IPV6 */
413 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
)))
414 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", localpref %u",
417 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
418 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", metric %u",
421 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
)))
422 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", community %s",
423 community_str (attr
->community
));
425 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
)))
426 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", atomic-aggregate");
428 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
429 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", aggregated by %u %s",
430 attr
->extra
->aggregator_as
,
431 inet_ntoa (attr
->extra
->aggregator_addr
));
433 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)))
434 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", originator %s",
435 inet_ntoa (attr
->extra
->originator_id
));
437 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST
)))
441 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", clusterlist");
442 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
443 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), " %s",
444 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
447 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH
)))
448 snprintf (buf
+ strlen (buf
), size
- strlen (buf
), ", path %s",
449 aspath_print (attr
->aspath
));
451 if (strlen (buf
) > 1)
458 bgp_notify_code_str (char code
)
460 return LOOKUP_DEF (bgp_notify_msg
, code
, "Unrecognized Error Code");
464 bgp_notify_subcode_str (char code
, char subcode
)
469 case BGP_NOTIFY_HEADER_ERR
:
470 return LOOKUP_DEF (bgp_notify_head_msg
, subcode
,
471 "Unrecognized Error Subcode");
472 case BGP_NOTIFY_OPEN_ERR
:
473 return LOOKUP_DEF (bgp_notify_open_msg
, subcode
,
474 "Unrecognized Error Subcode");
475 case BGP_NOTIFY_UPDATE_ERR
:
476 return LOOKUP_DEF (bgp_notify_update_msg
, subcode
,
477 "Unrecognized Error Subcode");
478 case BGP_NOTIFY_HOLD_ERR
:
480 case BGP_NOTIFY_FSM_ERR
:
482 case BGP_NOTIFY_CEASE
:
483 return LOOKUP_DEF (bgp_notify_cease_msg
, subcode
,
484 "Unrecognized Error Subcode");
485 case BGP_NOTIFY_CAPABILITY_ERR
:
486 return LOOKUP_DEF (bgp_notify_capability_msg
, subcode
,
487 "Unrecognized Error Subcode");
492 /* dump notify packet */
494 bgp_notify_print(struct peer
*peer
, struct bgp_notify
*bgp_notify
,
497 const char *subcode_str
;
498 const char *code_str
;
500 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
) || bgp_flag_check (peer
->bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
))
502 code_str
= bgp_notify_code_str(bgp_notify
->code
);
503 subcode_str
= bgp_notify_subcode_str(bgp_notify
->code
, bgp_notify
->subcode
);
505 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
506 strcmp (direct
, "received") == 0 ? "received from" : "sent to",
507 peer
->host
, bgp_notify
->code
, bgp_notify
->subcode
,
508 code_str
, subcode_str
, bgp_notify
->length
,
509 bgp_notify
->data
? bgp_notify
->data
: "");
514 bgp_debug_clear_updgrp_update_dbg(struct bgp
*bgp
)
517 bgp
= bgp_get_default();
518 update_group_walk (bgp
, update_group_clear_update_dbg
, NULL
);
522 /* Debug option setting interface. */
523 unsigned long bgp_debug_option
= 0;
526 debug (unsigned int option
)
528 return bgp_debug_option
& option
;
531 DEFUN (debug_bgp_as4
,
538 if (vty
->node
== CONFIG_NODE
)
542 TERM_DEBUG_ON (as4
, AS4
);
543 vty_out (vty
, "BGP as4 debugging is on%s", VTY_NEWLINE
);
548 DEFUN (no_debug_bgp_as4
,
549 no_debug_bgp_as4_cmd
,
556 if (vty
->node
== CONFIG_NODE
)
557 DEBUG_OFF (as4
, AS4
);
560 TERM_DEBUG_OFF (as4
, AS4
);
561 vty_out (vty
, "BGP as4 debugging is off%s", VTY_NEWLINE
);
566 DEFUN (debug_bgp_as4_segment
,
567 debug_bgp_as4_segment_cmd
,
568 "debug bgp as4 segment",
572 "BGP AS4 aspath segment handling\n")
574 if (vty
->node
== CONFIG_NODE
)
575 DEBUG_ON (as4
, AS4_SEGMENT
);
578 TERM_DEBUG_ON (as4
, AS4_SEGMENT
);
579 vty_out (vty
, "BGP as4 segment debugging is on%s", VTY_NEWLINE
);
584 DEFUN (no_debug_bgp_as4_segment
,
585 no_debug_bgp_as4_segment_cmd
,
586 "no debug bgp as4 segment",
591 "BGP AS4 aspath segment handling\n")
593 if (vty
->node
== CONFIG_NODE
)
594 DEBUG_OFF (as4
, AS4_SEGMENT
);
597 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
598 vty_out (vty
, "BGP as4 segment debugging is off%s", VTY_NEWLINE
);
603 /* debug bgp neighbor_events */
604 DEFUN (debug_bgp_neighbor_events
,
605 debug_bgp_neighbor_events_cmd
,
606 "debug bgp neighbor-events",
609 "BGP Neighbor Events\n")
611 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
613 if (vty
->node
== CONFIG_NODE
)
614 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
617 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
618 vty_out (vty
, "BGP neighbor-events debugging is on%s", VTY_NEWLINE
);
623 DEFUN (debug_bgp_neighbor_events_peer
,
624 debug_bgp_neighbor_events_peer_cmd
,
625 "debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
628 "BGP Neighbor Events\n"
629 "BGP neighbor IP address to debug\n"
630 "BGP IPv6 neighbor to debug\n"
631 "BGP neighbor on interface to debug\n")
634 const char *host
= argv
[idx_peer
]->arg
;
636 if (!bgp_debug_neighbor_events_peers
)
637 bgp_debug_neighbor_events_peers
= list_new ();
639 if (bgp_debug_list_has_entry(bgp_debug_neighbor_events_peers
, host
, NULL
))
641 vty_out (vty
, "BGP neighbor-events debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
645 bgp_debug_list_add_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
647 if (vty
->node
== CONFIG_NODE
)
648 DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
651 TERM_DEBUG_ON (neighbor_events
, NEIGHBOR_EVENTS
);
652 vty_out (vty
, "BGP neighbor-events debugging is on for %s%s", host
, VTY_NEWLINE
);
657 DEFUN (no_debug_bgp_neighbor_events
,
658 no_debug_bgp_neighbor_events_cmd
,
659 "no debug bgp neighbor-events",
665 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
667 if (vty
->node
== CONFIG_NODE
)
668 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
671 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
672 vty_out (vty
, "BGP neighbor-events debugging is off%s", VTY_NEWLINE
);
677 DEFUN (no_debug_bgp_neighbor_events_peer
,
678 no_debug_bgp_neighbor_events_peer_cmd
,
679 "no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
684 "BGP neighbor IP address to debug\n"
685 "BGP IPv6 neighbor to debug\n"
686 "BGP neighbor on interface to debug\n")
690 const char *host
= argv
[idx_peer
]->arg
;
692 if (bgp_debug_neighbor_events_peers
&& !list_isempty(bgp_debug_neighbor_events_peers
))
694 found_peer
= bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
696 if (list_isempty(bgp_debug_neighbor_events_peers
))
698 if (vty
->node
== CONFIG_NODE
)
699 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
701 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
706 vty_out (vty
, "BGP neighbor-events debugging is off for %s%s", host
, VTY_NEWLINE
);
708 vty_out (vty
, "BGP neighbor-events debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
714 DEFUN (debug_bgp_nht
,
719 "BGP nexthop tracking events\n")
721 if (vty
->node
== CONFIG_NODE
)
725 TERM_DEBUG_ON (nht
, NHT
);
726 vty_out (vty
, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE
);
731 DEFUN (no_debug_bgp_nht
,
732 no_debug_bgp_nht_cmd
,
737 "BGP nexthop tracking events\n")
739 if (vty
->node
== CONFIG_NODE
)
740 DEBUG_OFF (nht
, NHT
);
743 TERM_DEBUG_OFF (nht
, NHT
);
744 vty_out (vty
, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE
);
749 /* debug bgp keepalives */
750 DEFUN (debug_bgp_keepalive
,
751 debug_bgp_keepalive_cmd
,
752 "debug bgp keepalives",
757 bgp_debug_list_free(bgp_debug_keepalive_peers
);
759 if (vty
->node
== CONFIG_NODE
)
760 DEBUG_ON (keepalive
, KEEPALIVE
);
763 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
764 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
769 DEFUN (debug_bgp_keepalive_peer
,
770 debug_bgp_keepalive_peer_cmd
,
771 "debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
774 "BGP Neighbor Events\n"
775 "BGP neighbor IP address to debug\n"
776 "BGP IPv6 neighbor to debug\n"
777 "BGP neighbor on interface to debug\n")
780 const char *host
= argv
[idx_peer
]->arg
;
782 if (!bgp_debug_keepalive_peers
)
783 bgp_debug_keepalive_peers
= list_new ();
785 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
))
787 vty_out (vty
, "BGP keepalive debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
791 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
793 if (vty
->node
== CONFIG_NODE
)
794 DEBUG_ON (keepalive
, KEEPALIVE
);
797 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
798 vty_out (vty
, "BGP keepalives debugging is on for %s%s", host
, VTY_NEWLINE
);
803 DEFUN (no_debug_bgp_keepalive
,
804 no_debug_bgp_keepalive_cmd
,
805 "no debug bgp keepalives",
811 bgp_debug_list_free(bgp_debug_keepalive_peers
);
813 if (vty
->node
== CONFIG_NODE
)
814 DEBUG_OFF (keepalive
, KEEPALIVE
);
817 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
818 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
823 DEFUN (no_debug_bgp_keepalive_peer
,
824 no_debug_bgp_keepalive_peer_cmd
,
825 "no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
830 "BGP neighbor IP address to debug\n"
831 "BGP IPv6 neighbor to debug\n"
832 "BGP neighbor on interface to debug\n")
836 const char *host
= argv
[idx_peer
]->arg
;
838 if (bgp_debug_keepalive_peers
&& !list_isempty(bgp_debug_keepalive_peers
))
840 found_peer
= bgp_debug_list_remove_entry(bgp_debug_keepalive_peers
, host
, NULL
);
842 if (list_isempty(bgp_debug_keepalive_peers
))
844 if (vty
->node
== CONFIG_NODE
)
845 DEBUG_OFF (keepalive
, KEEPALIVE
);
847 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
852 vty_out (vty
, "BGP keepalives debugging is off for %s%s", host
, VTY_NEWLINE
);
854 vty_out (vty
, "BGP keepalives debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
859 /* debug bgp bestpath */
860 DEFUN (debug_bgp_bestpath_prefix
,
861 debug_bgp_bestpath_prefix_cmd
,
862 "debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
870 int idx_ipv4_ipv6_prefixlen
= 3;
871 struct prefix
*argv_p
;
874 argv_p
= prefix_new();
875 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
879 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
884 if (!bgp_debug_bestpath_prefixes
)
885 bgp_debug_bestpath_prefixes
= list_new ();
887 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
))
889 vty_out (vty
, "BGP bestptah debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
893 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
895 if (vty
->node
== CONFIG_NODE
)
897 DEBUG_ON (bestpath
, BESTPATH
);
901 TERM_DEBUG_ON (bestpath
, BESTPATH
);
902 vty_out (vty
, "BGP bestpath debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
908 DEFUN (no_debug_bgp_bestpath_prefix
,
909 no_debug_bgp_bestpath_prefix_cmd
,
910 "no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
919 int idx_ipv4_ipv6_prefixlen
= 4;
920 struct prefix
*argv_p
;
921 int found_prefix
= 0;
924 argv_p
= prefix_new();
925 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
929 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
933 if (bgp_debug_bestpath_prefixes
&& !list_isempty(bgp_debug_bestpath_prefixes
))
935 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
937 if (list_isempty(bgp_debug_bestpath_prefixes
))
939 if (vty
->node
== CONFIG_NODE
)
941 DEBUG_OFF (bestpath
, BESTPATH
);
945 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
946 vty_out (vty
, "BGP bestpath debugging (per prefix) is off%s", VTY_NEWLINE
);
952 vty_out (vty
, "BGP bestpath debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
954 vty_out (vty
, "BGP bestpath debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
959 DEFUN (no_debug_bgp_bestpath
,
960 no_debug_bgp_bestpath_cmd
,
961 "no debug bgp bestpath",
967 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
969 if (vty
->node
== CONFIG_NODE
)
970 DEBUG_OFF (bestpath
, BESTPATH
);
973 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
974 vty_out (vty
, "BGP bestpath debugging is off%s", VTY_NEWLINE
);
979 /* debug bgp updates */
980 DEFUN (debug_bgp_update
,
981 debug_bgp_update_cmd
,
987 bgp_debug_list_free(bgp_debug_update_in_peers
);
988 bgp_debug_list_free(bgp_debug_update_out_peers
);
989 bgp_debug_list_free(bgp_debug_update_prefixes
);
991 if (vty
->node
== CONFIG_NODE
)
993 DEBUG_ON (update
, UPDATE_IN
);
994 DEBUG_ON (update
, UPDATE_OUT
);
998 TERM_DEBUG_ON (update
, UPDATE_IN
);
999 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1000 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
1005 DEFUN (debug_bgp_update_direct
,
1006 debug_bgp_update_direct_cmd
,
1007 "debug bgp updates <in|out>",
1012 "Outbound updates\n")
1016 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1017 bgp_debug_list_free(bgp_debug_update_in_peers
);
1019 bgp_debug_list_free(bgp_debug_update_out_peers
);
1021 if (vty
->node
== CONFIG_NODE
)
1023 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1024 DEBUG_ON (update
, UPDATE_IN
);
1026 DEBUG_ON (update
, UPDATE_OUT
);
1030 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1032 TERM_DEBUG_ON (update
, UPDATE_IN
);
1033 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
1037 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1038 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
1044 DEFUN (debug_bgp_update_direct_peer
,
1045 debug_bgp_update_direct_peer_cmd
,
1046 "debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1051 "Outbound updates\n"
1052 "BGP neighbor IP address to debug\n"
1053 "BGP IPv6 neighbor to debug\n"
1054 "BGP neighbor on interface to debug\n")
1058 const char *host
= argv
[idx_peer
]->arg
;
1061 if (!bgp_debug_update_in_peers
)
1062 bgp_debug_update_in_peers
= list_new ();
1064 if (!bgp_debug_update_out_peers
)
1065 bgp_debug_update_out_peers
= list_new ();
1067 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1074 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
, NULL
))
1076 vty_out (vty
, "BGP inbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1083 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
))
1085 vty_out (vty
, "BGP outbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1091 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1095 struct peer_af
*paf
;
1098 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
, NULL
);
1099 peer
= bgp_find_peer (vty
, host
);
1103 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1105 paf
= peer
->peer_af_array
[afidx
];
1108 if (PAF_SUBGRP (paf
))
1110 UPDGRP_PEER_DBG_EN(PAF_SUBGRP(paf
)->update_group
);
1117 if (vty
->node
== CONFIG_NODE
)
1120 DEBUG_ON (update
, UPDATE_IN
);
1122 DEBUG_ON (update
, UPDATE_OUT
);
1128 TERM_DEBUG_ON (update
, UPDATE_IN
);
1129 vty_out (vty
, "BGP updates debugging is on (inbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1133 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1134 vty_out (vty
, "BGP updates debugging is on (outbound) for %s%s", argv
[idx_peer
]->arg
, VTY_NEWLINE
);
1140 DEFUN (no_debug_bgp_update_direct
,
1141 no_debug_bgp_update_direct_cmd
,
1142 "no debug bgp updates <in|out>",
1148 "Outbound updates\n")
1151 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1153 bgp_debug_list_free(bgp_debug_update_in_peers
);
1155 if (vty
->node
== CONFIG_NODE
)
1157 DEBUG_OFF (update
, UPDATE_IN
);
1161 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1162 vty_out (vty
, "BGP updates debugging is off (inbound)%s", VTY_NEWLINE
);
1167 bgp_debug_list_free(bgp_debug_update_out_peers
);
1169 if (vty
->node
== CONFIG_NODE
)
1171 DEBUG_OFF (update
, UPDATE_OUT
);
1175 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1176 vty_out (vty
, "BGP updates debugging is off (outbound)%s", VTY_NEWLINE
);
1183 DEFUN (no_debug_bgp_update_direct_peer
,
1184 no_debug_bgp_update_direct_peer_cmd
,
1185 "no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
1191 "Outbound updates\n"
1192 "BGP neighbor IP address to debug\n"
1193 "BGP IPv6 neighbor to debug\n"
1194 "BGP neighbor on interface to debug\n")
1200 const char *host
= argv
[idx_peer
]->arg
;
1202 if (strncmp ("i", argv
[idx_in_out
]->arg
, 1) == 0)
1207 if (inbound
&& bgp_debug_update_in_peers
&&
1208 !list_isempty(bgp_debug_update_in_peers
))
1210 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_in_peers
, host
, NULL
);
1212 if (list_isempty(bgp_debug_update_in_peers
))
1214 if (vty
->node
== CONFIG_NODE
)
1215 DEBUG_OFF (update
, UPDATE_IN
);
1218 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1219 vty_out (vty
, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE
);
1224 if (!inbound
&& bgp_debug_update_out_peers
&&
1225 !list_isempty(bgp_debug_update_out_peers
))
1227 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_out_peers
, host
, NULL
);
1229 if (list_isempty(bgp_debug_update_out_peers
))
1231 if (vty
->node
== CONFIG_NODE
)
1232 DEBUG_OFF (update
, UPDATE_OUT
);
1235 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1236 vty_out (vty
, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE
);
1241 struct peer_af
*paf
;
1243 peer
= bgp_find_peer (vty
, host
);
1247 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1249 paf
= peer
->peer_af_array
[afidx
];
1252 if (PAF_SUBGRP (paf
))
1254 UPDGRP_PEER_DBG_DIS(PAF_SUBGRP(paf
)->update_group
);
1263 vty_out (vty
, "BGP updates debugging (inbound) is off for %s%s", host
, VTY_NEWLINE
);
1265 vty_out (vty
, "BGP updates debugging (outbound) is off for %s%s", host
, VTY_NEWLINE
);
1268 vty_out (vty
, "BGP updates debugging (inbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1270 vty_out (vty
, "BGP updates debugging (outbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1275 DEFUN (debug_bgp_update_prefix
,
1276 debug_bgp_update_prefix_cmd
,
1277 "debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1281 "Specify a prefix to debug\n"
1286 int idx_ipv4_ipv6_prefixlen
= 4;
1287 struct prefix
*argv_p
;
1290 argv_p
= prefix_new();
1291 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1294 prefix_free(argv_p
);
1295 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1300 if (!bgp_debug_update_prefixes
)
1301 bgp_debug_update_prefixes
= list_new ();
1303 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
))
1305 vty_out (vty
, "BGP updates debugging is already enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1309 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1311 if (vty
->node
== CONFIG_NODE
)
1313 DEBUG_ON (update
, UPDATE_PREFIX
);
1317 TERM_DEBUG_ON (update
, UPDATE_PREFIX
);
1318 vty_out (vty
, "BGP updates debugging is on for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1324 DEFUN (no_debug_bgp_update_prefix
,
1325 no_debug_bgp_update_prefix_cmd
,
1326 "no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
1331 "Specify a prefix to debug\n"
1336 int idx_ipv4_ipv6_prefixlen
= 5;
1337 struct prefix
*argv_p
;
1338 int found_prefix
= 0;
1341 argv_p
= prefix_new();
1342 ret
= str2prefix (argv
[idx_ipv4_ipv6_prefixlen
]->arg
, argv_p
);
1345 prefix_free(argv_p
);
1346 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1350 if (bgp_debug_update_prefixes
&& !list_isempty(bgp_debug_update_prefixes
))
1352 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1354 if (list_isempty(bgp_debug_update_prefixes
))
1356 if (vty
->node
== CONFIG_NODE
)
1358 DEBUG_OFF (update
, UPDATE_PREFIX
);
1362 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1363 vty_out (vty
, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE
);
1369 vty_out (vty
, "BGP updates debugging is off for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1371 vty_out (vty
, "BGP updates debugging was not enabled for %s%s", argv
[idx_ipv4_ipv6_prefixlen
]->arg
, VTY_NEWLINE
);
1376 DEFUN (no_debug_bgp_update
,
1377 no_debug_bgp_update_cmd
,
1378 "no debug bgp updates",
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(vty
->index
);
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 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1620 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1621 bgp_debug_list_free(bgp_debug_update_in_peers
);
1622 bgp_debug_list_free(bgp_debug_update_out_peers
);
1623 bgp_debug_list_free(bgp_debug_update_prefixes
);
1624 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1625 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1627 bgp_debug_clear_updgrp_update_dbg(vty
->index
);
1629 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
1630 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1631 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1632 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1633 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
1634 TERM_DEBUG_OFF (as4
, AS4
);
1635 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
1636 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
1637 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1638 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1639 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
1644 DEFUN (show_debugging_bgp
,
1645 show_debugging_bgp_cmd
,
1646 "show debugging bgp",
1651 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
1653 if (BGP_DEBUG (as4
, AS4
))
1654 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
1656 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1657 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
1659 if (BGP_DEBUG (bestpath
, BESTPATH
))
1660 bgp_debug_list_print (vty
, " BGP bestpath debugging is on",
1661 bgp_debug_bestpath_prefixes
);
1663 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1664 bgp_debug_list_print (vty
, " BGP keepalives debugging is on",
1665 bgp_debug_keepalive_peers
);
1667 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1668 bgp_debug_list_print (vty
, " BGP neighbor-events debugging is on",
1669 bgp_debug_neighbor_events_peers
);
1671 if (BGP_DEBUG (nht
, NHT
))
1672 vty_out (vty
, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE
);
1674 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1675 vty_out (vty
, " BGP update-groups debugging is on%s", VTY_NEWLINE
);
1677 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1678 bgp_debug_list_print (vty
, " BGP updates debugging is on",
1679 bgp_debug_update_prefixes
);
1681 if (BGP_DEBUG (update
, UPDATE_IN
))
1682 bgp_debug_list_print (vty
, " BGP updates debugging is on (inbound)",
1683 bgp_debug_update_in_peers
);
1685 if (BGP_DEBUG (update
, UPDATE_OUT
))
1686 bgp_debug_list_print (vty
, " BGP updates debugging is on (outbound)",
1687 bgp_debug_update_out_peers
);
1689 if (BGP_DEBUG (zebra
, ZEBRA
))
1690 bgp_debug_list_print (vty
, " BGP zebra debugging is on",
1691 bgp_debug_zebra_prefixes
);
1693 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1694 vty_out (vty
, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE
);
1695 vty_out (vty
, "%s", VTY_NEWLINE
);
1699 /* return count of number of debug flags set */
1701 bgp_debug_count(void)
1704 if (BGP_DEBUG (as4
, AS4
))
1707 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1710 if (BGP_DEBUG (bestpath
, BESTPATH
))
1713 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1716 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1719 if (BGP_DEBUG (nht
, NHT
))
1722 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1725 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1728 if (BGP_DEBUG (update
, UPDATE_IN
))
1731 if (BGP_DEBUG (update
, UPDATE_OUT
))
1734 if (BGP_DEBUG (zebra
, ZEBRA
))
1737 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1744 bgp_config_write_debug (struct vty
*vty
)
1748 if (CONF_BGP_DEBUG (as4
, AS4
))
1750 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
1754 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
1756 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
1760 if (CONF_BGP_DEBUG (bestpath
, BESTPATH
))
1762 write
+= bgp_debug_list_conf_print (vty
, "debug bgp bestpath",
1763 bgp_debug_bestpath_prefixes
);
1766 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
1768 write
+= bgp_debug_list_conf_print (vty
, "debug bgp keepalives",
1769 bgp_debug_keepalive_peers
);
1772 if (CONF_BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1774 write
+= bgp_debug_list_conf_print (vty
, "debug bgp neighbor-events",
1775 bgp_debug_neighbor_events_peers
);
1778 if (CONF_BGP_DEBUG (nht
, NHT
))
1780 vty_out (vty
, "debug bgp nht%s", VTY_NEWLINE
);
1784 if (CONF_BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1786 vty_out (vty
, "debug bgp update-groups%s", VTY_NEWLINE
);
1790 if (CONF_BGP_DEBUG (update
, UPDATE_PREFIX
))
1792 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates prefix",
1793 bgp_debug_update_prefixes
);
1796 if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
1798 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates in",
1799 bgp_debug_update_in_peers
);
1802 if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
1804 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates out",
1805 bgp_debug_update_out_peers
);
1808 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
1810 if (!bgp_debug_zebra_prefixes
|| list_isempty(bgp_debug_zebra_prefixes
))
1812 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
1817 write
+= bgp_debug_list_conf_print (vty
, "debug bgp zebra prefix",
1818 bgp_debug_zebra_prefixes
);
1822 if (CONF_BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1824 vty_out (vty
, "debug bgp allow-martians%s", VTY_NEWLINE
);
1831 static struct cmd_node debug_node
=
1839 bgp_debug_init (void)
1841 install_node (&debug_node
, bgp_config_write_debug
);
1843 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
1845 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
1846 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
1847 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1848 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1850 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1851 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1852 install_element (ENABLE_NODE
, &debug_bgp_nht_cmd
);
1853 install_element (CONFIG_NODE
, &debug_bgp_nht_cmd
);
1854 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1855 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1856 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
1857 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
1858 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1859 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1860 install_element (ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1861 install_element (CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1862 install_element (ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1863 install_element (CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1864 install_element (ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1865 install_element (CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1867 /* debug bgp updates (in|out) */
1868 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1869 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1870 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1871 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1873 /* debug bgp updates (in|out) A.B.C.D */
1874 install_element (ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1875 install_element (CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1876 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1877 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1879 /* debug bgp updates prefix A.B.C.D/M */
1880 install_element (ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1881 install_element (CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1882 install_element (ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1883 install_element (CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1885 /* debug bgp zebra prefix A.B.C.D/M */
1886 install_element (ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1887 install_element (CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1888 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1889 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1891 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1892 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1893 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1894 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1896 /* debug bgp neighbor-events A.B.C.D */
1897 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1898 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1899 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1900 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1902 /* debug bgp keepalive A.B.C.D */
1903 install_element (ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1904 install_element (CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1905 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1906 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1908 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1909 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1910 install_element (ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1911 install_element (CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1912 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1913 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1914 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1915 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1916 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1917 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1918 install_element (ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1919 install_element (CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1920 install_element (ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1921 install_element (CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1922 install_element (ENABLE_NODE
, &no_debug_bgp_cmd
);
1923 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1924 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1925 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1926 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1929 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
1930 * for BGP_DEBUG_TYPE
1933 bgp_debug_per_prefix (struct prefix
*p
, unsigned long term_bgp_debug_type
,
1934 unsigned int BGP_DEBUG_TYPE
, struct list
*per_prefix_list
)
1936 struct bgp_debug_filter
*filter
;
1937 struct listnode
*node
, *nnode
;
1939 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1941 /* We are debugging all prefixes so return true */
1942 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
1950 for (ALL_LIST_ELEMENTS (per_prefix_list
, node
, nnode
, filter
))
1951 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
1961 /* Return true if this peer is on the per_peer_list of peers to debug
1962 * for BGP_DEBUG_TYPE
1965 bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
1966 unsigned int BGP_DEBUG_TYPE
, struct list
*per_peer_list
)
1968 struct bgp_debug_filter
*filter
;
1969 struct listnode
*node
, *nnode
;
1971 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1973 /* We are debugging all peers so return true */
1974 if (!per_peer_list
|| list_isempty(per_peer_list
))
1982 for (ALL_LIST_ELEMENTS (per_peer_list
, node
, nnode
, filter
))
1983 if (strcmp (filter
->host
, host
) == 0)
1994 bgp_debug_neighbor_events (struct peer
*peer
)
2001 return bgp_debug_per_peer (host
,
2002 term_bgp_debug_neighbor_events
,
2003 BGP_DEBUG_NEIGHBOR_EVENTS
,
2004 bgp_debug_neighbor_events_peers
);
2008 bgp_debug_keepalive (struct peer
*peer
)
2015 return bgp_debug_per_peer (host
,
2016 term_bgp_debug_keepalive
,
2017 BGP_DEBUG_KEEPALIVE
,
2018 bgp_debug_keepalive_peers
);
2022 bgp_debug_update (struct peer
*peer
, struct prefix
*p
,
2023 struct update_group
*updgrp
, unsigned int inbound
)
2032 if (bgp_debug_per_peer (host
, term_bgp_debug_update
, BGP_DEBUG_UPDATE_IN
,
2033 bgp_debug_update_in_peers
))
2040 if (bgp_debug_per_peer (host
, term_bgp_debug_update
,
2041 BGP_DEBUG_UPDATE_OUT
,
2042 bgp_debug_update_out_peers
))
2045 /* Check if update debugging implicitly enabled for the group. */
2046 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2051 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
2053 if (bgp_debug_per_prefix (p
, term_bgp_debug_update
,
2054 BGP_DEBUG_UPDATE_PREFIX
,
2055 bgp_debug_update_prefixes
))
2063 bgp_debug_bestpath (struct prefix
*p
)
2065 if (BGP_DEBUG (bestpath
, BESTPATH
))
2067 if (bgp_debug_per_prefix (p
, term_bgp_debug_bestpath
,
2069 bgp_debug_bestpath_prefixes
))
2077 bgp_debug_zebra (struct prefix
*p
)
2079 if (BGP_DEBUG (zebra
, ZEBRA
))
2081 if (bgp_debug_per_prefix (p
, term_bgp_debug_zebra
, BGP_DEBUG_ZEBRA
,
2082 bgp_debug_zebra_prefixes
))