From 8b3e765d19158e3be146304d40d0563bf945310d Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 10 Oct 2023 16:44:34 -0400 Subject: [PATCH] Revert "bgpd, lib: extend the size of the prefix string buffer" This reverts commit bdb3fa3b9216aede64c5b982011fb04ef25c67f7. --- bgpd/bgp_route.c | 10 +++++----- bgpd/bgp_table.c | 2 +- lib/prefix.c | 6 +++--- lib/prefix.h | 5 ----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7d85980d74..b22b0bafe0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1581,7 +1581,7 @@ static enum filter_type bgp_input_filter(struct peer *peer, done: if (frrtrace_enabled(frr_bgp, input_filter)) { - char pfxprint[PREFIX_STRLEN_EXTENDED]; + char pfxprint[PREFIX2STR_BUFFER]; prefix2str(p, pfxprint, sizeof(pfxprint)); frrtrace(5, frr_bgp, input_filter, peer, pfxprint, afi, safi, @@ -1638,7 +1638,7 @@ static enum filter_type bgp_output_filter(struct peer *peer, } if (frrtrace_enabled(frr_bgp, output_filter)) { - char pfxprint[PREFIX_STRLEN_EXTENDED]; + char pfxprint[PREFIX2STR_BUFFER]; prefix2str(p, pfxprint, sizeof(pfxprint)); frrtrace(5, frr_bgp, output_filter, peer, pfxprint, afi, safi, @@ -2712,7 +2712,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest, int paths_eq, do_mpath; bool debug; struct list mp_list; - char pfx_buf[PREFIX_STRLEN_EXTENDED] = {}; + char pfx_buf[PREFIX2STR_BUFFER] = {}; char path_buf[PATH_ADDPATH_STR_BUFFER]; bgp_mp_list_init(&mp_list); @@ -4167,7 +4167,7 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, int allowas_in = 0; if (frrtrace_enabled(frr_bgp, process_update)) { - char pfxprint[PREFIX_STRLEN_EXTENDED]; + char pfxprint[PREFIX2STR_BUFFER]; prefix2str(p, pfxprint, sizeof(pfxprint)); frrtrace(6, frr_bgp, process_update, peer, pfxprint, addpath_id, @@ -8772,7 +8772,7 @@ static void route_vty_out_route(struct bgp_dest *dest, const struct prefix *p, struct vty *vty, json_object *json, bool wide) { int len = 0; - char buf[PREFIX_STRLEN_EXTENDED]; + char buf[INET6_ADDRSTRLEN]; if (p->family == AF_INET) { if (!json) { diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index e01bf39113..b9265dd81b 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -63,7 +63,7 @@ struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest) const char *bgp_dest_get_prefix_str(struct bgp_dest *dest) { const struct prefix *p = NULL; - static char str[PREFIX_STRLEN_EXTENDED] = {0}; + static char str[PREFIX_STRLEN] = {0}; p = bgp_dest_get_prefix(dest); if (p) diff --git a/lib/prefix.c b/lib/prefix.c index cde8677cf0..e7ce8f23ab 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1166,7 +1166,7 @@ const char *bgp_linkstate_nlri_type_2str(uint16_t nlri_type) const char *prefix2str(union prefixconstptr pu, char *str, int size) { const struct prefix *p = pu.p; - char buf[PREFIX_STRLEN_EXTENDED]; + char buf[PREFIX2STR_BUFFER]; int byte, tmp, a, b; bool z = false; size_t l; @@ -1234,7 +1234,7 @@ const char *prefix2str(union prefixconstptr pu, char *str, int size) static ssize_t prefixhost2str(struct fbuf *fbuf, union prefixconstptr pu) { const struct prefix *p = pu.p; - char buf[PREFIX_STRLEN_EXTENDED]; + char buf[PREFIX2STR_BUFFER]; switch (p->family) { case AF_INET: @@ -1752,7 +1752,7 @@ static ssize_t printfrr_pfx(struct fbuf *buf, struct printfrr_eargs *ea, if (host_only) return prefixhost2str(buf, (struct prefix *)ptr); else { - char cbuf[PREFIX_STRLEN_EXTENDED]; + char cbuf[PREFIX_STRLEN]; prefix2str(ptr, cbuf, sizeof(cbuf)); return bputs(buf, cbuf); diff --git a/lib/prefix.h b/lib/prefix.h index f1aff43689..dacdbf9059 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -347,11 +347,6 @@ union prefixconstptr { /* Maximum string length of the result of prefix2str */ #define PREFIX_STRLEN 80 -/* Maximum string length of the result of prefix2str for - * long string prefixes (eg. BGP Link-State) - */ -#define PREFIX_STRLEN_EXTENDED 512 - /* * Longest possible length of a (S,G) string is 34 bytes * 123.123.123.123 = 15 * 2 -- 2.39.5