From 90ffa97e3817115a3076787dff1b98698c9d4034 Mon Sep 17 00:00:00 2001 From: mxyns Date: Fri, 29 Jul 2022 20:06:08 +0200 Subject: [PATCH] bgpd: beginning to add rib_uptime field for loc-rib timestamp added time_t field to bgp_path_info set value before bgp dp hook is called value not set in the msg yet, testing and double checking is needed before Signed-off-by: Maxence Younsi --- bgpd/bgp_bmp.c | 4 ++-- bgpd/bgp_route.c | 6 ++++++ bgpd/bgp_route.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index 6a48cb3e5c..f74647f094 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -1165,7 +1165,7 @@ afibreak: CHECK_FLAG(bmp->targets->afimon[afi][safi], BMP_MON_LOC_RIB)) { bmp_monitor(bmp, bpi->peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, bmp_get_peer_distinguisher(bmp, afi), bn_p, prd, - bpi->attr, afi, safi, bpi->uptime); + bpi->attr, afi, safi, bpi->rib_uptime); } if (bpi && CHECK_FLAG(bpi->flags, BGP_PATH_VALID) @@ -1322,7 +1322,7 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr) bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, bmp_get_peer_distinguisher(bmp, afi), &bqe->p, prd, bpi ? bpi->attr : NULL, afi, safi, - bpi ? bpi->uptime : monotime(NULL)); + bpi ? bpi->rib_uptime : monotime(NULL)); written = true; out: diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7333d5a432..9353b64f30 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3457,6 +3457,11 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest, zlog_info("old_select==NULL %s | new_select==NULL %s", old_select == NULL ? "YES" : "NO", new_select == NULL ? "YES" : "NO"); + + if (old_select) /* route is not installed in locrib anymore */ + old_select->rib_uptime = (time_t)(-1L); + if (new_select) /* route is installed in locrib from now on */ + new_select->rib_uptime = bgp_clock(); bool is_withdraw = old_select && !new_select; hook_call(bgp_route_update, bgp, afi, safi, dest, @@ -3989,6 +3994,7 @@ struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance, new->peer = peer; new->attr = attr; new->uptime = monotime(NULL); + new->rib_uptime = (time_t)(-1L); new->net = dest; return new; } diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index f834539742..232d680188 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -295,6 +295,7 @@ struct bgp_path_info { /* Uptime. */ time_t uptime; + time_t rib_uptime; /* reference count */ int lock; -- 2.39.5