bgpd: Use %pRD for prefix_rd2str()

Convert a bunch of prefix_rd2str() for json/vty stuff.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2022-09-22 11:17:49 +03:00
parent 447d0fc290
commit c4f64ea94d
15 changed files with 111 additions and 235 deletions

View File

@ -2662,7 +2662,6 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
struct bgp_route_evpn *overlay_index,
char *str, int size)
{
char rd_buf[RD_ADDRSTRLEN];
char tag_buf[30];
char overlay_index_buf[INET6_ADDRSTRLEN + 14];
const struct prefix_evpn *evp;
@ -2720,8 +2719,7 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
}
if (prd)
snprintfrr(str, size, "RD %s %pFX%s%s%s %s %s",
prefix_rd2str(prd, rd_buf, sizeof(rd_buf)), pu.p,
snprintfrr(str, size, "RD %pRD %pFX%s%s%s %s %s", prd, pu.p,
overlay_index_buf, tag_buf, pathid_buf, afi2str(afi),
safi2str(safi));
else if (safi == SAFI_FLOWSPEC) {

View File

@ -2402,16 +2402,13 @@ static void bgp_evpn_es_json_frag_fill(json_object *json_frags,
struct bgp_evpn_es *es)
{
json_object *json_frag;
char buf1[RD_ADDRSTRLEN];
struct listnode *node;
struct bgp_evpn_es_frag *es_frag;
for (ALL_LIST_ELEMENTS_RO(es->es_frag_list, node, es_frag)) {
json_frag = json_object_new_object();
json_object_string_add(
json_frag, "rd",
prefix_rd2str(&es_frag->prd, buf1, sizeof(buf1)));
json_object_string_addf(json_frag, "rd", "%pRD", &es_frag->prd);
json_object_int_add(json_frag, "eviCount",
listcount(es_frag->es_evi_frag_list));
@ -2423,12 +2420,10 @@ static void bgp_evpn_es_frag_show_detail(struct vty *vty,
struct bgp_evpn_es *es)
{
struct listnode *node;
char buf1[RD_ADDRSTRLEN];
struct bgp_evpn_es_frag *es_frag;
for (ALL_LIST_ELEMENTS_RO(es->es_frag_list, node, es_frag)) {
vty_out(vty, " %s EVIs: %d\n",
prefix_rd2str(&es_frag->prd, buf1, sizeof(buf1)),
vty_out(vty, " %pRD EVIs: %d\n", &es_frag->prd,
listcount(es_frag->es_evi_frag_list));
}
}
@ -2533,7 +2528,6 @@ static void bgp_evpn_es_vteps_show_detail(struct vty *vty,
static void bgp_evpn_es_show_entry(struct vty *vty,
struct bgp_evpn_es *es, json_object *json)
{
char buf1[RD_ADDRSTRLEN];
struct listnode *node;
struct bgp_evpn_es_vtep *es_vtep;
@ -2543,10 +2537,8 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
json_object_string_add(json, "esi", es->esi_str);
if (es->es_base_frag)
json_object_string_add(
json, "rd",
prefix_rd2str(&es->es_base_frag->prd, buf1,
sizeof(buf1)));
json_object_string_addf(json, "rd", "%pRD",
&es->es_base_frag->prd);
if (es->flags & (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE)) {
json_types = json_object_new_array();
@ -2583,15 +2575,9 @@ static void bgp_evpn_es_show_entry(struct vty *vty,
bgp_evpn_es_vteps_str(vtep_str, es, sizeof(vtep_str));
if (es->es_base_frag)
prefix_rd2str(&es->es_base_frag->prd, buf1,
sizeof(buf1));
else
strlcpy(buf1, "-", sizeof(buf1));
vty_out(vty, "%-30s %-5s %-21s %-8d %s\n",
es->esi_str, type_str, buf1,
listcount(es->es_evi_list), vtep_str);
vty_out(vty, "%-30s %-5s %-21pRD %-8d %s\n", es->esi_str,
type_str, &es->es_base_frag->prd,
listcount(es->es_evi_list), vtep_str);
}
}
@ -2657,7 +2643,6 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
} else {
char incons_str[BGP_EVPNES_INCONS_STR_SZ];
char type_str[4];
char buf1[RD_ADDRSTRLEN];
type_str[0] = '\0';
if (es->flags & BGP_EVPNES_LOCAL)
@ -2665,15 +2650,9 @@ static void bgp_evpn_es_show_entry_detail(struct vty *vty,
if (es->flags & BGP_EVPNES_REMOTE)
strlcat(type_str, "R", sizeof(type_str));
if (es->es_base_frag)
prefix_rd2str(&es->es_base_frag->prd, buf1,
sizeof(buf1));
else
strlcpy(buf1, "-", sizeof(buf1));
vty_out(vty, "ESI: %s\n", es->esi_str);
vty_out(vty, " Type: %s\n", type_str);
vty_out(vty, " RD: %s\n", buf1);
vty_out(vty, " RD: %pRD\n", &es->es_base_frag->prd);
vty_out(vty, " Originator-IP: %pI4\n", &es->originator_ip);
if (es->flags & BGP_EVPNES_LOCAL)
vty_out(vty, " Local ES DF preference: %u\n",
@ -4032,18 +4011,14 @@ static void bgp_evpn_es_evi_show_entry(struct vty *vty,
static void bgp_evpn_es_evi_show_entry_detail(struct vty *vty,
struct bgp_evpn_es_evi *es_evi, json_object *json)
{
char buf1[RD_ADDRSTRLEN];
if (json) {
json_object *json_flags;
/* Add the "brief" info first */
bgp_evpn_es_evi_show_entry(vty, es_evi, json);
if (es_evi->es_frag)
json_object_string_add(
json, "esFragmentRd",
prefix_rd2str(&es_evi->es_frag->prd, buf1,
sizeof(buf1)));
json_object_string_addf(json, "esFragmentRd", "%pRD",
&es_evi->es_frag->prd);
if (es_evi->flags & BGP_EVPNES_EVI_INCONS_VTEP_LIST) {
json_flags = json_object_new_array();
json_array_string_add(json_flags, "es-vtep-mismatch");
@ -4067,9 +4042,8 @@ static void bgp_evpn_es_evi_show_entry_detail(struct vty *vty,
es_evi->vpn->vni, es_evi->es->esi_str);
vty_out(vty, " Type: %s\n", type_str);
if (es_evi->es_frag)
vty_out(vty, " ES fragment RD: %s\n",
prefix_rd2str(&es_evi->es_frag->prd, buf1,
sizeof(buf1)));
vty_out(vty, " ES fragment RD: %pRD\n",
&es_evi->es_frag->prd);
vty_out(vty, " Inconsistencies: %s\n",
(es_evi->flags & BGP_EVPNES_EVI_INCONS_VTEP_LIST) ?
"es-vtep-mismatch":"-");

View File

@ -386,9 +386,7 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
json_object_int_add(json, "vni", bgp_vrf->l3vni);
json_object_string_add(json, "type", "L3");
json_object_string_add(json, "inKernel", "True");
json_object_string_add(
json, "rd",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
json_object_string_addf(json, "rd", "%pRD", &bgp_vrf->vrf_prd);
json_object_string_addf(json, "originatorIp", "%pI4",
&bgp_vrf->originator_ip);
json_object_string_add(json, "advertiseGatewayMacip", "n/a");
@ -412,8 +410,7 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
vty_out(vty, " Type: %s\n", "L3");
vty_out(vty, " Tenant VRF: %s\n",
vrf_id_to_name(bgp_vrf->vrf_id));
vty_out(vty, " RD: %s\n",
prefix_rd2str(&bgp_vrf->vrf_prd, buf1, RD_ADDRSTRLEN));
vty_out(vty, " RD: %pRD\n", &bgp_vrf->vrf_prd);
vty_out(vty, " Originator IP: %pI4\n",
&bgp_vrf->originator_ip);
vty_out(vty, " Advertise-gw-macip : %s\n", "n/a");
@ -471,7 +468,6 @@ static void display_l3vni(struct vty *vty, struct bgp *bgp_vrf,
static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
{
char buf1[RD_ADDRSTRLEN];
char *ecom_str;
struct listnode *node, *nnode;
struct ecommunity *ecom;
@ -488,9 +484,7 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
json_object_string_add(json, "type", "L2");
json_object_string_add(json, "inKernel",
is_vni_live(vpn) ? "True" : "False");
json_object_string_add(
json, "rd",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
json_object_string_addf(json, "rd", "%pRD", &vpn->prd);
json_object_string_addf(json, "originatorIp", "%pI4",
&vpn->originator_ip);
json_object_string_addf(json, "mcastGroup", "%pI4",
@ -531,8 +525,7 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
vty_out(vty, " Type: %s\n", "L2");
vty_out(vty, " Tenant-Vrf: %s\n",
vrf_id_to_name(vpn->tenant_vrf_id));
vty_out(vty, " RD: %s\n",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
vty_out(vty, " RD: %pRD\n", &vpn->prd);
vty_out(vty, " Originator IP: %pI4\n", &vpn->originator_ip);
vty_out(vty, " Mcast group: %pI4\n", &vpn->mcast_grp);
if (!vpn->advertise_gw_macip &&
@ -941,9 +934,7 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
json_object_string_add(json_vni, "inKernel", "True");
json_object_string_addf(json_vni, "originatorIp", "%pI4",
&bgp->originator_ip);
json_object_string_add(
json_vni, "rd",
prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));
json_object_string_addf(json_vni, "rd", "%pRD", &bgp->vrf_prd);
json_object_string_add(json_vni, "advertiseGatewayMacip",
"n/a");
json_object_string_add(json_vni, "advertiseSviMacIp", "n/a");
@ -959,8 +950,8 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,
json_vni, "rmac",
prefix_mac2str(&bgp->rmac, buf2, sizeof(buf2)));
} else {
vty_out(vty, "%-1s %-10u %-4s %-21s", buf1, bgp->l3vni, "L3",
prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));
vty_out(vty, "%-1s %-10u %-4s %-21pRD", buf1, bgp->l3vni, "L3",
&bgp->vrf_prd);
}
for (ALL_LIST_ELEMENTS(bgp->vrf_import_rtl, node, nnode, ecom)) {
@ -1038,7 +1029,6 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
json_object *json_export_rtl = NULL;
struct bgpevpn *vpn = (struct bgpevpn *)bucket->data;
char buf1[10];
char buf2[RD_ADDRSTRLEN];
char rt_buf[25];
char *ecom_str;
struct listnode *node, *nnode;
@ -1065,9 +1055,7 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
json_object_string_add(json_vni, "type", "L2");
json_object_string_add(json_vni, "inKernel",
is_vni_live(vpn) ? "True" : "False");
json_object_string_add(
json_vni, "rd",
prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
json_object_string_addf(json_vni, "rd", "%pRD", &vpn->prd);
json_object_string_addf(json_vni, "originatorIp", "%pI4",
&vpn->originator_ip);
json_object_string_addf(json_vni, "mcastGroup", "%pI4",
@ -1097,8 +1085,8 @@ static void show_vni_entry(struct hash_bucket *bucket, void *args[])
json_object_string_add(json_vni, "advertiseSviMacIp",
"Disabled");
} else {
vty_out(vty, "%-1s %-10u %-4s %-21s", buf1, vpn->vni, "L2",
prefix_rd2str(&vpn->prd, buf2, RD_ADDRSTRLEN));
vty_out(vty, "%-1s %-10u %-4s %-21pRD", buf1, vpn->vni, "L2",
&vpn->prd);
}
for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) {
@ -2629,7 +2617,6 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
afi_t afi;
safi_t safi;
uint32_t prefix_cnt, path_cnt;
char rd_str[RD_ADDRSTRLEN];
json_object *json_rd = NULL;
int add_rd_to_json = 0;
@ -2637,8 +2624,6 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
safi = SAFI_EVPN;
prefix_cnt = path_cnt = 0;
prefix_rd2str(prd, rd_str, sizeof(rd_str));
rd_dest = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd);
if (!rd_dest)
return;
@ -2651,7 +2636,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json) {
json_rd = json_object_new_object();
json_object_string_add(json_rd, "rd", rd_str);
json_object_string_addf(json_rd, "rd", "%pRD", prd);
}
bgp_dest_unlock_node(rd_dest);
@ -2732,7 +2717,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json) {
if (add_rd_to_json)
json_object_object_add(json, rd_str, json_rd);
json_object_object_addf(json, json_rd, "%pRD", prd);
else {
json_object_free(json_rd);
json_rd = NULL;
@ -3307,7 +3292,6 @@ static void evpn_unset_advertise_autort_rfc8365(struct bgp *bgp)
static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
{
char buf1[RD_ADDRSTRLEN];
char *ecom_str;
struct listnode *node, *nnode;
struct ecommunity *ecom;
@ -3315,8 +3299,7 @@ static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
if (is_vni_configured(vpn)) {
vty_out(vty, " vni %d\n", vpn->vni);
if (is_rd_configured(vpn))
vty_out(vty, " rd %s\n",
prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
vty_out(vty, " rd %pRD\n", &vpn->prd);
if (is_import_rt_configured(vpn)) {
for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode,
@ -5697,7 +5680,6 @@ DEFUN (show_bgp_vrf_l3vni_info,
JSON_STR)
{
char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN];
int idx_vrf = 3;
const char *name = NULL;
struct bgp *bgp = NULL;
@ -5761,8 +5743,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, ecom))
vty_out(vty, "%s ", ecommunity_str(ecom));
vty_out(vty, "\n");
vty_out(vty, " RD: %s\n",
prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN));
vty_out(vty, " RD: %pRD\n", &bgp->vrf_prd);
} else {
json_object_string_add(json, "vrf", name);
json_object_string_addf(json, "local-ip", "%pI4",
@ -5796,9 +5777,7 @@ DEFUN (show_bgp_vrf_l3vni_info,
json_import_rts,
json_object_new_string(ecommunity_str(ecom)));
json_object_object_add(json, "import-rts", json_import_rts);
json_object_string_add(
json, "rd",
prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN));
json_object_string_addf(json, "rd", "%pRD", &bgp->vrf_prd);
}
if (uj)
@ -6271,7 +6250,6 @@ static int vni_cmp(const void **a, const void **b)
void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi)
{
char buf1[RD_ADDRSTRLEN];
char buf2[INET6_ADDRSTRLEN];
if (bgp->advertise_all_vni)
@ -6437,8 +6415,7 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
}
}
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_RD_CFGD))
vty_out(vty, " rd %s\n",
prefix_rd2str(&bgp->vrf_prd, buf1, sizeof(buf1)));
vty_out(vty, " rd %pRD\n", &bgp->vrf_prd);
/* import route-target */
if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_IMPORT_RT_CFGD)) {

View File

@ -743,7 +743,6 @@ static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
safi_t safi;
struct bgp_table *table;
struct bgp *bgp_path;
char buf1[BUFSIZ];
vty_out(vty, " Paths:\n");
LIST_FOREACH (path, &(bnc->paths), nh_thread) {
@ -754,12 +753,13 @@ static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
safi = table->safi;
bgp_path = table->bgp;
if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1));
vty_out(vty, " %d/%d %pBD RD %s %s flags 0x%x\n",
afi, safi, dest, buf1, bgp_path->name_pretty, path->flags);
} else
if (dest->pdest)
vty_out(vty, " %d/%d %pBD RD %pRD %s flags 0x%x\n",
afi, safi, dest,
(struct prefix_rd *)bgp_dest_get_prefix(
dest->pdest),
bgp_path->name_pretty, path->flags);
else
vty_out(vty, " %d/%d %pBD %s flags 0x%x\n",
afi, safi, dest, bgp_path->name_pretty, path->flags);
}

View File

@ -1145,16 +1145,14 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
}
if (BGP_DEBUG(nht, NHT)) {
char buf1[RD_ADDRSTRLEN];
if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1));
if (dest->pdest)
zlog_debug(
"... eval path %d/%d %pBD RD %s %s flags 0x%x",
afi, safi, dest, buf1,
"... eval path %d/%d %pBD RD %pRD %s flags 0x%x",
afi, safi, dest,
(struct prefix_rd *)bgp_dest_get_prefix(
dest->pdest),
bgp_path->name_pretty, path->flags);
} else
else
zlog_debug(
"... eval path %d/%d %pBD %s flags 0x%x",
afi, safi, dest, bgp_path->name_pretty,

View File

@ -211,3 +211,17 @@ void form_auto_rd(struct in_addr router_id,
snprintfrr(buf, sizeof(buf), "%pI4:%hu", &router_id, rd_id);
(void)str2prefix_rd(buf, prd);
}
printfrr_ext_autoreg_p("RD", printfrr_prd);
static ssize_t printfrr_prd(struct fbuf *buf, struct printfrr_eargs *ea,
const void *ptr)
{
char rd_buf[RD_ADDRSTRLEN];
if (!ptr)
return bputs(buf, "(null)");
prefix_rd2str(ptr, rd_buf, sizeof(rd_buf));
return bputs(buf, rd_buf);
}

View File

@ -10083,14 +10083,12 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
dest = parent_ri->net;
if (dest && dest->pdest) {
pdest = dest->pdest;
prefix_rd2str(
(struct prefix_rd *)bgp_dest_get_prefix(
pdest),
buf1, sizeof(buf1));
if (is_pi_family_evpn(parent_ri)) {
vty_out(vty,
" Imported from %s:%pFX, VNI %s",
buf1,
" Imported from %pRD:%pFX, VNI %s",
(struct prefix_rd *)
bgp_dest_get_prefix(
pdest),
(struct prefix_evpn *)
bgp_dest_get_prefix(
dest),
@ -10105,8 +10103,10 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
} else
vty_out(vty,
" Imported from %s:%pFX\n",
buf1,
" Imported from %pRD:%pFX\n",
(struct prefix_rd *)
bgp_dest_get_prefix(
pdest),
(struct prefix_evpn *)
bgp_dest_get_prefix(
dest));
@ -11800,7 +11800,6 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
{
struct bgp_path_info *pi;
int header = 1;
char rdbuf[RD_ADDRSTRLEN];
json_object *json_header = NULL;
json_object *json_paths = NULL;
const struct prefix *p = bgp_dest_get_prefix(bgp_node);
@ -11819,10 +11818,9 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
if (json && !json_paths) {
/* Instantiate json_paths only if path is valid */
json_paths = json_object_new_array();
if (pfx_rd) {
prefix_rd2str(pfx_rd, rdbuf, sizeof(rdbuf));
if (pfx_rd)
json_header = json_object_new_object();
} else
else
json_header = json;
}
@ -11848,7 +11846,8 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
json_object_object_add(json_header, "paths", json_paths);
if (pfx_rd)
json_object_object_add(json, rdbuf, json_header);
json_object_object_addf(json, json_header, "%pRD",
pfx_rd);
}
}
@ -15197,7 +15196,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 rdbuf[RD_ADDRSTRLEN];
/* Network configuration. */
for (pdest = bgp_table_top(bgp->route[afi][safi]); pdest;
@ -15217,10 +15215,9 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
pdest);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
label = decode_label(&bgp_static->label);
vty_out(vty, " network %pFX rd %s", p, rdbuf);
vty_out(vty, " network %pFX rd %pRD", p, prd);
if (safi == SAFI_MPLS_VPN)
vty_out(vty, " label %u", label);
@ -15247,7 +15244,6 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
struct bgp_static *bgp_static;
char buf[PREFIX_STRLEN * 2];
char buf2[SU_ADDRSTRLEN];
char rdbuf[RD_ADDRSTRLEN];
char esi_buf[ESI_STR_LEN];
/* Network configuration. */
@ -15275,7 +15271,6 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
prd = (struct prefix_rd *)bgp_dest_get_prefix(pdest);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
if (p->u.prefix_evpn.route_type == 5) {
char local_buf[PREFIX_STRLEN];
uint8_t family = is_evpn_prefix_ipaddr_v4((
@ -15298,9 +15293,8 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
&bgp_static->gatewayIp.u.prefix, buf2,
sizeof(buf2));
vty_out(vty,
" network %s rd %s ethtag %u label %u esi %s gwip %s routermac %s\n",
buf, rdbuf,
p->u.prefix_evpn.prefix_addr.eth_tag,
" network %s rd %pRD ethtag %u label %u esi %s gwip %s routermac %s\n",
buf, prd, p->u.prefix_evpn.prefix_addr.eth_tag,
decode_label(&bgp_static->label), esi_buf, buf2,
macrouter);

View File

@ -14993,7 +14993,6 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
struct bgp *bgp;
struct listnode *node;
char *vname;
char buf1[INET6_ADDRSTRLEN];
char *ecom_str;
enum vpn_policy_direction dir;
@ -15058,9 +15057,9 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
json_object_new_string(vname));
json_object_object_add(json, "exportToVrfs",
json_export_vrfs);
json_object_string_add(json, "routeDistinguisher",
prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd,
buf1, RD_ADDRSTRLEN));
json_object_string_addf(json, "routeDistinguisher",
"%pRD",
&bgp->vpn_policy[afi].tovpn_rd);
dir = BGP_VPN_POLICY_DIR_TOVPN;
if (bgp->vpn_policy[afi].rtlist[dir]) {
@ -15129,9 +15128,8 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
node, vname))
vty_out(vty, " %s\n", vname);
vty_out(vty, "RD: %s\n",
prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd,
buf1, RD_ADDRSTRLEN));
vty_out(vty, "RD: %pRD\n",
&bgp->vpn_policy[afi].tovpn_rd);
dir = BGP_VPN_POLICY_DIR_TOVPN;
if (bgp->vpn_policy[afi].rtlist[dir]) {
@ -16621,13 +16619,10 @@ static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp,
tovpn_sid_index);
}
if (CHECK_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_RD_SET)) {
char buf[RD_ADDRSTRLEN];
vty_out(vty, "%*srd vpn export %s\n", indent, "",
prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf,
sizeof(buf)));
}
if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET))
vty_out(vty, "%*srd vpn export %pRD\n", indent, "",
&bgp->vpn_policy[afi].tovpn_rd);
if (CHECK_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) {

View File

@ -3913,8 +3913,6 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
}
if (rfg->rd.prefixlen) {
char buf[RD_ADDRSTRLEN];
if (AF_UNIX == rfg->rd.family) {
uint16_t value = 0;
@ -3927,9 +3925,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
value);
} else
vty_out(vty, " rd %s\n",
prefix_rd2str(&rfg->rd, buf,
sizeof(buf)));
vty_out(vty, " rd %pRD\n", &rfg->rd);
}
if (rfg->rt_import_list && rfg->rt_export_list
@ -4137,8 +4133,6 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty_out(vty, " vnc defaults\n");
if (hc->default_rd.prefixlen) {
char buf[RD_ADDRSTRLEN];
if (AF_UNIX == hc->default_rd.family) {
uint16_t value = 0;
@ -4151,10 +4145,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
value);
} else
vty_out(vty, " rd %s\n",
prefix_rd2str(&hc->default_rd,
buf,
sizeof(buf)));
vty_out(vty, " rd %pRD\n",
&hc->default_rd);
}
if (hc->default_response_lifetime
!= BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT) {
@ -4219,8 +4211,6 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
if (rfg->rd.prefixlen) {
char buf[RD_ADDRSTRLEN];
if (AF_UNIX == rfg->rd.family) {
uint16_t value = 0;
@ -4235,10 +4225,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
value);
} else
vty_out(vty, " rd %s\n",
prefix_rd2str(
&rfg->rd, buf,
sizeof(buf)));
vty_out(vty, " rd %pRD\n",
&rfg->rd);
}
if (rfg->flags & RFAPI_RFG_RESPONSE_LIFETIME) {
vty_out(vty, " response-lifetime ");

View File

@ -362,7 +362,6 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
afi_t afi; /* of the VN address */
struct bgp_dest *bn;
struct bgp_path_info *bpi;
char buf2[RD_ADDRSTRLEN];
struct prefix_rd prd0;
afi = family2afi(p->family);
@ -377,9 +376,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
vnc_zlog_debug_verbose(
"%s: peer=%p, prefix=%pFX, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
__func__, peer, p, prefix_rd2str(prd, buf2, sizeof(buf2)), afi,
safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
"%s: peer=%p, prefix=%pFX, prd=%pRD afi=%d, safi=%d bn=%p, bn->info=%p",
__func__, peer, p, prd, afi, safi, bn,
(bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
bpi = bpi->next) {
@ -577,7 +576,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
struct bgp_attr_encap_subtlv *encaptlv;
char buf[PREFIX_STRLEN];
char buf2[RD_ADDRSTRLEN];
struct rfapi_nexthop *lnh = NULL; /* local nexthop */
struct rfapi_vn_option *vo;
@ -616,8 +614,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
else
label_val = MPLS_LABEL_IMPLICIT_NULL;
prefix_rd2str(prd, buf2, sizeof(buf2));
afi = family2afi(p->family);
assert(afi == AFI_IP || afi == AFI_IP6);
@ -1070,8 +1066,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
bgp_process(bgp, bn, afi, safi);
vnc_zlog_debug_any(
"%s: Added route (safi=%s) at prefix %s (bn=%p, prd=%s)",
__func__, safi2str(safi), buf, bn, buf2);
"%s: Added route (safi=%s) at prefix %s (bn=%p, prd=%pRD)",
__func__, safi2str(safi), buf, bn, prd);
done:
/* Loop back to import tables */
@ -3724,12 +3720,7 @@ int rfapi_set_autord_from_vn(struct prefix_rd *rd, struct rfapi_ip_addr *vn)
memcpy(rd->val + 2, &vn->addr.v6.s6_addr32[3],
4); /* low order 4 bytes */
}
{
char buf[RD_ADDRSTRLEN];
vnc_zlog_debug_verbose("%s: auto-RD is set to %s", __func__,
prefix_rd2str(rd, buf, sizeof(buf)));
}
vnc_zlog_debug_verbose("%s: auto-RD is set to %pRD", __func__, rd);
return 0;
}

