bgpd: fix format string mess in AS-path printing

This was done *very* weirdly.  Make it slightly less so.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2023-01-26 14:45:11 +01:00
parent e59bd527e9
commit e678b143a9
3 changed files with 9 additions and 14 deletions

View File

@ -2122,16 +2122,12 @@ const char *aspath_print(struct aspath *as)
}
/* Printing functions */
/* Feed the AS_PATH to the vty; the suffix string follows it only in case
/* Feed the AS_PATH to the vty; the space suffix follows it only in case
* AS_PATH wasn't empty.
*/
void aspath_print_vty(struct vty *vty, const char *format, struct aspath *as,
const char *suffix)
void aspath_print_vty(struct vty *vty, struct aspath *as)
{
assert(format);
vty_out(vty, format, as->str);
if (as->str_len && strlen(suffix))
vty_out(vty, "%s", suffix);
vty_out(vty, "%s%s", as->str, as->str_len ? " " : "");
}
static void aspath_show_all_iterator(struct hash_bucket *bucket,

View File

@ -104,8 +104,7 @@ extern void aspath_free(struct aspath *aspath);
extern struct aspath *aspath_intern(struct aspath *aspath);
extern void aspath_unintern(struct aspath **aspath);
extern const char *aspath_print(struct aspath *aspath);
extern void aspath_print_vty(struct vty *vty, const char *format,
struct aspath *aspath, const char *suffix);
extern void aspath_print_vty(struct vty *vty, struct aspath *aspath);
extern void aspath_print_all_vty(struct vty *vty);
extern unsigned int aspath_key_make(const void *p);
extern unsigned int aspath_get_first_as(struct aspath *aspath);

View File

@ -9483,7 +9483,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
json_object_string_add(json_path, "path",
attr->aspath->str);
else
aspath_print_vty(vty, "%s", attr->aspath, " ");
aspath_print_vty(vty, attr->aspath);
}
/* Print origin */
@ -9701,7 +9701,7 @@ CPP_NOTICE("Drop `bgpOriginCodes` from JSON outputs")
/* Print aspath */
if (attr->aspath)
aspath_print_vty(vty, "%s", attr->aspath, " ");
aspath_print_vty(vty, attr->aspath);
/* Print origin */
vty_out(vty, "%s", bgp_origin_str[attr->origin]);
@ -9968,7 +9968,7 @@ static void damp_route_vty_out(struct vty *vty, const struct prefix *p,
use_json, NULL));
if (attr->aspath)
aspath_print_vty(vty, "%s", attr->aspath, " ");
aspath_print_vty(vty, attr->aspath);
vty_out(vty, "%s", bgp_origin_str[attr->origin]);
@ -10045,7 +10045,7 @@ static void flap_route_vty_out(struct vty *vty, const struct prefix *p,
vty_out(vty, "%*s ", 8, " ");
if (attr->aspath)
aspath_print_vty(vty, "%s", attr->aspath, " ");
aspath_print_vty(vty, attr->aspath);
vty_out(vty, "%s", bgp_origin_str[attr->origin]);
@ -10329,7 +10329,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
attr->aspath->json);
} else {
if (attr->aspath->segments)
aspath_print_vty(vty, " %s", attr->aspath, "");
vty_out(vty, " %s", attr->aspath->str);
else
vty_out(vty, " Local");
}