From 085225812322e7667260dfb446fae31fe5edd4b6 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 9 Jan 2025 18:24:39 +0100 Subject: [PATCH 1/2] bgpd: fix bgp orf prefix-list json prefix 0x
FX was displayed instead of the prefix. Fixes: b219dda129 ("lib: Convert usage of strings to %pFX and %pRN") Signed-off-by: Louis Scalbert (cherry picked from commit b7e843d7e8afe57d3815dbb44e30307654e73711) --- lib/plist.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/plist.c b/lib/plist.c index 5f52e27d18ec..5911d961cc6a 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1544,11 +1544,6 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, plist->name); for (pentry = plist->head; pentry; pentry = pentry->next) { - struct prefix *p = &pentry->prefix; - char buf_a[BUFSIZ]; - - snprintf(buf_a, sizeof(buf_a), "%pFX", p); - json_object_int_add(json_list, "seq", pentry->seq); json_object_string_add(json_list, "seqPrefixListType", prefix_list_type_str(pentry)); @@ -1560,7 +1555,7 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, json_object_int_add(json_list, "le", pentry->le); - json_object_object_add(json_prefix, buf_a, json_list); + json_object_object_addf(json_prefix, json_list, "%pFX", &pentry->prefix); } if (afi == AFI_IP) json_object_object_add(json, "ipPrefixList", From ac7db8ff709bb2c7e1dd7c26d5f9a97bdf737181 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 9 Jan 2025 18:28:53 +0100 Subject: [PATCH 2/2] bgpd: fix crash in displaying json orf prefix-list bgpd crashes when there is several entries in the prefix-list. No backtrace is provided because the issue was catched from a code review. Fixes: 856ca177c4 ("Added json formating support to show-...-neighbors-... bgp commands.") Signed-off-by: Louis Scalbert (cherry picked from commit 8ccf60921b85893d301186a0f8156fb702da379f) --- lib/plist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plist.c b/lib/plist.c index 5911d961cc6a..a5ddc91bae07 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1536,7 +1536,6 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, if (use_json) { json = json_object_new_object(); json_prefix = json_object_new_object(); - json_list = json_object_new_object(); json_object_int_add(json_prefix, "prefixListCounter", plist->count); @@ -1544,6 +1543,8 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, plist->name); for (pentry = plist->head; pentry; pentry = pentry->next) { + json_list = json_object_new_object(); + json_object_int_add(json_list, "seq", pentry->seq); json_object_string_add(json_list, "seqPrefixListType", prefix_list_type_str(pentry));