lib: Convert usage of strings to %pFX and %pRN

Convert over to using the %pFX and %pRN modifiers
to output strings to allow us to consolidate on
one standard for printing prefixes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2020-10-14 12:57:14 -04:00
parent c10e14e96d
commit b219dda129
3 changed files with 17 additions and 60 deletions

View file

@ -826,7 +826,7 @@ DEFUN (show_address,
p = ifc->address;
if (p->family == AF_INET)
vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
vty_out (vty, "%pFX\n", p);
}
}
return CMD_SUCCESS;
@ -858,7 +858,7 @@ DEFUN (show_address_vrf_all,
p = ifc->address;
if (p->family == AF_INET)
vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
vty_out (vty, "%pFX\n", p);
}
}
}
@ -929,10 +929,9 @@ connected_log(struct connected *connected, char *str)
p = connected->address;
vrf = vrf_lookup_by_id(ifp->vrf_id);
snprintf(logbuf, sizeof(logbuf), "%s interface %s vrf %s(%u) %s %s/%d ",
snprintf(logbuf, sizeof(logbuf), "%s interface %s vrf %s(%u) %s %pFX ",
str, ifp->name, VRF_LOGNAME(vrf), ifp->vrf_id,
prefix_family_str(p),
inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen);
prefix_family_str(p), p);
p = connected->destination;
if (p) {
@ -949,14 +948,12 @@ nbr_connected_log(struct nbr_connected *connected, char *str)
struct prefix *p;
struct interface *ifp;
char logbuf[BUFSIZ];
char buf[BUFSIZ];
ifp = connected->ifp;
p = connected->address;
snprintf(logbuf, sizeof(logbuf), "%s interface %s %s %s/%d ", str,
ifp->name, prefix_family_str(p),
inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen);
snprintf(logbuf, sizeof(logbuf), "%s interface %s %s %pFX ", str,
ifp->name, prefix_family_str(p), p);
zlog_info("%s", logbuf);
}

View file

@ -901,14 +901,11 @@ static void __attribute__((unused)) prefix_list_print(struct prefix_list *plist)
printf("any %s\n", prefix_list_type_str(pentry));
else {
struct prefix *p;
char buf[BUFSIZ];
p = &pentry->prefix;
printf(" seq %lld %s %s/%d", (long long)pentry->seq,
prefix_list_type_str(pentry),
inet_ntop(p->family, p->u.val, buf, BUFSIZ),
p->prefixlen);
printf(" seq %lld %s %pFX", (long long)pentry->seq,
prefix_list_type_str(pentry), p);
if (pentry->ge)
printf(" ge %d", pentry->ge);
if (pentry->le)
@ -1014,12 +1011,8 @@ static void vty_show_prefix_entry(struct vty *vty, afi_t afi,
vty_out(vty, "any");
else {
struct prefix *p = &pentry->prefix;
char buf[BUFSIZ];
vty_out(vty, "%s/%d",
inet_ntop(p->family, p->u.val, buf,
BUFSIZ),
p->prefixlen);
vty_out(vty, "%pFX", p);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
@ -1121,12 +1114,8 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,
vty_out(vty, "any");
else {
struct prefix *pf = &pentry->prefix;
char buf[BUFSIZ];
vty_out(vty, "%s/%d",
inet_ntop(pf->family, pf->u.val, buf,
BUFSIZ),
pf->prefixlen);
vty_out(vty, "%pFX", pf);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
@ -1491,11 +1480,8 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
for (pentry = plist->head; pentry; pentry = pentry->next) {
struct prefix *p = &pentry->prefix;
char buf_a[BUFSIZ];
char buf_b[BUFSIZ];
snprintf(buf_a, sizeof(buf_a), "%s/%d",
inet_ntop(p->family, p->u.val, buf_b, BUFSIZ),
p->prefixlen);
snprintf(buf_a, sizeof(buf_a), "%pFX", p);
json_object_int_add(json_list, "seq", pentry->seq);
json_object_string_add(json_list, "seqPrefixListType",
@ -1526,13 +1512,9 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
for (pentry = plist->head; pentry; pentry = pentry->next) {
struct prefix *p = &pentry->prefix;
char buf[BUFSIZ];
vty_out(vty, " seq %" PRId64 " %s %s/%d",
pentry->seq,
prefix_list_type_str(pentry),
inet_ntop(p->family, p->u.val, buf, BUFSIZ),
p->prefixlen);
vty_out(vty, " seq %" PRId64 " %s %pFX", pentry->seq,
prefix_list_type_str(pentry), p);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);

View file

@ -3156,8 +3156,6 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
struct list *rmap_index_list = NULL;
struct listnode *ln = NULL, *nln = NULL;
struct route_map_index *index = NULL;
struct prefix *p = NULL, *pp = NULL;
char buf[SU_ADDRSTRLEN], pbuf[SU_ADDRSTRLEN];
uint8_t len = 54;
vty_out(vty, "%s:\n", frr_protonameinst);
@ -3171,23 +3169,13 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
"____________________");
for (rn = route_top(rm_pfx_tbl4); rn;
rn = route_next(rn)) {
p = &rn->p;
vty_out(vty, " %s/%d (%d)\n",
inet_ntop(p->family, &p->u.prefix, buf,
SU_ADDRSTRLEN),
p->prefixlen,
vty_out(vty, " %pRN (%d)\n", rn,
route_node_get_lock_count(rn));
vty_out(vty, "(P) ");
prn = rn->parent;
if (prn) {
pp = &prn->p;
vty_out(vty, "%s/%d\n",
inet_ntop(pp->family,
&pp->u.prefix, pbuf,
SU_ADDRSTRLEN),
pp->prefixlen);
vty_out(vty, "%pRN\n", prn);
}
vty_out(vty, "\n");
@ -3216,23 +3204,13 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
"____________________");
for (rn = route_top(rm_pfx_tbl6); rn;
rn = route_next(rn)) {
p = &rn->p;
vty_out(vty, " %s/%d (%d)\n",
inet_ntop(p->family, &p->u.prefix, buf,
SU_ADDRSTRLEN),
p->prefixlen,
vty_out(vty, " %pRN (%d)\n", rn,
route_node_get_lock_count(rn));
vty_out(vty, "(P) ");
prn = rn->parent;
if (prn) {
pp = &prn->p;
vty_out(vty, "%s/%d\n",
inet_ntop(pp->family,
&pp->u.prefix, pbuf,
SU_ADDRSTRLEN),
pp->prefixlen);
vty_out(vty, "%pRN\n", prn);
}
vty_out(vty, "\n");