]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add `%pBD` for printing `struct bgp_dest *`
authorDavid Lamparter <equinox@diac24.net>
Tue, 23 Jun 2020 14:00:41 +0000 (16:00 +0200)
committerDonald Sharp <sharpd@nvidia.com>
Sat, 17 Oct 2020 12:52:35 +0000 (08:52 -0400)
`%pRN` is not appropriate anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_evpn.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_route.c
bgpd/bgp_table.c
bgpd/bgp_table.h
bgpd/rfapi/vnc_export_bgp.c

index 0703853354fcdaabad4b1253576b2392f83b2c70..dc133e257a6c820663b31844e032e7c749147f5d 100644 (file)
@@ -1660,7 +1660,7 @@ static void evpn_cleanup_local_non_best_route(struct bgp *bgp,
 {
        /* local path was not picked as the winner; kick it out */
        if (bgp_debug_zebra(NULL))
-               zlog_debug("evicting local evpn prefix %pRN as remote won",
+               zlog_debug("evicting local evpn prefix %pBD as remote won",
                           dest);
 
        evpn_delete_old_local_route(bgp, vpn, dest, local_pi, NULL);
@@ -5209,7 +5209,7 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
                                                              sizeof(attr_str));
 
                                                zlog_debug(
-                                                       "%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop",
+                                                       "%u: prefix %pBD with attr %s - DENIED due to martian or self nexthop",
                                                        bgp->vrf_id, dest,
                                                        attr_str);
                                        }
index b33251635c582a92010384a8ba1c38804767bdf7..67885cbf7ecdef9ef3829e64cc1871e2cfbc28ce 100644 (file)
@@ -506,7 +506,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
 
        if (debug)
                zlog_debug(
-                       "%s: entry: leak-to=%s, p=%pRN, type=%d, sub_type=%d",
+                       "%s: entry: leak-to=%s, p=%pBD, type=%d, sub_type=%d",
                        __func__, bgp->name_pretty, bn, source_bpi->type,
                        source_bpi->sub_type);
 
@@ -547,7 +547,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
                        bgp_attr_unintern(&new_attr);
                        if (debug)
                                zlog_debug(
-                                       "%s: ->%s: %pRN: Found route, no change",
+                                       "%s: ->%s: %pBD: Found route, no change",
                                        __func__, bgp->name_pretty, bn);
                        return NULL;
                }
@@ -608,7 +608,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
                bgp_dest_unlock_node(bn);
 
                if (debug)
-                       zlog_debug("%s: ->%s: %pRN Found route, changed attr",
+                       zlog_debug("%s: ->%s: %pBD Found route, changed attr",
                                   __func__, bgp->name_pretty, bn);
 
                return bpi;
@@ -674,7 +674,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
        bgp_process(bgp, bn, afi, safi);
 
        if (debug)
-               zlog_debug("%s: ->%s: %pRN: Added new route", __func__,
+               zlog_debug("%s: ->%s: %pBD: Added new route", __func__,
                           bgp->name_pretty, bn);
 
        return new;
@@ -929,7 +929,7 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn,                /* to */
 
        if (debug) {
                zlog_debug(
-                       "%s: entry: leak-from=%s, p=%pRN, type=%d, sub_type=%d",
+                       "%s: entry: leak-from=%s, p=%pBD, type=%d, sub_type=%d",
                        __func__, bgp_vrf->name_pretty, path_vrf->net,
                        path_vrf->type, path_vrf->sub_type);
        }
@@ -1009,7 +1009,7 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
                for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
                        bpi = bgp_dest_get_bgp_path_info(bn);
                        if (debug && bpi) {
-                               zlog_debug("%s: looking at prefix %pRN",
+                               zlog_debug("%s: looking at prefix %pBD",
                                           __func__, bn);
                        }
 
@@ -1262,7 +1262,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf,            /* to */
        }
 
        if (debug)
-               zlog_debug("%s: pfx %pRN: num_labels %d", __func__,
+               zlog_debug("%s: pfx %pBD: num_labels %d", __func__,
                           path_vpn->net, num_labels);
 
        /*
@@ -1315,7 +1315,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn,            /* from */
        int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
 
        if (debug)
-               zlog_debug("%s: entry: p=%pRN, type=%d, sub_type=%d", __func__,
+               zlog_debug("%s: entry: p=%pBD, type=%d, sub_type=%d", __func__,
                           path_vpn->net, path_vpn->type, path_vpn->sub_type);
 
        if (debug)
index 0d8214e4d6ea7b87a82623d395f4f52dd2085eab..29cca99fd76410369e24490cdc855a8774241176 100644 (file)
@@ -757,10 +757,10 @@ static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
                if (dest->pdest) {
                        prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
                                        buf1, sizeof(buf1));
-                       vty_out(vty, "    %d/%d %pRN RD %s %s flags 0x%x\n",
+                       vty_out(vty, "    %d/%d %pBD RD %s %s flags 0x%x\n",
                                afi, safi, dest, buf1, bgp_path->name_pretty, path->flags);
                } else
-                       vty_out(vty, "    %d/%d %pRN %s flags 0x%x\n",
+                       vty_out(vty, "    %d/%d %pBD %s flags 0x%x\n",
                                afi, safi, dest, bgp_path->name_pretty, path->flags);
        }
 }
index e97c34bb5e230c25efea47c34ef2e4deee9c8887..6cd38ec78f7ffe6a075b3c5858d4669b4b7173c3 100644 (file)
@@ -757,7 +757,7 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
                                    path->sub_type, path->attr, dest)) {
                                if (BGP_DEBUG(nht, NHT))
                                        zlog_debug(
-                                               "%s: prefix %pRN (vrf %s), ignoring path due to martian or self-next-hop",
+                                               "%s: prefix %pBD (vrf %s), ignoring path due to martian or self-next-hop",
                                                __func__, dest, bgp_path->name);
                        } else
                                bnc_is_valid_nexthop =
@@ -771,12 +771,12 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
                                prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
                                        buf1, sizeof(buf1));
                                zlog_debug(
-                                       "... eval path %d/%d %pRN RD %s %s flags 0x%x",
+                                       "... eval path %d/%d %pBD RD %s %s flags 0x%x",
                                        afi, safi, dest, buf1,
                                        bgp_path->name_pretty, path->flags);
                        } else
                                zlog_debug(
-                                       "... eval path %d/%d %pRN %s flags 0x%x",
+                                       "... eval path %d/%d %pBD %s flags 0x%x",
                                        afi, safi, dest, bgp_path->name_pretty,
                                        path->flags);
                }
