From 911222261ab987a5187d642915df4eebae5d57f1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 3 Nov 2023 23:26:56 -0400 Subject: [PATCH] bgpd: add some counters not displayed yet Add some counters to keep track how often stuff is done. This is mainly for us developers. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 13 ++++++++++++- bgpd/bgpd.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 1b9bd7670d17..9e271130e7cd 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -654,6 +654,8 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, struct bgp_path_info *bpi_ultimate; struct peer *peer_new, *peer_exist; + bgp->bestpath_runs++; + *paths_eq = 0; /* 0. Null check. */ @@ -3695,8 +3697,10 @@ void bgp_process(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, safi_t safi) int pqnode_reuse = 0; /* already scheduled for processing? */ - if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED)) + if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED)) { + bgp->node_already_on_queue++; return; + } /* If the flag BGP_NODE_SELECT_DEFER is set, do not add route to * the workqueue @@ -3705,6 +3709,7 @@ void bgp_process(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, safi_t safi) if (BGP_DEBUG(update, UPDATE_OUT)) zlog_debug("BGP_NODE_SELECT_DEFER set for route %p", dest); + bgp->node_deferred_on_queue++; return; } @@ -12594,6 +12599,12 @@ DEFUN(show_ip_bgp_afi_safi_statistics, show_ip_bgp_afi_safi_statistics_cmd, json = json_object_new_object(); json_object_object_add(json, get_afi_safi_str(afi, safi, true), json_afi_safi); + json_object_int_add(json, "bgpBestPathCalls", + bgp->bestpath_runs); + json_object_int_add(json, "bgpNodeOnQueue", + bgp->node_already_on_queue); + json_object_int_add(json, "bgpNodeDeferredOnQueue", + bgp->node_deferred_on_queue); vty_json(vty, json); } return ret; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 94bb10725354..f0e67ce7c84d 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -825,6 +825,10 @@ struct bgp { enum asnotation_mode asnotation; + uint64_t bestpath_runs; + uint64_t node_already_on_queue; + uint64_t node_deferred_on_queue; + QOBJ_FIELDS; }; DECLARE_QOBJ_TYPE(bgp);