diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2023-01-26 14:45:11 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2023-01-27 12:01:20 +0100 |
commit | e678b143a9b715a008dd988b2da0ca15da919bc0 (patch) | |
tree | 5625022bce39f3adef722fce11c200ce9c190f68 /bgpd | |
parent | lib: literal constant format string for termtable (diff) | |
download | frr-e678b143a9b715a008dd988b2da0ca15da919bc0.tar.xz frr-e678b143a9b715a008dd988b2da0ca15da919bc0.zip |
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_aspath.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_aspath.h | 3 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 10 |
3 files changed, 9 insertions, 14 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 85f09ccf0..2ae693cd3 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -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, diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index 97bc7c0ac..a814d73dd 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -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); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3f07e53bb..988a8bad0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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"); } |