Commit 7979039418 for frr
commit 797903941833623059f9b0526059c2068d5242f3
Author: Enke Chen <enchen@paloaltonetworks.com>
Date: Thu Nov 5 14:58:17 2026 -0800
bgpd: add community attributes to advertised-routes JSON output
The route_vty_out_tmp() function is used for displaying routes in
'show bgp neighbor X advertised-routes json' output. Add community,
extended community, and large community attributes to the JSON output
so that these attributes are visible in the advertised-routes display.
Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 8353c808f8..2e512e9eaf 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -13302,6 +13302,37 @@ void route_vty_out_tmp(struct vty *vty, struct bgp *bgp, struct bgp_dest *dest,
json_object_string_add(
json_net, "origin",
bgp_origin_long_str[attr->origin]);
+
+ /* Print community */
+ if (bgp_attr_get_community(attr)) {
+ if (!bgp_attr_get_community(attr)->json)
+ community_str(bgp_attr_get_community(attr), true);
+ json_object_lock(bgp_attr_get_community(attr)->json);
+ json_object_object_add(json_net, "community",
+ bgp_attr_get_community(attr)->json);
+ }
+
+ /* Print extended community */
+ if (bgp_attr_get_ecommunity(attr)) {
+ struct json_object *json_ext_community;
+
+ if (!bgp_attr_get_ecommunity(attr)->str)
+ ecommunity_str(bgp_attr_get_ecommunity(attr));
+ json_ext_community = json_object_new_object();
+ json_object_string_add(json_ext_community, "string",
+ bgp_attr_get_ecommunity(attr)->str);
+ json_object_object_add(json_net, "extendedCommunity",
+ json_ext_community);
+ }
+
+ /* Print large community */
+ if (bgp_attr_get_lcommunity(attr)) {
+ if (!bgp_attr_get_lcommunity(attr)->json)
+ lcommunity_str(bgp_attr_get_lcommunity(attr), true);
+ json_object_lock(bgp_attr_get_lcommunity(attr)->json);
+ json_object_object_add(json_net, "largeCommunity",
+ bgp_attr_get_lcommunity(attr)->json);
+ }
} else if (safi == SAFI_UNREACH) {
/* Skip nexthop display for SAFI_UNREACH */
} else {