From 6f214dd377588ffc44224c07ad3839c36051178c Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 13 Jun 2019 17:55:38 -0700 Subject: [PATCH] bgpd: print ecom in evpn route output EVPN route's extended community include important informations like Mobility sequence, router mac, and RT values, include the ecomm in evpn brief output. Ticket:CM-25353 Testing Done: Validated in evpn deployment with routes. TOR#show bgp l2vpn evpn route ... Network Next Hop Metric LocPrf Weight Path Extended Community Route Distinguisher: 27.0.0.11:3 *> [2]:[0]:[0]:[48]:[00:02:00:00:00:04]:[128]:[fe80::202:ff:fe00:4] 36.0.0.11 0 4435 5546 i RT:5546:1008 ET:8 ND:Router Flag * [2]:[0]:[0]:[48]:[00:02:00:00:00:36] 36.0.0.11 0 4435 5546 i RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01 *> [2]:[0]:[0]:[48]:[00:02:00:00:00:36] 36.0.0.11 0 4435 5546 i RT:5546:1008 RT:5546:4003 ET:8 MM:0, sticky MAC Rmac:44:38:39:ff:ff:01 * [3]:[0]:[32]:[36.0.0.11] 36.0.0.11 0 4435 5546 i RT:5546:1008 ET:8 *> [3]:[0]:[32]:[36.0.0.11] 36.0.0.11 0 4435 5546 i RT:5546:1008 ET:8 Signed-off-by: Chirag Shah --- bgpd/bgp_evpn_vty.c | 2 ++ bgpd/bgp_route.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index ca6edffab0..44e9375dc9 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -2480,6 +2480,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, bgp_evpn_show_route_header(vty, bgp, tbl_ver, json); + vty_out(vty, "%19s Extended Community\n" + , " "); header = 0; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4ae018698d..3e9afe0392 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6965,6 +6965,7 @@ void route_vty_out(struct vty *vty, struct prefix *p, json_object *json_nexthops = NULL; json_object *json_nexthop_global = NULL; json_object *json_nexthop_ll = NULL; + json_object *json_ext_community = NULL; char vrf_id_str[VRF_NAMSIZ] = {0}; bool nexthop_self = CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false; @@ -7330,6 +7331,17 @@ void route_vty_out(struct vty *vty, struct prefix *p, vty_out(vty, "%s", bgp_origin_str[attr->origin]); if (json_paths) { + if (safi == SAFI_EVPN && + attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) { + json_ext_community = json_object_new_object(); + json_object_string_add(json_ext_community, + "string", + attr->ecommunity->str); + json_object_object_add(json_path, + "extendedCommunity", + json_ext_community); + } + if (nexthop_self) json_object_boolean_true_add(json_path, "announceNexthopSelf"); @@ -7363,6 +7375,13 @@ void route_vty_out(struct vty *vty, struct prefix *p, json_object_array_add(json_paths, json_path); } else { vty_out(vty, "\n"); + + if (safi == SAFI_EVPN && + attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)) { + vty_out(vty, "%*s", 20, " "); + vty_out(vty, "%s\n", attr->ecommunity->str); + } + #if ENABLE_BGP_VNC /* prints an additional line, indented, with VNC info, if * present */ -- 2.39.5