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")
633 const char *host
= argv
[0];
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")
688 const char *host
= argv
[0];
690 if (bgp_debug_neighbor_events_peers
&& !list_isempty(bgp_debug_neighbor_events_peers
))
692 found_peer
= bgp_debug_list_remove_entry(bgp_debug_neighbor_events_peers
, host
, NULL
);
694 if (list_isempty(bgp_debug_neighbor_events_peers
))
696 if (vty
->node
== CONFIG_NODE
)
697 DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
699 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
704 vty_out (vty
, "BGP neighbor-events debugging is off for %s%s", host
, VTY_NEWLINE
);
706 vty_out (vty
, "BGP neighbor-events debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
712 DEFUN (debug_bgp_nht
,
717 "BGP nexthop tracking events\n")
719 if (vty
->node
== CONFIG_NODE
)
723 TERM_DEBUG_ON (nht
, NHT
);
724 vty_out (vty
, "BGP nexthop tracking debugging is on%s", VTY_NEWLINE
);
729 DEFUN (no_debug_bgp_nht
,
730 no_debug_bgp_nht_cmd
,
735 "BGP nexthop tracking events\n")
737 if (vty
->node
== CONFIG_NODE
)
738 DEBUG_OFF (nht
, NHT
);
741 TERM_DEBUG_OFF (nht
, NHT
);
742 vty_out (vty
, "BGP nexthop tracking debugging is off%s", VTY_NEWLINE
);
747 /* debug bgp keepalives */
748 DEFUN (debug_bgp_keepalive
,
749 debug_bgp_keepalive_cmd
,
750 "debug bgp keepalives",
755 bgp_debug_list_free(bgp_debug_keepalive_peers
);
757 if (vty
->node
== CONFIG_NODE
)
758 DEBUG_ON (keepalive
, KEEPALIVE
);
761 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
762 vty_out (vty
, "BGP keepalives debugging is on%s", VTY_NEWLINE
);
767 DEFUN (debug_bgp_keepalive_peer
,
768 debug_bgp_keepalive_peer_cmd
,
769 "debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
772 "BGP Neighbor Events\n"
773 "BGP neighbor IP address to debug\n"
774 "BGP IPv6 neighbor to debug\n"
775 "BGP neighbor on interface to debug\n")
777 const char *host
= argv
[0];
779 if (!bgp_debug_keepalive_peers
)
780 bgp_debug_keepalive_peers
= list_new ();
782 if (bgp_debug_list_has_entry(bgp_debug_keepalive_peers
, host
, NULL
))
784 vty_out (vty
, "BGP keepalive debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
788 bgp_debug_list_add_entry(bgp_debug_keepalive_peers
, host
, NULL
);
790 if (vty
->node
== CONFIG_NODE
)
791 DEBUG_ON (keepalive
, KEEPALIVE
);
794 TERM_DEBUG_ON (keepalive
, KEEPALIVE
);
795 vty_out (vty
, "BGP keepalives debugging is on for %s%s", host
, VTY_NEWLINE
);
800 DEFUN (no_debug_bgp_keepalive
,
801 no_debug_bgp_keepalive_cmd
,
802 "no debug bgp keepalives",
808 bgp_debug_list_free(bgp_debug_keepalive_peers
);
810 if (vty
->node
== CONFIG_NODE
)
811 DEBUG_OFF (keepalive
, KEEPALIVE
);
814 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
815 vty_out (vty
, "BGP keepalives debugging is off%s", VTY_NEWLINE
);
820 DEFUN (no_debug_bgp_keepalive_peer
,
821 no_debug_bgp_keepalive_peer_cmd
,
822 "no debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
827 "BGP neighbor IP address to debug\n"
828 "BGP IPv6 neighbor to debug\n"
829 "BGP neighbor on interface to debug\n")
832 const char *host
= argv
[0];
834 if (bgp_debug_keepalive_peers
&& !list_isempty(bgp_debug_keepalive_peers
))
836 found_peer
= bgp_debug_list_remove_entry(bgp_debug_keepalive_peers
, host
, NULL
);
838 if (list_isempty(bgp_debug_keepalive_peers
))
840 if (vty
->node
== CONFIG_NODE
)
841 DEBUG_OFF (keepalive
, KEEPALIVE
);
843 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
848 vty_out (vty
, "BGP keepalives debugging is off for %s%s", host
, VTY_NEWLINE
);
850 vty_out (vty
, "BGP keepalives debugging was not enabled for %s%s", host
, VTY_NEWLINE
);
855 /* debug bgp bestpath */
856 DEFUN (debug_bgp_bestpath_prefix
,
857 debug_bgp_bestpath_prefix_cmd
,
858 "debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)",
862 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
863 "IPv6 prefix <network>/<length>\n")
866 struct prefix
*argv_p
;
869 argv_p
= prefix_new();
870 ret
= str2prefix (argv
[0], argv_p
);
874 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
879 if (!bgp_debug_bestpath_prefixes
)
880 bgp_debug_bestpath_prefixes
= list_new ();
882 if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
))
884 vty_out (vty
, "BGP bestptah debugging is already enabled for %s%s", argv
[0], VTY_NEWLINE
);
888 bgp_debug_list_add_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
890 if (vty
->node
== CONFIG_NODE
)
892 DEBUG_ON (bestpath
, BESTPATH
);
896 TERM_DEBUG_ON (bestpath
, BESTPATH
);
897 vty_out (vty
, "BGP bestpath debugging is on for %s%s", argv
[0], VTY_NEWLINE
);
903 DEFUN (no_debug_bgp_bestpath_prefix
,
904 no_debug_bgp_bestpath_prefix_cmd
,
905 "no debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)",
910 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
911 "IPv6 prefix <network>/<length>\n")
914 struct prefix
*argv_p
;
915 int found_prefix
= 0;
918 argv_p
= prefix_new();
919 ret
= str2prefix (argv
[0], argv_p
);
923 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
927 if (bgp_debug_bestpath_prefixes
&& !list_isempty(bgp_debug_bestpath_prefixes
))
929 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_bestpath_prefixes
, NULL
, argv_p
);
931 if (list_isempty(bgp_debug_bestpath_prefixes
))
933 if (vty
->node
== CONFIG_NODE
)
935 DEBUG_OFF (bestpath
, BESTPATH
);
939 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
940 vty_out (vty
, "BGP bestpath debugging (per prefix) is off%s", VTY_NEWLINE
);
946 vty_out (vty
, "BGP bestpath debugging is off for %s%s", argv
[0], VTY_NEWLINE
);
948 vty_out (vty
, "BGP bestpath debugging was not enabled for %s%s", argv
[0], VTY_NEWLINE
);
953 DEFUN (no_debug_bgp_bestpath
,
954 no_debug_bgp_bestpath_cmd
,
955 "no debug bgp bestpath",
961 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
963 if (vty
->node
== CONFIG_NODE
)
964 DEBUG_OFF (bestpath
, BESTPATH
);
967 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
968 vty_out (vty
, "BGP bestpath debugging is off%s", VTY_NEWLINE
);
973 /* debug bgp updates */
974 DEFUN (debug_bgp_update
,
975 debug_bgp_update_cmd
,
981 bgp_debug_list_free(bgp_debug_update_in_peers
);
982 bgp_debug_list_free(bgp_debug_update_out_peers
);
983 bgp_debug_list_free(bgp_debug_update_prefixes
);
985 if (vty
->node
== CONFIG_NODE
)
987 DEBUG_ON (update
, UPDATE_IN
);
988 DEBUG_ON (update
, UPDATE_OUT
);
992 TERM_DEBUG_ON (update
, UPDATE_IN
);
993 TERM_DEBUG_ON (update
, UPDATE_OUT
);
994 vty_out (vty
, "BGP updates debugging is on%s", VTY_NEWLINE
);
999 DEFUN (debug_bgp_update_direct
,
1000 debug_bgp_update_direct_cmd
,
1001 "debug bgp updates (in|out)",
1006 "Outbound updates\n")
1009 if (strncmp ("i", argv
[0], 1) == 0)
1010 bgp_debug_list_free(bgp_debug_update_in_peers
);
1012 bgp_debug_list_free(bgp_debug_update_out_peers
);
1014 if (vty
->node
== CONFIG_NODE
)
1016 if (strncmp ("i", argv
[0], 1) == 0)
1017 DEBUG_ON (update
, UPDATE_IN
);
1019 DEBUG_ON (update
, UPDATE_OUT
);
1023 if (strncmp ("i", argv
[0], 1) == 0)
1025 TERM_DEBUG_ON (update
, UPDATE_IN
);
1026 vty_out (vty
, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE
);
1030 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1031 vty_out (vty
, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE
);
1037 DEFUN (debug_bgp_update_direct_peer
,
1038 debug_bgp_update_direct_peer_cmd
,
1039 "debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
1044 "Outbound updates\n"
1045 "BGP neighbor IP address to debug\n"
1046 "BGP IPv6 neighbor to debug\n"
1047 "BGP neighbor on interface to debug\n")
1049 const char *host
= argv
[1];
1052 if (!bgp_debug_update_in_peers
)
1053 bgp_debug_update_in_peers
= list_new ();
1055 if (!bgp_debug_update_out_peers
)
1056 bgp_debug_update_out_peers
= list_new ();
1058 if (strncmp ("i", argv
[0], 1) == 0)
1065 if (bgp_debug_list_has_entry(bgp_debug_update_in_peers
, host
, NULL
))
1067 vty_out (vty
, "BGP inbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1074 if (bgp_debug_list_has_entry(bgp_debug_update_out_peers
, host
, NULL
))
1076 vty_out (vty
, "BGP outbound update debugging is already enabled for %s%s", host
, VTY_NEWLINE
);
1082 bgp_debug_list_add_entry(bgp_debug_update_in_peers
, host
, NULL
);
1086 struct peer_af
*paf
;
1089 bgp_debug_list_add_entry(bgp_debug_update_out_peers
, host
, NULL
);
1090 peer
= bgp_find_peer (vty
, host
);
1094 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1096 paf
= peer
->peer_af_array
[afidx
];
1099 if (PAF_SUBGRP (paf
))
1101 UPDGRP_PEER_DBG_EN(PAF_SUBGRP(paf
)->update_group
);
1108 if (vty
->node
== CONFIG_NODE
)
1111 DEBUG_ON (update
, UPDATE_IN
);
1113 DEBUG_ON (update
, UPDATE_OUT
);
1119 TERM_DEBUG_ON (update
, UPDATE_IN
);
1120 vty_out (vty
, "BGP updates debugging is on (inbound) for %s%s", argv
[1], VTY_NEWLINE
);
1124 TERM_DEBUG_ON (update
, UPDATE_OUT
);
1125 vty_out (vty
, "BGP updates debugging is on (outbound) for %s%s", argv
[1], VTY_NEWLINE
);
1131 DEFUN (no_debug_bgp_update_direct
,
1132 no_debug_bgp_update_direct_cmd
,
1133 "no debug bgp updates (in|out)",
1139 "Outbound updates\n")
1141 if (strncmp ("i", argv
[0], 1) == 0)
1143 bgp_debug_list_free(bgp_debug_update_in_peers
);
1145 if (vty
->node
== CONFIG_NODE
)
1147 DEBUG_OFF (update
, UPDATE_IN
);
1151 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1152 vty_out (vty
, "BGP updates debugging is off (inbound)%s", VTY_NEWLINE
);
1157 bgp_debug_list_free(bgp_debug_update_out_peers
);
1159 if (vty
->node
== CONFIG_NODE
)
1161 DEBUG_OFF (update
, UPDATE_OUT
);
1165 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1166 vty_out (vty
, "BGP updates debugging is off (outbound)%s", VTY_NEWLINE
);
1173 DEFUN (no_debug_bgp_update_direct_peer
,
1174 no_debug_bgp_update_direct_peer_cmd
,
1175 "no debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
1181 "Outbound updates\n"
1182 "BGP neighbor IP address to debug\n"
1183 "BGP IPv6 neighbor to debug\n"
1184 "BGP neighbor on interface to debug\n")
1188 const char *host
= argv
[1];
1190 if (strncmp ("i", argv
[0], 1) == 0)
1195 if (inbound
&& bgp_debug_update_in_peers
&&
1196 !list_isempty(bgp_debug_update_in_peers
))
1198 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_in_peers
, host
, NULL
);
1200 if (list_isempty(bgp_debug_update_in_peers
))
1202 if (vty
->node
== CONFIG_NODE
)
1203 DEBUG_OFF (update
, UPDATE_IN
);
1206 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1207 vty_out (vty
, "BGP updates debugging (inbound) is off%s", VTY_NEWLINE
);
1212 if (!inbound
&& bgp_debug_update_out_peers
&&
1213 !list_isempty(bgp_debug_update_out_peers
))
1215 found_peer
= bgp_debug_list_remove_entry(bgp_debug_update_out_peers
, host
, NULL
);
1217 if (list_isempty(bgp_debug_update_out_peers
))
1219 if (vty
->node
== CONFIG_NODE
)
1220 DEBUG_OFF (update
, UPDATE_OUT
);
1223 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1224 vty_out (vty
, "BGP updates debugging (outbound) is off%s", VTY_NEWLINE
);
1229 struct peer_af
*paf
;
1231 peer
= bgp_find_peer (vty
, host
);
1235 for (afidx
= BGP_AF_START
; afidx
< BGP_AF_MAX
; afidx
++)
1237 paf
= peer
->peer_af_array
[afidx
];
1240 if (PAF_SUBGRP (paf
))
1242 UPDGRP_PEER_DBG_DIS(PAF_SUBGRP(paf
)->update_group
);
1251 vty_out (vty
, "BGP updates debugging (inbound) is off for %s%s", host
, VTY_NEWLINE
);
1253 vty_out (vty
, "BGP updates debugging (outbound) is off for %s%s", host
, VTY_NEWLINE
);
1256 vty_out (vty
, "BGP updates debugging (inbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1258 vty_out (vty
, "BGP updates debugging (outbound) was not enabled for %s%s", host
, VTY_NEWLINE
);
1263 DEFUN (debug_bgp_update_prefix
,
1264 debug_bgp_update_prefix_cmd
,
1265 "debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
1269 "Specify a prefix to debug\n"
1270 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1271 "IPv6 prefix <network>/<length>\n")
1274 struct prefix
*argv_p
;
1277 argv_p
= prefix_new();
1278 ret
= str2prefix (argv
[0], argv_p
);
1281 prefix_free(argv_p
);
1282 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1287 if (!bgp_debug_update_prefixes
)
1288 bgp_debug_update_prefixes
= list_new ();
1290 if (bgp_debug_list_has_entry(bgp_debug_update_prefixes
, NULL
, argv_p
))
1292 vty_out (vty
, "BGP updates debugging is already enabled for %s%s", argv
[0], VTY_NEWLINE
);
1296 bgp_debug_list_add_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1298 if (vty
->node
== CONFIG_NODE
)
1300 DEBUG_ON (update
, UPDATE_PREFIX
);
1304 TERM_DEBUG_ON (update
, UPDATE_PREFIX
);
1305 vty_out (vty
, "BGP updates debugging is on for %s%s", argv
[0], VTY_NEWLINE
);
1311 DEFUN (no_debug_bgp_update_prefix
,
1312 no_debug_bgp_update_prefix_cmd
,
1313 "no debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
1318 "Specify a prefix to debug\n"
1319 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1320 "IPv6 prefix <network>/<length>\n")
1323 struct prefix
*argv_p
;
1324 int found_prefix
= 0;
1327 argv_p
= prefix_new();
1328 ret
= str2prefix (argv
[0], argv_p
);
1331 prefix_free(argv_p
);
1332 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1336 if (bgp_debug_update_prefixes
&& !list_isempty(bgp_debug_update_prefixes
))
1338 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_update_prefixes
, NULL
, argv_p
);
1340 if (list_isempty(bgp_debug_update_prefixes
))
1342 if (vty
->node
== CONFIG_NODE
)
1344 DEBUG_OFF (update
, UPDATE_PREFIX
);
1348 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1349 vty_out (vty
, "BGP updates debugging (per prefix) is off%s", VTY_NEWLINE
);
1355 vty_out (vty
, "BGP updates debugging is off for %s%s", argv
[0], VTY_NEWLINE
);
1357 vty_out (vty
, "BGP updates debugging was not enabled for %s%s", argv
[0], VTY_NEWLINE
);
1362 DEFUN (no_debug_bgp_update
,
1363 no_debug_bgp_update_cmd
,
1364 "no debug bgp updates",
1370 bgp_debug_list_free(bgp_debug_update_in_peers
);
1371 bgp_debug_list_free(bgp_debug_update_out_peers
);
1372 bgp_debug_list_free(bgp_debug_update_prefixes
);
1374 bgp_debug_clear_updgrp_update_dbg(vty
->index
);
1376 if (vty
->node
== CONFIG_NODE
)
1378 DEBUG_OFF (update
, UPDATE_IN
);
1379 DEBUG_OFF (update
, UPDATE_OUT
);
1380 DEBUG_OFF (update
, UPDATE_PREFIX
);
1384 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1385 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1386 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1387 vty_out (vty
, "BGP updates debugging is off%s", VTY_NEWLINE
);
1392 /* debug bgp zebra */
1393 DEFUN (debug_bgp_zebra
,
1394 debug_bgp_zebra_cmd
,
1398 "BGP Zebra messages\n")
1400 if (vty
->node
== CONFIG_NODE
)
1401 DEBUG_ON (zebra
, ZEBRA
);
1404 TERM_DEBUG_ON (zebra
, ZEBRA
);
1405 vty_out (vty
, "BGP zebra debugging is on%s", VTY_NEWLINE
);
1410 DEFUN (debug_bgp_zebra_prefix
,
1411 debug_bgp_zebra_prefix_cmd
,
1412 "debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
1415 "BGP Zebra messages\n"
1416 "Specify a prefix to debug\n"
1417 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1418 "IPv6 prefix <network>/<length>\n")
1421 struct prefix
*argv_p
;
1424 argv_p
= prefix_new();
1425 ret
= str2prefix (argv
[0], argv_p
);
1428 prefix_free(argv_p
);
1429 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1433 if (!bgp_debug_zebra_prefixes
)
1434 bgp_debug_zebra_prefixes
= list_new();
1436 if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
))
1438 vty_out (vty
, "BGP zebra debugging is already enabled for %s%s", argv
[0], VTY_NEWLINE
);
1442 bgp_debug_list_add_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1444 if (vty
->node
== CONFIG_NODE
)
1445 DEBUG_ON (zebra
, ZEBRA
);
1448 TERM_DEBUG_ON (zebra
, ZEBRA
);
1449 vty_out (vty
, "BGP zebra debugging is on for %s%s", argv
[0], VTY_NEWLINE
);
1455 DEFUN (no_debug_bgp_zebra
,
1456 no_debug_bgp_zebra_cmd
,
1457 "no debug bgp zebra",
1461 "BGP Zebra messages\n")
1463 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1465 if (vty
->node
== CONFIG_NODE
)
1466 DEBUG_OFF (zebra
, ZEBRA
);
1469 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1470 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1475 DEFUN (no_debug_bgp_zebra_prefix
,
1476 no_debug_bgp_zebra_prefix_cmd
,
1477 "no debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
1481 "BGP Zebra messages\n"
1482 "Specify a prefix to debug\n"
1483 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1484 "IPv6 prefix <network>/<length>\n")
1487 struct prefix
*argv_p
;
1488 int found_prefix
= 0;
1491 argv_p
= prefix_new();
1492 ret
= str2prefix (argv
[0], argv_p
);
1495 prefix_free(argv_p
);
1496 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
1500 if (bgp_debug_zebra_prefixes
&& !list_isempty(bgp_debug_zebra_prefixes
))
1502 found_prefix
= bgp_debug_list_remove_entry(bgp_debug_zebra_prefixes
, NULL
, argv_p
);
1504 if (list_isempty(bgp_debug_zebra_prefixes
))
1506 if (vty
->node
== CONFIG_NODE
)
1507 DEBUG_OFF (zebra
, ZEBRA
);
1510 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1511 vty_out (vty
, "BGP zebra debugging is off%s", VTY_NEWLINE
);
1517 vty_out (vty
, "BGP zebra debugging is off for %s%s", argv
[0], VTY_NEWLINE
);
1519 vty_out (vty
, "BGP zebra debugging was not enabled for %s%s", argv
[0], VTY_NEWLINE
);
1524 DEFUN (debug_bgp_allow_martians
,
1525 debug_bgp_allow_martians_cmd
,
1526 "debug bgp allow-martians",
1529 "BGP allow martian next hops\n")
1531 if (vty
->node
== CONFIG_NODE
)
1532 DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1535 TERM_DEBUG_ON (allow_martians
, ALLOW_MARTIANS
);
1536 vty_out (vty
, "BGP allow_martian next hop debugging is on%s", VTY_NEWLINE
);
1541 DEFUN (no_debug_bgp_allow_martians
,
1542 no_debug_bgp_allow_martians_cmd
,
1543 "no debug bgp allow-martians",
1547 "BGP allow martian next hops\n")
1549 if (vty
->node
== CONFIG_NODE
)
1550 DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1553 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1554 vty_out (vty
, "BGP allow martian next hop debugging is off%s", VTY_NEWLINE
);
1559 ALIAS (no_debug_bgp_allow_martians
,
1560 undebug_bgp_allow_martians_cmd
,
1561 "undebug bgp allow-martians",
1564 "BGP allow martian next hops\n")
1566 /* debug bgp update-groups */
1567 DEFUN (debug_bgp_update_groups
,
1568 debug_bgp_update_groups_cmd
,
1569 "debug bgp update-groups",
1572 "BGP update-groups\n")
1574 if (vty
->node
== CONFIG_NODE
)
1575 DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1578 TERM_DEBUG_ON (update_groups
, UPDATE_GROUPS
);
1579 vty_out (vty
, "BGP update-groups debugging is on%s", VTY_NEWLINE
);
1584 DEFUN (no_debug_bgp_update_groups
,
1585 no_debug_bgp_update_groups_cmd
,
1586 "no debug bgp update-groups",
1590 "BGP update-groups\n")
1592 if (vty
->node
== CONFIG_NODE
)
1593 DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1596 TERM_DEBUG_OFF (update_groups
, UPDATE_GROUPS
);
1597 vty_out (vty
, "BGP update-groups debugging is off%s", VTY_NEWLINE
);
1602 DEFUN (no_debug_bgp
,
1609 bgp_debug_list_free(bgp_debug_neighbor_events_peers
);
1610 bgp_debug_list_free(bgp_debug_keepalive_peers
);
1611 bgp_debug_list_free(bgp_debug_update_in_peers
);
1612 bgp_debug_list_free(bgp_debug_update_out_peers
);
1613 bgp_debug_list_free(bgp_debug_update_prefixes
);
1614 bgp_debug_list_free(bgp_debug_bestpath_prefixes
);
1615 bgp_debug_list_free(bgp_debug_zebra_prefixes
);
1617 bgp_debug_clear_updgrp_update_dbg(vty
->index
);
1619 TERM_DEBUG_OFF (keepalive
, KEEPALIVE
);
1620 TERM_DEBUG_OFF (update
, UPDATE_IN
);
1621 TERM_DEBUG_OFF (update
, UPDATE_OUT
);
1622 TERM_DEBUG_OFF (update
, UPDATE_PREFIX
);
1623 TERM_DEBUG_OFF (bestpath
, BESTPATH
);
1624 TERM_DEBUG_OFF (as4
, AS4
);
1625 TERM_DEBUG_OFF (as4
, AS4_SEGMENT
);
1626 TERM_DEBUG_OFF (neighbor_events
, NEIGHBOR_EVENTS
);
1627 TERM_DEBUG_OFF (zebra
, ZEBRA
);
1628 TERM_DEBUG_OFF (allow_martians
, ALLOW_MARTIANS
);
1629 vty_out (vty
, "All possible debugging has been turned off%s", VTY_NEWLINE
);
1634 DEFUN (show_debugging_bgp
,
1635 show_debugging_bgp_cmd
,
1636 "show debugging bgp",
1641 vty_out (vty
, "BGP debugging status:%s", VTY_NEWLINE
);
1643 if (BGP_DEBUG (as4
, AS4
))
1644 vty_out (vty
, " BGP as4 debugging is on%s", VTY_NEWLINE
);
1646 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1647 vty_out (vty
, " BGP as4 aspath segment debugging is on%s", VTY_NEWLINE
);
1649 if (BGP_DEBUG (bestpath
, BESTPATH
))
1650 bgp_debug_list_print (vty
, " BGP bestpath debugging is on",
1651 bgp_debug_bestpath_prefixes
);
1653 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1654 bgp_debug_list_print (vty
, " BGP keepalives debugging is on",
1655 bgp_debug_keepalive_peers
);
1657 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1658 bgp_debug_list_print (vty
, " BGP neighbor-events debugging is on",
1659 bgp_debug_neighbor_events_peers
);
1661 if (BGP_DEBUG (nht
, NHT
))
1662 vty_out (vty
, " BGP next-hop tracking debugging is on%s", VTY_NEWLINE
);
1664 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1665 vty_out (vty
, " BGP update-groups debugging is on%s", VTY_NEWLINE
);
1667 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1668 bgp_debug_list_print (vty
, " BGP updates debugging is on",
1669 bgp_debug_update_prefixes
);
1671 if (BGP_DEBUG (update
, UPDATE_IN
))
1672 bgp_debug_list_print (vty
, " BGP updates debugging is on (inbound)",
1673 bgp_debug_update_in_peers
);
1675 if (BGP_DEBUG (update
, UPDATE_OUT
))
1676 bgp_debug_list_print (vty
, " BGP updates debugging is on (outbound)",
1677 bgp_debug_update_out_peers
);
1679 if (BGP_DEBUG (zebra
, ZEBRA
))
1680 bgp_debug_list_print (vty
, " BGP zebra debugging is on",
1681 bgp_debug_zebra_prefixes
);
1683 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1684 vty_out (vty
, " BGP allow martian next hop debugging is on%s", VTY_NEWLINE
);
1685 vty_out (vty
, "%s", VTY_NEWLINE
);
1689 /* return count of number of debug flags set */
1691 bgp_debug_count(void)
1694 if (BGP_DEBUG (as4
, AS4
))
1697 if (BGP_DEBUG (as4
, AS4_SEGMENT
))
1700 if (BGP_DEBUG (bestpath
, BESTPATH
))
1703 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1706 if (BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1709 if (BGP_DEBUG (nht
, NHT
))
1712 if (BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1715 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
1718 if (BGP_DEBUG (update
, UPDATE_IN
))
1721 if (BGP_DEBUG (update
, UPDATE_OUT
))
1724 if (BGP_DEBUG (zebra
, ZEBRA
))
1727 if (BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1734 bgp_config_write_debug (struct vty
*vty
)
1738 if (CONF_BGP_DEBUG (as4
, AS4
))
1740 vty_out (vty
, "debug bgp as4%s", VTY_NEWLINE
);
1744 if (CONF_BGP_DEBUG (as4
, AS4_SEGMENT
))
1746 vty_out (vty
, "debug bgp as4 segment%s", VTY_NEWLINE
);
1750 if (CONF_BGP_DEBUG (bestpath
, BESTPATH
))
1752 write
+= bgp_debug_list_conf_print (vty
, "debug bgp bestpath",
1753 bgp_debug_bestpath_prefixes
);
1756 if (CONF_BGP_DEBUG (keepalive
, KEEPALIVE
))
1758 write
+= bgp_debug_list_conf_print (vty
, "debug bgp keepalives",
1759 bgp_debug_keepalive_peers
);
1762 if (CONF_BGP_DEBUG (neighbor_events
, NEIGHBOR_EVENTS
))
1764 write
+= bgp_debug_list_conf_print (vty
, "debug bgp neighbor-events",
1765 bgp_debug_neighbor_events_peers
);
1768 if (CONF_BGP_DEBUG (nht
, NHT
))
1770 vty_out (vty
, "debug bgp nht%s", VTY_NEWLINE
);
1774 if (CONF_BGP_DEBUG (update_groups
, UPDATE_GROUPS
))
1776 vty_out (vty
, "debug bgp update-groups%s", VTY_NEWLINE
);
1780 if (CONF_BGP_DEBUG (update
, UPDATE_PREFIX
))
1782 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates prefix",
1783 bgp_debug_update_prefixes
);
1786 if (CONF_BGP_DEBUG (update
, UPDATE_IN
))
1788 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates in",
1789 bgp_debug_update_in_peers
);
1792 if (CONF_BGP_DEBUG (update
, UPDATE_OUT
))
1794 write
+= bgp_debug_list_conf_print (vty
, "debug bgp updates out",
1795 bgp_debug_update_out_peers
);
1798 if (CONF_BGP_DEBUG (zebra
, ZEBRA
))
1800 if (!bgp_debug_zebra_prefixes
|| list_isempty(bgp_debug_zebra_prefixes
))
1802 vty_out (vty
, "debug bgp zebra%s", VTY_NEWLINE
);
1807 write
+= bgp_debug_list_conf_print (vty
, "debug bgp zebra prefix",
1808 bgp_debug_zebra_prefixes
);
1812 if (CONF_BGP_DEBUG (allow_martians
, ALLOW_MARTIANS
))
1814 vty_out (vty
, "debug bgp allow-martians%s", VTY_NEWLINE
);
1821 static struct cmd_node debug_node
=
1829 bgp_debug_init (void)
1831 install_node (&debug_node
, bgp_config_write_debug
);
1833 install_element (ENABLE_NODE
, &show_debugging_bgp_cmd
);
1835 install_element (ENABLE_NODE
, &debug_bgp_as4_cmd
);
1836 install_element (CONFIG_NODE
, &debug_bgp_as4_cmd
);
1837 install_element (ENABLE_NODE
, &debug_bgp_as4_segment_cmd
);
1838 install_element (CONFIG_NODE
, &debug_bgp_as4_segment_cmd
);
1840 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_cmd
);
1841 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_cmd
);
1842 install_element (ENABLE_NODE
, &debug_bgp_nht_cmd
);
1843 install_element (CONFIG_NODE
, &debug_bgp_nht_cmd
);
1844 install_element (ENABLE_NODE
, &debug_bgp_keepalive_cmd
);
1845 install_element (CONFIG_NODE
, &debug_bgp_keepalive_cmd
);
1846 install_element (ENABLE_NODE
, &debug_bgp_update_cmd
);
1847 install_element (CONFIG_NODE
, &debug_bgp_update_cmd
);
1848 install_element (ENABLE_NODE
, &debug_bgp_zebra_cmd
);
1849 install_element (CONFIG_NODE
, &debug_bgp_zebra_cmd
);
1850 install_element (ENABLE_NODE
, &debug_bgp_allow_martians_cmd
);
1851 install_element (CONFIG_NODE
, &debug_bgp_allow_martians_cmd
);
1852 install_element (ENABLE_NODE
, &debug_bgp_update_groups_cmd
);
1853 install_element (CONFIG_NODE
, &debug_bgp_update_groups_cmd
);
1854 install_element (ENABLE_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1855 install_element (CONFIG_NODE
, &debug_bgp_bestpath_prefix_cmd
);
1857 /* debug bgp updates (in|out) */
1858 install_element (ENABLE_NODE
, &debug_bgp_update_direct_cmd
);
1859 install_element (CONFIG_NODE
, &debug_bgp_update_direct_cmd
);
1860 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_cmd
);
1861 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_cmd
);
1863 /* debug bgp updates (in|out) A.B.C.D */
1864 install_element (ENABLE_NODE
, &debug_bgp_update_direct_peer_cmd
);
1865 install_element (CONFIG_NODE
, &debug_bgp_update_direct_peer_cmd
);
1866 install_element (ENABLE_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1867 install_element (CONFIG_NODE
, &no_debug_bgp_update_direct_peer_cmd
);
1869 /* debug bgp updates prefix A.B.C.D/M */
1870 install_element (ENABLE_NODE
, &debug_bgp_update_prefix_cmd
);
1871 install_element (CONFIG_NODE
, &debug_bgp_update_prefix_cmd
);
1872 install_element (ENABLE_NODE
, &no_debug_bgp_update_prefix_cmd
);
1873 install_element (CONFIG_NODE
, &no_debug_bgp_update_prefix_cmd
);
1875 /* debug bgp zebra prefix A.B.C.D/M */
1876 install_element (ENABLE_NODE
, &debug_bgp_zebra_prefix_cmd
);
1877 install_element (CONFIG_NODE
, &debug_bgp_zebra_prefix_cmd
);
1878 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1879 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_prefix_cmd
);
1881 install_element (ENABLE_NODE
, &no_debug_bgp_as4_cmd
);
1882 install_element (CONFIG_NODE
, &no_debug_bgp_as4_cmd
);
1883 install_element (ENABLE_NODE
, &no_debug_bgp_as4_segment_cmd
);
1884 install_element (CONFIG_NODE
, &no_debug_bgp_as4_segment_cmd
);
1886 /* debug bgp neighbor-events A.B.C.D */
1887 install_element (ENABLE_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1888 install_element (CONFIG_NODE
, &debug_bgp_neighbor_events_peer_cmd
);
1889 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1890 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_peer_cmd
);
1892 /* debug bgp keepalive A.B.C.D */
1893 install_element (ENABLE_NODE
, &debug_bgp_keepalive_peer_cmd
);
1894 install_element (CONFIG_NODE
, &debug_bgp_keepalive_peer_cmd
);
1895 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1896 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_peer_cmd
);
1898 install_element (ENABLE_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1899 install_element (CONFIG_NODE
, &no_debug_bgp_neighbor_events_cmd
);
1900 install_element (ENABLE_NODE
, &no_debug_bgp_nht_cmd
);
1901 install_element (CONFIG_NODE
, &no_debug_bgp_nht_cmd
);
1902 install_element (ENABLE_NODE
, &no_debug_bgp_keepalive_cmd
);
1903 install_element (CONFIG_NODE
, &no_debug_bgp_keepalive_cmd
);
1904 install_element (ENABLE_NODE
, &no_debug_bgp_update_cmd
);
1905 install_element (CONFIG_NODE
, &no_debug_bgp_update_cmd
);
1906 install_element (ENABLE_NODE
, &no_debug_bgp_zebra_cmd
);
1907 install_element (CONFIG_NODE
, &no_debug_bgp_zebra_cmd
);
1908 install_element (ENABLE_NODE
, &no_debug_bgp_allow_martians_cmd
);
1909 install_element (ENABLE_NODE
, &undebug_bgp_allow_martians_cmd
);
1910 install_element (CONFIG_NODE
, &no_debug_bgp_allow_martians_cmd
);
1911 install_element (ENABLE_NODE
, &no_debug_bgp_update_groups_cmd
);
1912 install_element (CONFIG_NODE
, &no_debug_bgp_update_groups_cmd
);
1913 install_element (ENABLE_NODE
, &no_debug_bgp_cmd
);
1914 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_cmd
);
1915 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_cmd
);
1916 install_element (ENABLE_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1917 install_element (CONFIG_NODE
, &no_debug_bgp_bestpath_prefix_cmd
);
1920 /* Return true if this prefix is on the per_prefix_list of prefixes to debug
1921 * for BGP_DEBUG_TYPE
1924 bgp_debug_per_prefix (struct prefix
*p
, unsigned long term_bgp_debug_type
,
1925 unsigned int BGP_DEBUG_TYPE
, struct list
*per_prefix_list
)
1927 struct bgp_debug_filter
*filter
;
1928 struct listnode
*node
, *nnode
;
1930 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1932 /* We are debugging all prefixes so return true */
1933 if (!per_prefix_list
|| list_isempty(per_prefix_list
))
1941 for (ALL_LIST_ELEMENTS (per_prefix_list
, node
, nnode
, filter
))
1942 if (filter
->p
->prefixlen
== p
->prefixlen
&& prefix_match(filter
->p
, p
))
1952 /* Return true if this peer is on the per_peer_list of peers to debug
1953 * for BGP_DEBUG_TYPE
1956 bgp_debug_per_peer(char *host
, unsigned long term_bgp_debug_type
,
1957 unsigned int BGP_DEBUG_TYPE
, struct list
*per_peer_list
)
1959 struct bgp_debug_filter
*filter
;
1960 struct listnode
*node
, *nnode
;
1962 if (term_bgp_debug_type
& BGP_DEBUG_TYPE
)
1964 /* We are debugging all peers so return true */
1965 if (!per_peer_list
|| list_isempty(per_peer_list
))
1973 for (ALL_LIST_ELEMENTS (per_peer_list
, node
, nnode
, filter
))
1974 if (strcmp (filter
->host
, host
) == 0)
1985 bgp_debug_neighbor_events (struct peer
*peer
)
1992 return bgp_debug_per_peer (host
,
1993 term_bgp_debug_neighbor_events
,
1994 BGP_DEBUG_NEIGHBOR_EVENTS
,
1995 bgp_debug_neighbor_events_peers
);
1999 bgp_debug_keepalive (struct peer
*peer
)
2006 return bgp_debug_per_peer (host
,
2007 term_bgp_debug_keepalive
,
2008 BGP_DEBUG_KEEPALIVE
,
2009 bgp_debug_keepalive_peers
);
2013 bgp_debug_update (struct peer
*peer
, struct prefix
*p
,
2014 struct update_group
*updgrp
, unsigned int inbound
)
2023 if (bgp_debug_per_peer (host
, term_bgp_debug_update
, BGP_DEBUG_UPDATE_IN
,
2024 bgp_debug_update_in_peers
))
2031 if (bgp_debug_per_peer (host
, term_bgp_debug_update
,
2032 BGP_DEBUG_UPDATE_OUT
,
2033 bgp_debug_update_out_peers
))
2036 /* Check if update debugging implicitly enabled for the group. */
2037 if (updgrp
&& UPDGRP_DBG_ON(updgrp
))
2042 if (BGP_DEBUG (update
, UPDATE_PREFIX
))
2044 if (bgp_debug_per_prefix (p
, term_bgp_debug_update
,
2045 BGP_DEBUG_UPDATE_PREFIX
,
2046 bgp_debug_update_prefixes
))
2054 bgp_debug_bestpath (struct prefix
*p
)
2056 if (BGP_DEBUG (bestpath
, BESTPATH
))
2058 if (bgp_debug_per_prefix (p
, term_bgp_debug_bestpath
,
2060 bgp_debug_bestpath_prefixes
))
2068 bgp_debug_zebra (struct prefix
*p
)
2070 if (BGP_DEBUG (zebra
, ZEBRA
))
2072 if (bgp_debug_per_prefix (p
, term_bgp_debug_zebra
, BGP_DEBUG_ZEBRA
,
2073 bgp_debug_zebra_prefixes
))