View File

@ -2091,14 +2091,8 @@ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */
assert(bpi);
assert(bpi->extra);
{
char buf[RD_ADDRSTRLEN];
vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %s", __func__,
bpi, bpi->peer,
prefix_rd2str(&bpi->extra->vnc.import.rd,
buf, sizeof(buf)));
}
vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %pRD", __func__, bpi,
bpi->peer, &bpi->extra->vnc.import.rd);
sl = RFAPI_RDINDEX_W_ALLOC(rn);
if (!sl) {
@ -2164,7 +2158,6 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
#ifdef DEBUG_BI_SEARCH
{
char buf[RD_ADDRSTRLEN];
char buf_aux_pfx[PREFIX_STRLEN];
if (aux_prefix) {
@ -2173,10 +2166,9 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
} else
strlcpy(buf_aux_pfx, "(nil)", sizeof(buf_aux_pfx));
vnc_zlog_debug_verbose("%s want prd=%s, peer=%p, aux_prefix=%s",
__func__,
prefix_rd2str(prd, buf, sizeof(buf)),
peer, buf_aux_pfx);
vnc_zlog_debug_verbose(
"%s want prd=%pRD, peer=%p, aux_prefix=%s", __func__,
prd, peer, buf_aux_pfx);
rfapiItBiIndexDump(rn);
}
#endif
@ -2190,16 +2182,10 @@ static struct bgp_path_info *rfapiItBiIndexSearch(
for (bpi_result = rn->info; bpi_result;
bpi_result = bpi_result->next) {
#ifdef DEBUG_BI_SEARCH
{
char buf[RD_ADDRSTRLEN];
vnc_zlog_debug_verbose(
"%s: bpi has prd=%s, peer=%p", __func__,
prefix_rd2str(&bpi_result->extra->vnc
.import.rd,
buf, sizeof(buf)),
bpi_result->peer);
}
vnc_zlog_debug_verbose(
"%s: bpi has prd=%pRD, peer=%p", __func__,
&bpi_result->extra->vnc.import.rd,
bpi_result->peer);
#endif
if (peer == bpi_result->peer
&& !prefix_cmp((struct prefix *)&bpi_result->extra
@ -2261,14 +2247,8 @@ static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */
struct skiplist *sl;
int rc;
{
char buf[RD_ADDRSTRLEN];
vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %s", __func__,
bpi, bpi->peer,
prefix_rd2str(&bpi->extra->vnc.import.rd,
buf, sizeof(buf)));
}
vnc_zlog_debug_verbose("%s: bpi %p, peer %p, rd %pRD", __func__, bpi,
bpi->peer, &bpi->extra->vnc.import.rd);
sl = RFAPI_RDINDEX(rn);
assert(sl);

View File

@ -1104,9 +1104,6 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
__func__, ri);
} else {
char buf_rd[RD_ADDRSTRLEN];
/* not found: add new route to RIB */
ori = rfapi_info_new();
ori->rk = ri->rk;
@ -1129,16 +1126,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
}
skiplist_insert(slRibPt, &ori->rk, ori);
#if DEBUG_RIB_SL_RD
prefix_rd2str(&ori->rk.rd, buf_rd,
sizeof(buf_rd));
#else
buf_rd[0] = 0;
#endif
vnc_zlog_debug_verbose(
"%s: nomatch lPendCost item %p in slRibPt, added (rd=%s)",
__func__, ri, buf_rd);
"%s: nomatch lPendCost item %p in slRibPt, added (rd=%pRD)",
__func__, ri, &ori->rk.rd);
}
/*
@ -1378,17 +1368,9 @@ callback:
0, delete_list->count);
ri->last_sent_time = monotime(NULL);
#if DEBUG_RIB_SL_RD
{
char buf_rd[RD_ADDRSTRLEN];
vnc_zlog_debug_verbose(
"%s: move route to recently deleted list, rd=%s",
__func__,
prefix_rd2str(
&ri->rk.rd,
buf_rd,
sizeof(buf_rd)));
}
vnc_zlog_debug_verbose(
"%s: move route to recently deleted list, rd=%pRD",
__func__, &ri->rk.rd);
#endif
} else {
@ -2256,7 +2238,6 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty,
char str_lifetime[BUFSIZ];
char str_age[BUFSIZ];
char *p;
char str_rd[RD_ADDRSTRLEN];
++routes_displayed;
@ -2284,14 +2265,9 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty,
}
#endif
str_rd[0] = 0; /* start empty */
#if DEBUG_RIB_SL_RD
prefix_rd2str(&ri->rk.rd, str_rd, sizeof(str_rd));
#endif
fp(out, " %c %-20s %-15s %-15s %-4u %-8s %-8s %s\n",
fp(out, " %c %-20s %-15s %-15s %-4u %-8s %-8s %pRD\n",
deleted ? 'r' : ' ', *printedprefix ? "" : str_pfx, str_vn,
str_un, ri->cost, str_lifetime, str_age, str_rd);
str_un, ri->cost, str_lifetime, str_age, &ri->rk.rd);
if (!*printedprefix)
*printedprefix = 1;

