Merge pull request #17807 from louis-6wind/fix-bgp-orf-crash

bgpd: fix crash in displaying json orf prefix-list
This commit is contained in:
Donatas Abraitis 2025-01-09 22:57:51 +02:00 committed by GitHub
commit 0b48c8e134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1536,7 +1536,6 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
if (use_json) { if (use_json) {
json = json_object_new_object(); json = json_object_new_object();
json_prefix = json_object_new_object(); json_prefix = json_object_new_object();
json_list = json_object_new_object();
json_object_int_add(json_prefix, "prefixListCounter", json_object_int_add(json_prefix, "prefixListCounter",
plist->count); plist->count);
@ -1544,10 +1543,7 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
plist->name); plist->name);
for (pentry = plist->head; pentry; pentry = pentry->next) { for (pentry = plist->head; pentry; pentry = pentry->next) {
struct prefix *p = &pentry->prefix; json_list = json_object_new_object();
char buf_a[BUFSIZ];
snprintf(buf_a, sizeof(buf_a), "%pFX", p);
json_object_int_add(json_list, "seq", pentry->seq); json_object_int_add(json_list, "seq", pentry->seq);
json_object_string_add(json_list, "seqPrefixListType", json_object_string_add(json_list, "seqPrefixListType",
@ -1560,7 +1556,7 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
json_object_int_add(json_list, "le", json_object_int_add(json_list, "le",
pentry->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) if (afi == AFI_IP)
json_object_object_add(json, "ipPrefixList", json_object_object_add(json, "ipPrefixList",