Skip to content

Commit ed5f89e

Browse files
authored
Merge pull request FRRouting#19843 from Pdoijode/pdoijode/nbr-debug-detail
Add debug bgp neighbor-events detail command
2 parents c6951b7 + 9a2aca8 commit ed5f89e

File tree

4 files changed

+58
-16
lines changed

4 files changed

+58
-16
lines changed

bgpd/bgp_debug.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,31 @@ DEFUN (debug_bgp_neighbor_events,
820820
return CMD_SUCCESS;
821821
}
822822

823+
DEFPY(debug_bgp_neighbor_events_detail,
824+
debug_bgp_neighbor_events_detail_cmd,
825+
"[no] debug bgp neighbor-events detail",
826+
NO_STR
827+
DEBUG_STR
828+
BGP_STR
829+
"BGP Neighbor Events\n"
830+
"Show detailed information about neighbor events\n")
831+
{
832+
if (vty->node == CONFIG_NODE) {
833+
if (no)
834+
DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
835+
else
836+
DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
837+
} else {
838+
if (no)
839+
TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
840+
else
841+
TERM_DEBUG_ON(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
842+
vty_out(vty, "BGP neighbor-events detail debugging is %s\n", (no) ? "off" : "on");
843+
}
844+
845+
return CMD_SUCCESS;
846+
}
847+
823848
DEFUN (debug_bgp_neighbor_events_peer,
824849
debug_bgp_neighbor_events_peer_cmd,
825850
"debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
@@ -867,10 +892,12 @@ DEFUN (no_debug_bgp_neighbor_events,
867892
{
868893
bgp_debug_list_free(bgp_debug_neighbor_events_peers);
869894

870-
if (vty->node == CONFIG_NODE)
895+
if (vty->node == CONFIG_NODE) {
871896
DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS);
872-
else {
897+
DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
898+
} else {
873899
TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS);
900+
TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
874901
vty_out(vty, "BGP neighbor-events debugging is off\n");
875902
}
876903
return CMD_SUCCESS;
@@ -2287,6 +2314,7 @@ DEFUN (no_debug_bgp,
22872314
TERM_DEBUG_OFF(as4, AS4);
22882315
TERM_DEBUG_OFF(as4, AS4_SEGMENT);
22892316
TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS);
2317+
TERM_DEBUG_OFF(neighbor_events, NEIGHBOR_EVENTS_DETAIL);
22902318
TERM_DEBUG_OFF(zebra, ZEBRA);
22912319
TERM_DEBUG_OFF(nht, NHT);
22922320
TERM_DEBUG_OFF(vpn, VPN_LEAK_FROM_VRF);
@@ -2336,6 +2364,9 @@ DEFUN_NOSH (show_debugging_bgp,
23362364
" BGP neighbor-events debugging is on",
23372365
bgp_debug_neighbor_events_peers);
23382366

2367+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
2368+
vty_out(vty, " BGP neighbor-events detail debugging is on\n");
2369+
23392370
if (BGP_DEBUG(nht, NHT))
23402371
vty_out(vty, " BGP next-hop tracking debugging is on\n");
23412372

@@ -2436,6 +2467,11 @@ static int bgp_config_write_debug(struct vty *vty)
24362467
bgp_debug_neighbor_events_peers);
24372468
}
24382469

2470+
if (CONF_BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL)) {
2471+
vty_out(vty, "debug bgp neighbor-events detail\n");
2472+
write++;
2473+
}
2474+
24392475
if (CONF_BGP_DEBUG(nht, NHT)) {
24402476
vty_out(vty, "debug bgp nht\n");
24412477
write++;
@@ -2574,6 +2610,8 @@ void bgp_debug_init(void)
25742610

25752611
install_element(ENABLE_NODE, &debug_bgp_neighbor_events_cmd);
25762612
install_element(CONFIG_NODE, &debug_bgp_neighbor_events_cmd);
2613+
install_element(ENABLE_NODE, &debug_bgp_neighbor_events_detail_cmd);
2614+
install_element(CONFIG_NODE, &debug_bgp_neighbor_events_detail_cmd);
25772615
install_element(ENABLE_NODE, &debug_bgp_nht_cmd);
25782616
install_element(CONFIG_NODE, &debug_bgp_nht_cmd);
25792617
install_element(ENABLE_NODE, &debug_bgp_keepalive_cmd);

bgpd/bgp_debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct bgp_debug_filter {
114114

115115
#define BGP_DEBUG_BESTPATH 0x01
116116
#define BGP_DEBUG_NEIGHBOR_EVENTS 0x01
117+
#define BGP_DEBUG_NEIGHBOR_EVENTS_DETAIL 0x02
117118
#define BGP_DEBUG_PACKET 0x01
118119
#define BGP_DEBUG_KEEPALIVE 0x01
119120
#define BGP_DEBUG_UPDATE_IN 0x01

bgpd/bgp_route.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6754,7 +6754,7 @@ static void set_clearing_resume_info(struct bgp_clearing_info *cinfo,
67546754
const struct bgp_table *table,
67556755
const struct prefix *p, bool inner_p)
67566756
{
6757-
if (bgp_debug_neighbor_events(NULL))
6757+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
67586758
zlog_debug("%s: %sinfo for %s/%s %pFX", __func__,
67596759
inner_p ? "inner " : "", afi2str(table->afi),
67606760
safi2str(table->safi), p);
@@ -6812,7 +6812,7 @@ static struct bgp_dest *clearing_dest_helper(struct bgp_table *table,
68126812
/* Outer/RD table: use current RD if possible, advance
68136813
* otherwise
68146814
*/
6815-
if (bgp_debug_neighbor_events(NULL)) {
6815+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL)) {
68166816
prefix_rd2str((struct prefix_rd *)pfx, buf, sizeof(buf),
68176817
ASNOTATION_PLAIN);
68186818
zlog_debug("%s: using RESUME%s prefix %s", __func__,
@@ -6822,7 +6822,7 @@ static struct bgp_dest *clearing_dest_helper(struct bgp_table *table,
68226822
dest = bgp_node_match(table, pfx);
68236823
} else {
68246824
/* Normal prefix: look for next prefix */
6825-
if (bgp_debug_neighbor_events(NULL))
6825+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
68266826
zlog_debug("%s: using RESUME%s prefix %pFX", __func__,
68276827
inner_p ? " inner" : "", pfx);
68286828

@@ -6838,7 +6838,7 @@ static struct bgp_dest *clearing_dest_helper(struct bgp_table *table,
68386838
}
68396839
}
68406840

6841-
if (bgp_debug_neighbor_events(NULL)) {
6841+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL)) {
68426842
if (outer_level_p) {
68436843
if (dest)
68446844
prefix_rd2str((struct prefix_rd *)(&dest->rn->p), buf, sizeof(buf),
@@ -6896,7 +6896,7 @@ static int walk_batch_table_helper(struct bgp_clearing_info *cinfo,
68966896
UNSET_FLAG(cinfo->flags, (BGP_CLEARING_INFO_FLAG_RESUME |
68976897
BGP_CLEARING_INFO_FLAG_INNER));
68986898

6899-
if (bgp_debug_neighbor_events(NULL))
6899+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
69006900
zlog_debug("%s: table %s/%s, dest %pBD", __func__, afi2str(table->afi),
69016901
safi2str(table->safi), dest);
69026902

@@ -6946,7 +6946,7 @@ static int walk_batch_table_helper(struct bgp_clearing_info *cinfo,
69466946

69476947
if (cinfo->curr_counter >= bm->peer_clearing_batch_max_dests) {
69486948
/* Capture info about last dest seen and break */
6949-
if (bgp_debug_neighbor_events(NULL))
6949+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
69506950
zlog_debug("%s: %s/%s: pfx %pFX reached limit %u", __func__,
69516951
afi2str(table->afi), safi2str(table->safi), &pfx,
69526952
cinfo->curr_counter);
@@ -6960,7 +6960,7 @@ static int walk_batch_table_helper(struct bgp_clearing_info *cinfo,
69606960
}
69616961

69626962
if (examined > 0) {
6963-
if (bgp_debug_neighbor_events(NULL))
6963+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
69646964
zlog_debug("%s: %s/%s: examined %u dests, processed %u paths",
69656965
__func__, afi2str(table->afi),
69666966
safi2str(table->safi), examined, processed);
@@ -6995,7 +6995,7 @@ static int clear_batch_rib_helper(struct bgp_clearing_info *cinfo)
69956995
safi = SAFI_UNICAST;
69966996
}
69976997

6998-
if (bgp_debug_neighbor_events(NULL))
6998+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
69996999
zlog_debug("%s: %s: AFI/SAFI %s/%s", __func__, resume_str, afi2str(afi),
70007000
safi2str(safi));
70017001

@@ -7005,7 +7005,7 @@ static int clear_batch_rib_helper(struct bgp_clearing_info *cinfo)
70057005
/* Identify table to be examined: special handling
70067006
* for some SAFIs
70077007
*/
7008-
if (bgp_debug_neighbor_events(NULL))
7008+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
70097009
zlog_debug("%s: examining AFI/SAFI %s/%s", __func__, afi2str(afi),
70107010
safi2str(safi));
70117011

@@ -7033,7 +7033,7 @@ static int clear_batch_rib_helper(struct bgp_clearing_info *cinfo)
70337033
else
70347034
strlcpy(pbuf, "NULL", sizeof(pbuf));
70357035

7036-
if (bgp_debug_neighbor_events(NULL))
7036+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
70377037
zlog_debug("%s: outer table %s/%s starting dest %s",
70387038
__func__, afi2str(outer_table->afi),
70397039
safi2str(outer_table->safi), pbuf);
@@ -7052,7 +7052,7 @@ static int clear_batch_rib_helper(struct bgp_clearing_info *cinfo)
70527052
prefix_rd2str((struct prefix_rd *)(&dest->rn->p), pbuf,
70537053
sizeof(pbuf), ASNOTATION_PLAIN);
70547054

7055-
if (bgp_debug_neighbor_events(NULL))
7055+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
70567056
zlog_debug("%s: outer table %s/%s, dest %s",
70577057
__func__, afi2str(outer_table->afi),
70587058
safi2str(outer_table->safi), pbuf);
@@ -7107,7 +7107,7 @@ void bgp_clear_route_batch(struct bgp_clearing_info *cinfo)
71077107
{
71087108
int ret;
71097109

7110-
if (bgp_debug_neighbor_events(NULL))
7110+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
71117111
zlog_debug("%s: BGP %s, batch %u", __func__,
71127112
cinfo->bgp->name_pretty, cinfo->id);
71137113

@@ -7122,7 +7122,7 @@ void bgp_clear_route_batch(struct bgp_clearing_info *cinfo)
71227122
/* Handle pause/resume for the walk: we've captured key info
71237123
* in cinfo so we can resume later.
71247124
*/
7125-
if (bgp_debug_neighbor_events(NULL))
7125+
if (BGP_DEBUG(neighbor_events, NEIGHBOR_EVENTS_DETAIL))
71267126
zlog_debug("%s: reschedule cinfo at %s/%s, %pFX", __func__,
71277127
afi2str(cinfo->last_afi),
71287128
safi2str(cinfo->last_safi), &(cinfo->last_pfx));

doc/user/bgp.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4220,12 +4220,15 @@ Debugging
42204220

42214221
Enable or disable debugging of BGP conditional advertisement.
42224222

4223-
.. clicmd:: debug bgp neighbor-events
4223+
.. clicmd:: debug bgp neighbor-events [detail]
42244224

42254225
Enable or disable debugging for neighbor events. This provides general
42264226
information on BGP events such as peer connection / disconnection, session
42274227
establishment / teardown, and capability negotiation.
42284228

4229+
If ``detail`` is specified, the output will include extra context about state
4230+
transitions and related activity useful for deep troubleshooting of peer sessions.
4231+
42294232
.. clicmd:: debug bgp updates [detail]
42304233

42314234
Enable or disable debugging for BGP updates. This provides information on

0 commit comments

Comments
 (0)