View File

@ -1537,14 +1537,6 @@ void rfapiPrintRfapiIpPrefix(void *stream, struct rfapi_ip_prefix *p)
fp(out, "?/?:?");
}
void rfapiPrintRd(struct vty *vty, struct prefix_rd *prd)
{
char buf[RD_ADDRSTRLEN];
prefix_rd2str(prd, buf, sizeof(buf));
vty_out(vty, "%s", buf);
}
void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd,
safi_t safi, struct prefix *p)
{
@ -1615,7 +1607,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
vty_out(vty, " ");
rfapiPrintRfapiIpAddr(vty, &rfd->vn_addr);
vty_out(vty, " %p %p ", rfd->response_cb, rfd->cookie);
rfapiPrintRd(vty, &rfd->rd);
vty_out(vty, "%pRD", &rfd->rd);
vty_out(vty, " %d", rfd->response_lifetime);
vty_out(vty, " %s", (rfd->rfg ? rfd->rfg->name : "<orphaned>"));
vty_out(vty, "%s", HVTYNL);

View File

@ -93,8 +93,6 @@ extern void rfapiPrintRfapiIpAddr(void *stream, struct rfapi_ip_addr *a);
extern void rfapiPrintRfapiIpPrefix(void *stream, struct rfapi_ip_prefix *p);
void rfapiPrintRd(struct vty *vty, struct prefix_rd *prd);
extern void rfapiPrintAdvertisedInfo(struct vty *vty,
struct rfapi_descriptor *rfd, safi_t safi,
struct prefix *p);

View File

@ -674,6 +674,7 @@ static inline bool ipv4_mcast_ssm(const struct in_addr *addr)
#pragma FRR printfrr_ext "%pFX" (struct prefix_eth *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_evpn *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_fs *)
#pragma FRR printfrr_ext "%pRD" (struct prefix_rd *)
#pragma FRR printfrr_ext "%pPSG4" (struct prefix_sg *)
#endif