From 1115feedc3f878853e2e67df9efdd0f5e5e1f997 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 | 10 +++++++++- bgpd/bgpd.h | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index ea6b288e2f..baeb96a9c8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -745,6 +745,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. */ @@ -4119,8 +4121,10 @@ static void bgp_process_internal(struct bgp *bgp, struct bgp_dest *dest, } /* 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 @@ -4129,6 +4133,7 @@ static void bgp_process_internal(struct bgp *bgp, struct bgp_dest *dest, if (BGP_DEBUG(update, UPDATE_OUT)) zlog_debug("BGP_NODE_SELECT_DEFER set for route %p", dest); + bgp->node_deferred_on_queue++; return; } @@ -13095,6 +13100,9 @@ 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 eef5bab333..f37a722f0c 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -864,6 +864,10 @@ struct bgp { /* BGP route flap dampening configuration */ struct bgp_damp_config damp[AFI_MAX][SAFI_MAX]; + uint64_t bestpath_runs; + uint64_t node_already_on_queue; + uint64_t node_deferred_on_queue; + QOBJ_FIELDS; }; DECLARE_QOBJ_TYPE(bgp);