summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2020-10-17 19:21:52 +0200
committerGitHub <noreply@github.com>2020-10-17 19:21:52 +0200
commit0dc864709481a66c37b095f2f9df598896df3cd5 (patch)
tree1ec6521b98969a34e4ebee2951eab9669d15f736
parentMerge pull request #7322 from Orange-OpenSource/ospf-sr (diff)
parentdoc: Add %pBD print formatter to doc (diff)
downloadfrr-0dc864709481a66c37b095f2f9df598896df3cd5.tar.xz
frr-0dc864709481a66c37b095f2f9df598896df3cd5.zip
Merge pull request #7306 from donaldsharp/bgp_dest_print
Bgp dest print
-rw-r--r--bgpd/bgp_bmp.h2
-rw-r--r--bgpd/bgp_evpn.c93
-rw-r--r--bgpd/bgp_evpn_mh.c208
-rw-r--r--bgpd/bgp_evpn_private.h16
-rw-r--r--bgpd/bgp_mplsvpn.c16
-rw-r--r--bgpd/bgp_nexthop.c4
-rw-r--r--bgpd/bgp_nht.c6
-rw-r--r--bgpd/bgp_route.c113
-rw-r--r--bgpd/bgp_table.c12
-rw-r--r--bgpd/bgp_table.h1
-rw-r--r--bgpd/bgp_zebra.c16
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c2
-rw-r--r--doc/developer/logging.rst2
13 files changed, 247 insertions, 244 deletions
diff --git a/bgpd/bgp_bmp.h b/bgpd/bgp_bmp.h
index 9032da55b..d6b22d0cb 100644
--- a/bgpd/bgp_bmp.h
+++ b/bgpd/bgp_bmp.h
@@ -156,7 +156,7 @@ struct bmp {
* table entry, the sync* fields note down what we sent last
*/
struct prefix syncpos;
- struct bgp_node *syncrdpos;
+ struct bgp_dest *syncrdpos;
uint64_t syncpeerid;
afi_t syncafi;
safi_t syncsafi;
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 63e29fa2c..7f9ef0c9c 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -64,9 +64,10 @@ DEFINE_QOBJ_TYPE(bgp_evpn_es)
*/
static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn);
static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
- struct bgpevpn *vpn,
- struct bgp_node *rn, struct bgp_path_info *local_pi,
- const char *caller);
+ struct bgpevpn *vpn,
+ struct bgp_dest *dest,
+ struct bgp_path_info *local_pi,
+ const char *caller);
static struct in_addr zero_vtep_ip;
/*
@@ -545,10 +546,10 @@ static void evpn_convert_nexthop_to_ipv6(struct attr *attr)
attr->mp_nexthop_len = IPV6_MAX_BYTELEN;
}
-struct bgp_node *bgp_global_evpn_node_get(
- struct bgp_table *table, afi_t afi,
- safi_t safi, const struct prefix_evpn *evp,
- struct prefix_rd *prd)
+struct bgp_dest *bgp_global_evpn_node_get(struct bgp_table *table, afi_t afi,
+ safi_t safi,
+ const struct prefix_evpn *evp,
+ struct prefix_rd *prd)
{
struct prefix_evpn global_p;
@@ -562,10 +563,10 @@ struct bgp_node *bgp_global_evpn_node_get(
return bgp_afi_node_get(table, afi, safi, (struct prefix *)evp, prd);
}
-struct bgp_node *bgp_global_evpn_node_lookup(
- struct bgp_table *table, afi_t afi,
- safi_t safi, const struct prefix_evpn *evp,
- struct prefix_rd *prd)
+struct bgp_dest *bgp_global_evpn_node_lookup(struct bgp_table *table, afi_t afi,
+ safi_t safi,
+ const struct prefix_evpn *evp,
+ struct prefix_rd *prd)
{
struct prefix_evpn global_p;
@@ -1034,7 +1035,8 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
char prefix_buf[PREFIX_STRLEN];
char esi_buf[ESI_STR_LEN];
char esi_buf2[ESI_STR_LEN];
- struct prefix_evpn *evp = (struct prefix_evpn *)&dest->p;
+ struct prefix_evpn *evp =
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest);
zlog_debug("local path deleted %s es %s; new-path-es %s",
prefix2str(evp,
@@ -1359,9 +1361,9 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
}
static void bgp_evpn_get_sync_info(struct bgp *bgp, esi_t *esi,
- struct bgp_node *rn, uint32_t loc_seq, uint32_t *max_sync_seq,
- bool *active_on_peer, bool *peer_router,
- bool *proxy_from_peer)
+ struct bgp_dest *dest, uint32_t loc_seq,
+ uint32_t *max_sync_seq, bool *active_on_peer,
+ bool *peer_router, bool *proxy_from_peer)
{
struct bgp_path_info *tmp_pi;
struct bgp_path_info *second_best_path = NULL;
@@ -1372,8 +1374,8 @@ static void bgp_evpn_get_sync_info(struct bgp *bgp, esi_t *esi,
/* find the best non-local path. a local path can only be present
* as best path
*/
- for (tmp_pi = bgp_dest_get_bgp_path_info(rn); tmp_pi;
- tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->sub_type != BGP_ROUTE_IMPORTED ||
!CHECK_FLAG(tmp_pi->flags, BGP_PATH_VALID))
continue;
@@ -1420,11 +1422,13 @@ static void bgp_evpn_get_sync_info(struct bgp *bgp, esi_t *esi,
* VPN route table. It will take precedence over all sync paths.
*/
static void update_evpn_route_entry_sync_info(struct bgp *bgp,
- struct bgp_node *rn, struct attr *attr, uint32_t loc_seq,
- bool setup_sync)
+ struct bgp_dest *dest,
+ struct attr *attr,
+ uint32_t loc_seq, bool setup_sync)
{
esi_t *esi;
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ struct prefix_evpn *evp =
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest);
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
return;
@@ -1437,9 +1441,9 @@ static void update_evpn_route_entry_sync_info(struct bgp *bgp,
bool peer_router = false;
bool proxy_from_peer = false;
- bgp_evpn_get_sync_info(bgp, esi, rn, loc_seq,
- &max_sync_seq, &active_on_peer,
- &peer_router, &proxy_from_peer);
+ bgp_evpn_get_sync_info(bgp, esi, dest, loc_seq,
+ &max_sync_seq, &active_on_peer,
+ &peer_router, &proxy_from_peer);
attr->mm_sync_seqnum = max_sync_seq;
if (active_on_peer)
attr->es_flags |= ATTR_ES_PEER_ACTIVE;
@@ -1660,7 +1664,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);
@@ -1937,8 +1941,10 @@ static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
}
static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
- struct bgpevpn *vpn, struct bgp_node *rn,
- struct bgp_path_info *local_pi, const char *caller)
+ struct bgpevpn *vpn,
+ struct bgp_dest *dest,
+ struct bgp_path_info *local_pi,
+ const char *caller)
{
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -1947,9 +1953,10 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
struct attr *attr_new;
uint32_t seq;
int add_l3_ecomm = 0;
- struct bgp_node *global_rn;
+ struct bgp_dest *global_dest;
struct bgp_path_info *global_pi;
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ struct prefix_evpn *evp =
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest);
int route_change;
bool old_is_sync = false;
@@ -2008,9 +2015,9 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
}
/* Update the route entry. */
- route_change = update_evpn_route_entry(bgp, vpn, afi, safi,
- rn, &attr, 0, &pi, 0, seq,
- true /* setup_sync */, &old_is_sync);
+ route_change = update_evpn_route_entry(
+ bgp, vpn, afi, safi, dest, &attr, 0, &pi, 0, seq,
+ true /* setup_sync */, &old_is_sync);
assert(pi);
attr_new = pi->attr;
@@ -2026,14 +2033,14 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
* advertised to peers; otherwise, ensure it is evicted and
* (re)install the remote route into zebra.
*/
- evpn_route_select_install(bgp, vpn, rn);
+ evpn_route_select_install(bgp, vpn, dest);
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
route_change = 0;
} else {
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
route_change = 0;
- evpn_cleanup_local_non_best_route(bgp, vpn, rn, pi);
+ evpn_cleanup_local_non_best_route(bgp, vpn, dest, pi);
} else {
bool new_is_sync;
@@ -2056,17 +2063,17 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
if (route_change) {
/* Update route in global routing table. */
- global_rn = bgp_global_evpn_node_get(bgp->rib[afi][safi],
- afi, safi, evp, &vpn->prd);
- assert(global_rn);
- update_evpn_route_entry(bgp, vpn, afi, safi, global_rn,
- attr_new, 0, &global_pi, 0,
- mac_mobility_seqnum(attr_new),
- false /* setup_sync */, NULL /* old_is_sync */);
+ global_dest = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi,
+ safi, evp, &vpn->prd);
+ assert(global_dest);
+ update_evpn_route_entry(
+ bgp, vpn, afi, safi, global_dest, attr_new, 0,
+ &global_pi, 0, mac_mobility_seqnum(attr_new),
+ false /* setup_sync */, NULL /* old_is_sync */);
/* Schedule for processing and unlock node. */
- bgp_process(bgp, global_rn, afi, safi);
- bgp_dest_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/* Unintern temporary. */
@@ -5134,7 +5141,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);
}
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index 934c22d16..6fb5a4420 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -82,8 +82,8 @@ esi_t zero_esi_buf, *zero_esi = &zero_esi_buf;
* installed in the ES's routing table.
*/
static int bgp_evpn_es_route_select_install(struct bgp *bgp,
- struct bgp_evpn_es *es,
- struct bgp_node *rn)
+ struct bgp_evpn_es *es,
+ struct bgp_dest *dest)
{
int ret = 0;
afi_t afi = AFI_L2VPN;
@@ -93,8 +93,8 @@ static int bgp_evpn_es_route_select_install(struct bgp *bgp,
struct bgp_path_info_pair old_and_new;
/* Compute the best path. */
- bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi],
- &old_and_new, afi, safi);
+ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new,
+ afi, safi);
old_select = old_and_new.old;
new_select = old_and_new.new;
@@ -103,35 +103,36 @@ static int bgp_evpn_es_route_select_install(struct bgp *bgp,
* updated
*/
if (old_select && old_select == new_select
- && old_select->type == ZEBRA_ROUTE_BGP
- && old_select->sub_type == BGP_ROUTE_IMPORTED
- && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
- && !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
- && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
+ && old_select->type == ZEBRA_ROUTE_BGP
+ && old_select->sub_type == BGP_ROUTE_IMPORTED
+ && !CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR)
+ && !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
+ && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (bgp_zebra_has_route_changed(old_select)) {
bgp_evpn_es_vtep_add(bgp, es,
old_select->attr->nexthop,
true /*esr*/);
}
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
return ret;
}
/* If the user did a "clear" this flag will be set */
- UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
+ UNSET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
/* bestpath has changed; update relevant fields and install or uninstall
* into the zebra RIB.
*/
if (old_select || new_select)
- bgp_bump_version(rn);
+ bgp_bump_version(dest);
if (old_select)
- bgp_path_info_unset_flag(rn, old_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, old_select, BGP_PATH_SELECTED);
if (new_select) {
- bgp_path_info_set_flag(rn, new_select, BGP_PATH_SELECTED);
- bgp_path_info_unset_flag(rn, new_select, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, new_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, new_select,
+ BGP_PATH_ATTR_CHANGED);
UNSET_FLAG(new_select->flags, BGP_PATH_MULTIPATH_CHG);
}
@@ -148,11 +149,11 @@ static int bgp_evpn_es_route_select_install(struct bgp *bgp,
}
/* Clear any route change flags. */
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
/* Reap old select bgp_path_info, if it has been removed */
if (old_select && CHECK_FLAG(old_select->flags, BGP_PATH_REMOVED))
- bgp_path_info_reap(rn, old_select);
+ bgp_path_info_reap(dest, old_select);
return ret;
}
@@ -163,17 +164,17 @@ static int bgp_evpn_es_route_install(struct bgp *bgp,
struct bgp_path_info *parent_pi)
{
int ret = 0;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
struct attr *attr_new = NULL;
/* Create (or fetch) route within the VNI.
* NOTE: There is no RD here.
*/
- rn = bgp_node_get(es->route_table, (struct prefix *)p);
+ dest = bgp_node_get(es->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = bgp_dest_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent ==
parent_pi)
@@ -185,16 +186,16 @@ static int bgp_evpn_es_route_install(struct bgp *bgp,
/* Create new route with its attribute. */
pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0,
- parent_pi->peer, attr_new, rn);
+ parent_pi->peer, attr_new, dest);
SET_FLAG(pi->flags, BGP_PATH_VALID);
bgp_path_info_extra_get(pi);
pi->extra->parent = bgp_path_info_lock(parent_pi);
- bgp_dest_lock_node((struct bgp_node *)parent_pi->net);
- bgp_path_info_add(rn, pi);
+ bgp_dest_lock_node((struct bgp_dest *)parent_pi->net);
+ bgp_path_info_add(dest, pi);
} else {
if (attrhash_cmp(pi->attr, parent_pi->attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- bgp_dest_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
/* The attribute has changed. */
@@ -203,7 +204,7 @@ static int bgp_evpn_es_route_install(struct bgp *bgp,
/* Restore route, if needed. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
/* Mark if nexthop has changed. */
if (!IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop))
@@ -216,9 +217,9 @@ static int bgp_evpn_es_route_install(struct bgp *bgp,
}
/* Perform route selection and update zebra, if required. */
- ret = bgp_evpn_es_route_select_install(bgp, es, rn);
+ ret = bgp_evpn_es_route_select_install(bgp, es, dest);
- bgp_dest_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -228,7 +229,7 @@ static int bgp_evpn_es_route_uninstall(struct bgp *bgp, struct bgp_evpn_es *es,
struct prefix_evpn *p, struct bgp_path_info *parent_pi)
{
int ret;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
if (!es->route_table)
@@ -237,12 +238,12 @@ static int bgp_evpn_es_route_uninstall(struct bgp *bgp, struct bgp_evpn_es *es,
/* Locate route within the ESI.
* NOTE: There is no RD here.
*/
- rn = bgp_node_lookup(es->route_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(es->route_table, (struct prefix *)p);
+ if (!dest)
return 0;
/* Find matching route entry. */
- for (pi = bgp_dest_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent ==
parent_pi)
@@ -252,13 +253,13 @@ static int bgp_evpn_es_route_uninstall(struct bgp *bgp, struct bgp_evpn_es *es,
return 0;
/* Mark entry for deletion */
- bgp_path_info_delete(rn, pi);
+ bgp_path_info_delete(dest, pi);
/* Perform route selection and update zebra, if required. */
- ret = bgp_evpn_es_route_select_install(bgp, es, rn);
+ ret = bgp_evpn_es_route_select_install(bgp, es, dest);
/* Unlock route node. */
- bgp_dest_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -293,7 +294,7 @@ int bgp_evpn_es_route_install_uninstall(struct bgp *bgp, struct bgp_evpn_es *es,
*/
static void bgp_evpn_es_route_del_all(struct bgp *bgp, struct bgp_evpn_es *es)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi, *nextpi;
/* de-activate the ES */
@@ -301,13 +302,12 @@ static void bgp_evpn_es_route_del_all(struct bgp *bgp, struct bgp_evpn_es *es)
bgp_evpn_local_type1_evi_route_del(bgp, es);
/* Walk this ES's routing table and delete all routes. */
- for (rn = bgp_table_top(es->route_table); rn;
- rn = bgp_route_next(rn)) {
- for (pi = bgp_dest_get_bgp_path_info(rn);
- (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
- bgp_path_info_delete(rn, pi);
- bgp_path_info_reap(rn, pi);
+ for (dest = bgp_table_top(es->route_table); dest;
+ dest = bgp_route_next(dest)) {
+ for (pi = bgp_dest_get_bgp_path_info(dest);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
+ bgp_path_info_delete(dest, pi);
+ bgp_path_info_reap(dest, pi);
}
}
}
@@ -327,10 +327,11 @@ static void bgp_evpn_es_route_del_all(struct bgp *bgp, struct bgp_evpn_es *es)
* Note: vpn is applicable only to EAD-EVI routes (NULL for EAD-ES and
* ESR).
*/
-static int bgp_evpn_mh_route_update(struct bgp *bgp,
- struct bgp_evpn_es *es, struct bgpevpn *vpn, afi_t afi,
- safi_t safi, struct bgp_node *rn, struct attr *attr,
- int add, struct bgp_path_info **ri, int *route_changed)
+static int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es,
+ struct bgpevpn *vpn, afi_t afi, safi_t safi,
+ struct bgp_dest *dest, struct attr *attr,
+ int add, struct bgp_path_info **ri,
+ int *route_changed)
{
struct bgp_path_info *tmp_pi = NULL;
struct bgp_path_info *local_pi = NULL; /* local route entry if any */
@@ -339,11 +340,11 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp,
struct prefix_evpn *evp;
*ri = NULL;
- evp = (struct prefix_evpn *)&rn->p;
+ evp = (struct prefix_evpn *)bgp_dest_get_prefix(dest);
*route_changed = 1;
/* locate the local and remote entries if any */
- for (tmp_pi = bgp_dest_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -379,7 +380,7 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp,
/* Create new route with its attribute. */
tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
- bgp->peer_self, attr_new, rn);
+ bgp->peer_self, attr_new, dest);
SET_FLAG(tmp_pi->flags, BGP_PATH_VALID);
if (evp->prefix.route_type == BGP_EVPN_AD_ROUTE) {
@@ -392,7 +393,7 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp,
}
/* add the newly created path to the route-node */
- bgp_path_info_add(rn, tmp_pi);
+ bgp_path_info_add(dest, tmp_pi);
} else {
tmp_pi = local_pi;
if (attrhash_cmp(tmp_pi->attr, attr)
@@ -403,12 +404,12 @@ static int bgp_evpn_mh_route_update(struct bgp *bgp,
* Add (or update) attribute to hash.
*/
attr_new = bgp_attr_intern(attr);
- bgp_path_info_set_flag(rn, tmp_pi,
- BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, tmp_pi,
+ BGP_PATH_ATTR_CHANGED);
/* Restore route, if needed. */
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, tmp_pi);
+ bgp_path_info_restore(dest, tmp_pi);
/* Unintern existing, set to new. */
bgp_attr_unintern(&tmp_pi->attr);
@@ -444,8 +445,8 @@ static int bgp_evpn_mh_route_delete(struct bgp *bgp, struct bgp_evpn_es *es,
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
struct bgp_path_info *pi;
- struct bgp_node *rn = NULL; /* rn in esi table */
- struct bgp_node *global_rn = NULL; /* rn in global table */
+ struct bgp_dest *dest = NULL; /* dest in esi table */
+ struct bgp_dest *global_dest = NULL; /* dest in global table */
struct bgp_table *rt_table;
struct prefix_rd *prd;
@@ -461,8 +462,8 @@ static int bgp_evpn_mh_route_delete(struct bgp *bgp, struct bgp_evpn_es *es,
* If it doesn't exist, ther is nothing to do.
* Note: there is no RD here.
*/
- rn = bgp_node_lookup(rt_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(rt_table, (struct prefix *)p);
+ if (!dest)
return 0;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
@@ -476,29 +477,30 @@ static int bgp_evpn_mh_route_delete(struct bgp *bgp, struct bgp_evpn_es *es,
/* Next, locate route node in the global EVPN routing table.
* Note that this table is a 2-level tree (RD-level + Prefix-level)
*/
- global_rn = bgp_global_evpn_node_lookup(bgp->rib[afi][safi], afi, safi,
- (const struct prefix_evpn *)p, prd);
- if (global_rn) {
+ global_dest =
+ bgp_global_evpn_node_lookup(bgp->rib[afi][safi], afi, safi,
+ (const struct prefix_evpn *)p, prd);
+ if (global_dest) {
/* Delete route entry in the global EVPN table. */
- delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, global_dest, &pi);
/* Schedule for processing - withdraws to peers happen from
* this table.
*/
if (pi)
- bgp_process(bgp, global_rn, afi, safi);
- bgp_dest_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/*
* Delete route entry in the ESI or VNI routing table.
* This can just be removed.
*/
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, dest, &pi);
if (pi)
- bgp_path_info_reap(rn, pi);
- bgp_dest_unlock_node(rn);
+ bgp_path_info_reap(dest, pi);
+ bgp_dest_unlock_node(dest);
return 0;
}
@@ -551,7 +553,7 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp,
safi_t safi = SAFI_EVPN;
struct attr attr;
struct attr *attr_new = NULL;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
memset(&attr, 0, sizeof(struct attr));
@@ -567,11 +569,11 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp,
/* First, create (or fetch) route node within the ESI. */
/* NOTE: There is no RD here. */
- rn = bgp_node_get(es->route_table, (struct prefix *)p);
+ dest = bgp_node_get(es->route_table, (struct prefix *)p);
/* Create or update route entry. */
- ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi,
- rn, &attr, 1, &pi, &route_changed);
+ ret = bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest, &attr, 1,
+ &pi, &route_changed);
if (ret != 0) {
flog_err(EC_BGP_ES_INVALID,
"%u ERROR: Failed to updated ES route ESI: %s VTEP %s",
@@ -586,8 +588,8 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp,
* this is just to set the flags correctly
* as local route in the ES always wins.
*/
- bgp_evpn_es_route_select_install(bgp, es, rn);
- bgp_dest_unlock_node(rn);
+ bgp_evpn_es_route_select_install(bgp, es, dest);
+ bgp_dest_unlock_node(dest);
/* If this is a new route or some attribute has changed, export the
* route to the global table. The route will be advertised to peers
@@ -597,14 +599,15 @@ static int bgp_evpn_type4_route_update(struct bgp *bgp,
if (route_changed) {
struct bgp_path_info *global_pi;
- rn = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi,
- p, &es->prd);
- bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi,
- rn, attr_new, 1, &global_pi, &route_changed);
+ dest = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi,
+ p, &es->prd);
+ bgp_evpn_mh_route_update(bgp, es, NULL, afi, safi, dest,
+ attr_new, 1, &global_pi,
+ &route_changed);
/* Schedule for processing and unlock node. */
- bgp_process(bgp, rn, afi, safi);
- bgp_dest_unlock_node(rn);
+ bgp_process(bgp, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
}
/* Unintern temporary. */
@@ -695,7 +698,7 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
afi_t afi;
safi_t safi;
char buf[PREFIX_STRLEN];
- struct bgp_node *rd_rn, *rn;
+ struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -705,17 +708,19 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
/* Walk entire global routing table and evaluate routes which could be
* imported into this Ethernet Segment.
*/
- for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
- rd_rn = bgp_route_next(rd_rn)) {
- table = bgp_dest_get_bgp_table_info(rd_rn);
+ for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
+ rd_dest = bgp_route_next(rd_dest)) {
+ table = bgp_dest_get_bgp_table_info(rd_dest);
if (!table)
continue;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ for (dest = bgp_table_top(table); dest;
+ dest = bgp_route_next(dest)) {
+ struct prefix_evpn *evp =
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest);
- for (pi = bgp_dest_get_bgp_path_info(rn); pi;
- pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
+ pi = pi->next) {
/*
* Consider "valid" remote routes applicable for
* this ES.
@@ -845,7 +850,7 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
safi_t safi = SAFI_EVPN;
struct attr attr;
struct attr *attr_new = NULL;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
int route_changed = 0;
struct prefix_rd *global_rd;
@@ -867,11 +872,11 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
bgp_evpn_type1_evi_route_extcomm_build(es, vpn, &attr);
/* First, create (or fetch) route node within the VNI. */
- rn = bgp_node_get(vpn->route_table, (struct prefix *)p);
+ dest = bgp_node_get(vpn->route_table, (struct prefix *)p);
/* Create or update route entry. */
- ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi,
- rn, &attr, 1, &pi, &route_changed);
+ ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
+ &attr, 1, &pi, &route_changed);
if (ret != 0) {
flog_err(EC_BGP_ES_INVALID,
"%u Failed to update EAD-EVI route ESI: %s VNI %u VTEP %s",
@@ -889,11 +894,11 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
/* First, create (or fetch) route node within the ES. */
/* NOTE: There is no RD here. */
/* XXX: fragment ID must be included as a part of the prefix. */
- rn = bgp_node_get(es->route_table, (struct prefix *)p);
+ dest = bgp_node_get(es->route_table, (struct prefix *)p);
/* Create or update route entry. */
- ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi,
- rn, &attr, 1, &pi, &route_changed);
+ ret = bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
+ &attr, 1, &pi, &route_changed);
if (ret != 0) {
flog_err(EC_BGP_ES_INVALID,
"%u ERROR: Failed to updated EAD-EVI route ESI: %s VTEP %s",
@@ -911,8 +916,8 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
* this is just to set the flags correctly as local route in
* the ES always wins.
*/
- evpn_route_select_install(bgp, vpn, rn);
- bgp_dest_unlock_node(rn);
+ evpn_route_select_install(bgp, vpn, dest);
+ bgp_dest_unlock_node(dest);
/* If this is a new route or some attribute has changed, export the
* route to the global table. The route will be advertised to peers
@@ -922,14 +927,15 @@ static int bgp_evpn_type1_route_update(struct bgp *bgp,
if (route_changed) {
struct bgp_path_info *global_pi;
- rn = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi,
- p, global_rd);
- bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi,
- rn, attr_new, 1, &global_pi, &route_changed);
+ dest = bgp_global_evpn_node_get(bgp->rib[afi][safi], afi, safi,
+ p, global_rd);
+ bgp_evpn_mh_route_update(bgp, es, vpn, afi, safi, dest,
+ attr_new, 1, &global_pi,
+ &route_changed);
/* Schedule for processing and unlock node. */
- bgp_process(bgp, rn, afi, safi);
- bgp_dest_unlock_node(rn);
+ bgp_process(bgp, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
}
/* Unintern temporary. */
diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h
index ca45b198a..611566201 100644
--- a/bgpd/bgp_evpn_private.h
+++ b/bgpd/bgp_evpn_private.h
@@ -603,11 +603,13 @@ extern void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_path_info **pi);
int vni_list_cmp(void *p1, void *p2);
extern int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
- struct bgp_node *rn);
-extern struct bgp_node *bgp_global_evpn_node_get(
- struct bgp_table *table, afi_t afi, safi_t safi,
- const struct prefix_evpn *evp, struct prefix_rd *prd);
-extern struct bgp_node *bgp_global_evpn_node_lookup(
- struct bgp_table *table, afi_t afi, safi_t safi,
- const struct prefix_evpn *evp, struct prefix_rd *prd);
+ struct bgp_dest *dest);
+extern struct bgp_dest *bgp_global_evpn_node_get(struct bgp_table *table,
+ afi_t afi, safi_t safi,
+ const struct prefix_evpn *evp,
+ struct prefix_rd *prd);
+extern struct bgp_dest *
+bgp_global_evpn_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi,
+ const struct prefix_evpn *evp,
+ struct prefix_rd *prd);
#endif /* _BGP_EVPN_PRIVATE_H */
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index b33251635..67885cbf7 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -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)
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 0d8214e4d..29cca99fd 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -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);
}
}
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index e97c34bb5..6cd38ec78 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -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);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5986f08a7..73f5526fe 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -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;
}
@@ -1635,7 +1635,6 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *onlypeer;
struct bgp *bgp;
struct attr *piattr;
- char buf[PREFIX_STRLEN];
route_map_result_t ret;
int transparent;
int reflect;
@@ -1671,9 +1670,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* though they can have peer pointers that reference other
* systems
*/
- prefix2str(p, buf, PREFIX_STRLEN);
- zlog_debug("%s: pfx %s bgp_direct->vpn route peer safe",
- __func__, buf);
+ zlog_debug("%s: pfx %pFX bgp_direct->vpn route peer safe",
+ __func__, p);
samepeer_safe = 1;
}
#endif
@@ -1726,11 +1724,10 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
mpls_label_t label = bgp_adv_label(dest, pi, peer, afi, safi);
if (!bgp_is_valid_label(&label)) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
- zlog_debug("u%" PRIu64 ":s%" PRIu64" %s/%d is filtered - no label (%p)",
+ zlog_debug("u%" PRIu64 ":s%" PRIu64
+ " %pFX is filtered - no label (%p)",
subgrp->update_group->id, subgrp->id,
- inet_ntop(p->family, &p->u.prefix,
- buf, SU_ADDRSTRLEN),
- p->prefixlen, &label);
+ p, &label);
return false;
}
}
@@ -1771,9 +1768,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
&& (IPV4_ADDR_SAME(&onlypeer->remote_id, &piattr->originator_id))) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug(
- "%s [Update:SEND] %s originator-id is same as remote router-id",
- onlypeer->host,
- prefix2str(p, buf, sizeof(buf)));
+ "%s [Update:SEND] %pFX originator-id is same as remote router-id",
+ onlypeer->host, p);
return false;
}
@@ -1788,10 +1784,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
if (bgp_debug_update(NULL, p,
subgrp->update_group, 0))
zlog_debug(
- "%s [Update:SEND] %s is filtered via ORF",
- peer->host,
- prefix2str(p, buf,
- sizeof(buf)));
+ "%s [Update:SEND] %pFX is filtered via ORF",
+ peer->host, p);
return false;
}
}
@@ -1799,8 +1793,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
/* Output filter check. */
if (bgp_output_filter(peer, p, piattr, afi, safi) == FILTER_DENY) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
- zlog_debug("%s [Update:SEND] %s is filtered",
- peer->host, prefix2str(p, buf, sizeof(buf)));
+ zlog_debug("%s [Update:SEND] %pFX is filtered",
+ peer->host, p);
return false;
}
@@ -1986,8 +1980,9 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
if (ret == RMAP_DENYMATCH) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
- zlog_debug("%s [Update:SEND] %s is filtered by route-map",
- peer->host, prefix2str(p, buf, sizeof(buf)));
+ zlog_debug(
+ "%s [Update:SEND] %pFX is filtered by route-map",
+ peer->host, p);
bgp_attr_flush(attr);
return false;
@@ -2268,10 +2263,11 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
if (debug) {
bgp_path_info_path_with_addpath_rx_str(
new_select, path_buf);
- zlog_debug("%s: %s is the bestpath from AS %u",
- pfx_buf, path_buf,
- aspath_get_first_as(
- new_select->attr->aspath));
+ zlog_debug(
+ "%pBD: %s is the bestpath from AS %u",
+ dest, path_buf,
+ aspath_get_first_as(
+ new_select->attr->aspath));
}
}
}
@@ -2345,8 +2341,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
else
snprintf(path_buf, sizeof(path_buf), "NONE");
zlog_debug(
- "%s: After path selection, newbest is %s oldbest was %s",
- pfx_buf, path_buf,
+ "%pBD: After path selection, newbest is %s oldbest was %s",
+ dest, path_buf,
old_select ? old_select->peer->host : "NONE");
}
@@ -2361,8 +2357,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
if (pi == new_select) {
if (debug)
zlog_debug(
- "%s: %s is the bestpath, add to the multipath list",
- pfx_buf, path_buf);
+ "%pBD: %s is the bestpath, add to the multipath list",
+ dest, path_buf);
bgp_mp_list_add(&mp_list, pi);
continue;
}
@@ -2379,8 +2375,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
if (!bgp_path_info_nexthop_cmp(pi, new_select)) {
if (debug)
zlog_debug(
- "%s: %s has the same nexthop as the bestpath, skip it",
- pfx_buf, path_buf);
+ "%pBD: %s has the same nexthop as the bestpath, skip it",
+ dest, path_buf);
continue;
}
@@ -2391,8 +2387,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
if (paths_eq) {
if (debug)
zlog_debug(
- "%s: %s is equivalent to the bestpath, add to the multipath list",
- pfx_buf, path_buf);
+ "%pBD: %s is equivalent to the bestpath, add to the multipath list",
+ dest, path_buf);
bgp_mp_list_add(&mp_list, pi);
}
}
@@ -2601,7 +2597,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 +2621,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 +2682,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);
@@ -7610,10 +7606,7 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
if (p->family == AF_INET) {
if (!json) {
- len = vty_out(
- vty, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
- p->prefixlen);
+ len = vty_out(vty, "%pFX", p);
} else {
json_object_string_add(json, "prefix",
inet_ntop(p->family,
@@ -7625,7 +7618,7 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
}
} else if (p->family == AF_ETHERNET) {
prefix2str(p, buf, PREFIX_STRLEN);
- len = vty_out(vty, "%s", buf);
+ len = vty_out(vty, "%pFX", p);
} else if (p->family == AF_EVPN) {
if (!json)
len = vty_out(vty, "%s",
@@ -7640,10 +7633,7 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
NLRI_STRING_FORMAT_MIN, json);
} else {
if (!json)
- len = vty_out(
- vty, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
- p->prefixlen);
+ len = vty_out(vty, "%pFX", p);
else {
json_object_string_add(json, "prefix",
inet_ntop(p->family,
@@ -10331,7 +10321,6 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct peer *peer;
struct listnode *node, *nnode;
char buf1[RD_ADDRSTRLEN];
- char buf2[INET6_ADDRSTRLEN];
char buf3[EVPN_ROUTE_STRLEN];
char prefix_str[BUFSIZ];
int count = 0;
@@ -10378,15 +10367,12 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
}
} else {
if (!json) {
- vty_out(vty, "BGP routing table entry for %s%s%s/%d\n",
+ vty_out(vty, "BGP routing table entry for %s%s%pFX\n",
((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
- ? prefix_rd2str(prd, buf1,
- sizeof(buf1))
- : ""),
- safi == SAFI_MPLS_VPN ? ":" : "",
- inet_ntop(p->family, &p->u.prefix, buf2,
- INET6_ADDRSTRLEN),
- p->prefixlen);
+ ? prefix_rd2str(prd, buf1,
+ sizeof(buf1))
+ : ""),
+ safi == SAFI_MPLS_VPN ? ":" : "", p);
} else
json_object_string_add(json, "prefix",
@@ -13780,7 +13766,6 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
const struct prefix_rd *prd;
struct bgp_static *bgp_static;
mpls_label_t label;
- char buf[SU_ADDRSTRLEN];
char rdbuf[RD_ADDRSTRLEN];
/* Network configuration. */
@@ -13804,10 +13789,7 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
label = decode_label(&bgp_static->label);
- vty_out(vty, " network %s/%d rd %s",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen, rdbuf);
+ vty_out(vty, " network %pFX rd %s", p, rdbuf);
if (safi == SAFI_MPLS_VPN)
vty_out(vty, " label %u", label);
@@ -13905,7 +13887,6 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
const struct prefix *p;
struct bgp_static *bgp_static;
struct bgp_aggregate *bgp_aggregate;
- char buf[SU_ADDRSTRLEN];
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) {
bgp_config_write_network_vpn(vty, bgp, afi, safi);
@@ -13926,9 +13907,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
p = bgp_dest_get_prefix(dest);
- vty_out(vty, " network %s/%d",
- inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
- p->prefixlen);
+ vty_out(vty, " network %pFX", p);
if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX)
vty_out(vty, " label-index %u",
@@ -13952,9 +13931,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
p = bgp_dest_get_prefix(dest);
- vty_out(vty, " aggregate-address %s/%d",
- inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
- p->prefixlen);
+ vty_out(vty, " aggregate-address %pFX", p);
if (bgp_aggregate->as_set)
vty_out(vty, " as-set");
@@ -13999,7 +13976,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
: "");
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index 185cb251c..70e226b01 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -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;
+}
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index cf0086b52..31ea5554d 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -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 */
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index a32e47f44..1ee8a1a50 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -944,10 +944,8 @@ static bool bgp_table_map_apply(struct route_map *map, const struct prefix *p,
if (p->family == AF_INET) {
char buf[2][INET_ADDRSTRLEN];
zlog_debug(
- "Zebra rmap deny: IPv4 route %s/%d nexthop %s",
- inet_ntop(AF_INET, &p->u.prefix4, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
+ "Zebra rmap deny: IPv4 route %pFX nexthop %s",
+ p,
inet_ntop(AF_INET, &path->attr->nexthop, buf[1],
sizeof(buf[1])));
}
@@ -958,12 +956,10 @@ static bool bgp_table_map_apply(struct route_map *map, const struct prefix *p,
nexthop = bgp_path_info_to_ipv6_nexthop(path, &ifindex);
zlog_debug(
- "Zebra rmap deny: IPv6 route %s/%d nexthop %s",
- inet_ntop(AF_INET6, &p->u.prefix6, buf[0],
- sizeof(buf[0])),
- p->prefixlen,
- inet_ntop(AF_INET6, nexthop,
- buf[1], sizeof(buf[1])));
+ "Zebra rmap deny: IPv6 route %pFX nexthop %s",
+ p,
+ inet_ntop(AF_INET6, nexthop, buf[1],
+ sizeof(buf[1])));
}
}
return false;
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index 0480704b2..b56261669 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -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);
diff --git a/doc/developer/logging.rst b/doc/developer/logging.rst
index 0430ad72a..2f2444373 100644
--- a/doc/developer/logging.rst
+++ b/doc/developer/logging.rst
@@ -83,6 +83,8 @@ Extensions
+-----------+--------------------------+----------------------------------------------+
| ``%pNHs`` | ``struct nexthop *`` | ``1.2.3.4 if 15`` |
+-----------+--------------------------+----------------------------------------------+
+| ``%pFX`` + ``struct bgp_dest *`` | ``fe80::1234/64`` available in BGP only |
++-----------+--------------------------+----------------------------------------------+
Printf features like field lengths can be used normally with these extensions,
e.g. ``%-15pI4`` works correctly.