]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add bgp_nexthop_dump_bnc_flags
authorDonald Sharp <sharpd@nvidia.com>
Thu, 28 Jan 2021 00:56:13 +0000 (19:56 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 29 Jan 2021 12:54:58 +0000 (07:54 -0500)
Add a function that allows us to see a string version of the
bnc->flags bit fields.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_nexthop.c
bgpd/bgp_nexthop.h
bgpd/bgp_nht.c

index 1a9f59db6441c7ee404f9006e3eaf3560c3734ee..dcada04680cd8c7cce299c0fa954e87455fe4b35 100644 (file)
@@ -33,6 +33,7 @@
 #include "nexthop.h"
 #include "queue.h"
 #include "filter.h"
+#include "printfrr.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_route.h"
@@ -1020,3 +1021,28 @@ void bgp_scan_finish(struct bgp *bgp)
                bgp->connected_table[afi] = NULL;
        }
 }
+
+char *bgp_nexthop_dump_bnc_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%s%s%s%s",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID) ? "Valid " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED) ? "Reg " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) ? "Conn " : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED) ? "Notify "
+                                                                    : "",
+                  CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE) ? "Static " : "",
+                  CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH)
+                          ? "Static Exact "
+                          : "",
+                  CHECK_FLAG(bnc->flags, BGP_NEXTHOP_LABELED_VALID)
+                          ? "Label Valid "
+                          : "");
+
+       return buf;
+}
index c4b913faf4b7cf0b1b0b593dfeae8d4675b967c0..27486cf47586095d3cbda22745eac0dbe88fd477 100644 (file)
@@ -100,6 +100,9 @@ struct update_subgroup;
 struct bgp_dest;
 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 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,
index 85a65bc2ce298da2b04d740b469936321b7ba48d..8030f2e39e317d078dd8d0b41a0b92030ea23a7c 100644 (file)
@@ -320,12 +320,17 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
        bnc->change_flags = 0;
 
        /* debug print the input */
-       if (BGP_DEBUG(nht, NHT))
+       if (BGP_DEBUG(nht, NHT)) {
+               char bnc_buf[BNC_FLAG_DUMP_SIZE];
+
                zlog_debug(
-                       "%s(%u): Rcvd NH update %pFX(%u) - metric %d/%d #nhops %d/%d flags 0x%x",
+                       "%s(%u): Rcvd NH update %pFX(%u) - metric %d/%d #nhops %d/%d flags %s",
                        bnc->bgp->name_pretty, bnc->bgp->vrf_id, &nhr->prefix,
                        bnc->srte_color, nhr->metric, bnc->metric,
-                       nhr->nexthop_num, bnc->nexthop_num, bnc->flags);
+                       nhr->nexthop_num, bnc->nexthop_num,
+                       bgp_nexthop_dump_bnc_flags(bnc, bnc_buf,
+                                                  sizeof(bnc_buf)));
+       }
 
        if (nhr->metric != bnc->metric)
                bnc->change_flags |= BGP_NEXTHOP_METRIC_CHANGED;
@@ -702,10 +707,13 @@ 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];
+
                bnc_str(bnc, buf, PREFIX2STR_BUFFER);
                zlog_debug(
-                       "NH update for %s(%u)(%s) - flags 0x%x chgflags 0x%x - evaluate paths",
-                       buf, bnc->srte_color, bnc->bgp->name_pretty, bnc->flags,
+                       "NH update for %s(%u)(%s) - flags %s chgflags 0x%x - evaluate paths",
+                       buf, bnc->srte_color, bnc->bgp->name_pretty,
+                       bgp_nexthop_dump_bnc_flags(bnc, bnc_buf, sizeof(bnc_buf)),
                        bnc->change_flags);
        }