From df2a41a9bf6a9c2efb72fab1df57b6654a8d55b4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 27 Jan 2021 20:03:03 -0500 Subject: bgpd: Add `bgp_nexthop_dump_bnc_change_flags` function Allow us to read what the change flags are instead of having to look them up. Signed-off-by: Donald Sharp --- bgpd/bgp_nexthop.c | 22 ++++++++++++++++++++++ bgpd/bgp_nexthop.h | 2 ++ bgpd/bgp_nht.c | 9 ++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) (limited to 'bgpd') diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index dcada0468..b7f62ec0a 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -1046,3 +1046,25 @@ char *bgp_nexthop_dump_bnc_flags(struct bgp_nexthop_cache *bnc, char *buf, return buf; } + +char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache *bnc, + char *buf, size_t len) +{ + if (bnc->flags == 0) { + snprintfrr(buf, len, "None "); + return buf; + } + + snprintfrr(buf, len, "%s%s%s", + CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED) + ? "Changed " + : "", + CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_METRIC_CHANGED) + ? "Metric " + : "", + CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CONNECTED_CHANGED) + ? "Connected " + : ""); + + return buf; +} diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h index 27486cf47..a223ff413 100644 --- a/bgpd/bgp_nexthop.h +++ b/bgpd/bgp_nexthop.h @@ -103,6 +103,8 @@ struct attr; #define BNC_FLAG_DUMP_SIZE 180 extern char *bgp_nexthop_dump_bnc_flags(struct bgp_nexthop_cache *bnc, char *buf, size_t len); +extern char *bgp_nexthop_dump_bnc_change_flags(struct bgp_nexthop_cache *bnc, + char *buf, size_t len); extern void bgp_connected_add(struct bgp *bgp, struct connected *c); extern void bgp_connected_delete(struct bgp *bgp, struct connected *c); extern bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop, diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 8030f2e39..bc5da0ee2 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -708,13 +708,16 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc) if (BGP_DEBUG(nht, NHT)) { char buf[PREFIX2STR_BUFFER]; char bnc_buf[BNC_FLAG_DUMP_SIZE]; + char chg_buf[BNC_FLAG_DUMP_SIZE]; bnc_str(bnc, buf, PREFIX2STR_BUFFER); zlog_debug( - "NH update for %s(%u)(%s) - flags %s chgflags 0x%x - evaluate paths", + "NH update for %s(%u)(%s) - flags %s chgflags %s- evaluate paths", buf, bnc->srte_color, bnc->bgp->name_pretty, - bgp_nexthop_dump_bnc_flags(bnc, bnc_buf, sizeof(bnc_buf)), - bnc->change_flags); + bgp_nexthop_dump_bnc_flags(bnc, bnc_buf, + sizeof(bnc_buf)), + bgp_nexthop_dump_bnc_change_flags(bnc, chg_buf, + sizeof(bnc_buf))); } LIST_FOREACH (path, &(bnc->paths), nh_thread) { -- cgit v1.2.3