Skip to content

Commit

Permalink
bgpd: add some counters not displayed yet
Browse files Browse the repository at this point in the history
Add some counters to keep track how often stuff is done.
This is mainly for us developers.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Mar 16, 2024
1 parent cf102f0 commit 9112222
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9112222

Please sign in to comment.