index 8977b1651a6a121c936340a6645e25a30a99c5aa..f130d54967a7448d8858cdb994526200b7d861c0 100644 (file)
@@ -314,8 +314,8 @@ static int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete)
        if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED)) {
                if (BGP_DEBUG(update, UPDATE_OUT))
                        zlog_debug(
-                               "Route %pRN is in workqueue and being processed, not deferred.",
-                               bgp_dest_to_rnode(dest));
+                               "Route %pBD is in workqueue and being processed, not deferred.",
+                               dest);
 
                return 0;
        }
@@ -365,7 +365,7 @@ static int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete)
                                        bgp->gr_info[afi][safi].route_list,
                                        dest);
                        if (BGP_DEBUG(update, UPDATE_OUT))
-                               zlog_debug("DEFER route %pRN, dest %p, node %p",
+                               zlog_debug("DEFER route %pBD, dest %p, node %p",
                                           dest, dest, dest->rt_node);
                        return 0;
                }
@@ -2601,7 +2601,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
                        debug = bgp_debug_bestpath(dest);
                if (debug)
                        zlog_debug(
-                               "%s: bgp delete in progress, ignoring event, p=%pRN",
+                               "%s: bgp delete in progress, ignoring event, p=%pBD",
                                __func__, dest);
                return;
        }
@@ -2625,7 +2625,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
 
        debug = bgp_debug_bestpath(dest);
        if (debug)
-               zlog_debug("%s: p=%pRN afi=%s, safi=%s start", __func__, dest,
+               zlog_debug("%s: p=%pBD afi=%s, safi=%s start", __func__, dest,
                           afi2str(afi), safi2str(safi));
 
        /* The best path calculation for the route is deferred if
@@ -2686,7 +2686,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
 
        if (debug)
                zlog_debug(
-                       "%s: p=%pRN afi=%s, safi=%s, old_select=%p, new_select=%p",
+                       "%s: p=%pBD afi=%s, safi=%s, old_select=%p, new_select=%p",
                        __func__, dest, afi2str(afi), safi2str(safi),
                        old_select, new_select);
 
@@ -14001,7 +14001,7 @@ void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
             dest = bgp_route_next(dest)) {
                bdistance = bgp_dest_get_bgp_distance_info(dest);
                if (bdistance != NULL)
-                       vty_out(vty, "  distance %d %pRN %s\n",
+                       vty_out(vty, "  distance %d %pBD %s\n",
                                bdistance->distance, dest,
                                bdistance->access_list ? bdistance->access_list
                                                       : "");
index 185cb251c7efa4c4379cbc46dce2997f443b76e1..70e226b01b2c9d384929cd90ee84bf2bedd16758 100644 (file)
@@ -26,6 +26,7 @@
 #include "queue.h"
 #include "filter.h"
 #include "command.h"
+#include "printfrr.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_table.h"
@@ -203,3 +204,14 @@ struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
        bgp_dest_lock_node(matched);
        return matched;
 }
+
+printfrr_ext_autoreg_p("BD", printfrr_bd)
+static ssize_t printfrr_bd(char *buf, size_t bsz, const char *fmt,
+                          int prec, const void *ptr)
+{
+       const struct bgp_dest *dest = ptr;
+       const struct prefix *p = bgp_dest_get_prefix(dest);
+
+       prefix2str(p, buf, bsz);
+       return 2;
+}
index cf0086b52e91f5bf71ae5f5deba7fc0132d3834a..31ea5554d585e4ff4f99725778fa3ff92c3df155 100644 (file)
@@ -471,6 +471,7 @@ static inline const struct prefix *bgp_dest_get_prefix(const struct bgp_dest *de
 
 #ifdef _FRR_ATTRIBUTE_PRINTFRR
 #pragma FRR printfrr_ext "%pRN"  (struct bgp_node *)
+#pragma FRR printfrr_ext "%pBD"  (struct bgp_dest *)
 #endif
 
 #endif /* _QUAGGA_BGP_TABLE_H */
index 0480704b277ff5d3d3fd34bcaf15ec167388b975..b56261669c347f1853b6fd63339d9d96f9ecccc0 100644 (file)
@@ -1865,7 +1865,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
                        if (!bgp_dest_has_bgp_path_info_data(dest))
                                continue;
 
-                       vnc_zlog_debug_verbose("%s: checking prefix %pRN",
+                       vnc_zlog_debug_verbose("%s: checking prefix %pBD",
                                               __func__, dest);
 
                        dest_p = bgp_dest_get_prefix(dest);