From 5e4d4c8aa4899d49b0f4f620d0db21c6633be376 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Sat, 28 Mar 2020 10:15:06 -0700 Subject: [PATCH] bgpd: local path changes to display the SYNC info Sample output - root@torm-11:mgmt:~# net show bgp l2vpn evpn route vni 1000 mac 00:00:00:00:00:11 BGP routing table entry for [2]:[0]:[48]:[00:00:00:00:00:11] Paths: (5 available, best #5) Not advertised to any peer Route [2]:[0]:[48]:[00:00:00:00:00:11] VNI 1000 Imported from 27.0.0.16:14:[2]:[0]:[48]:[00:00:00:00:00:11], VNI 1000 4435 5551 27.0.0.16 from spine-2(swp4) (27.0.0.14) ESI 03:00:00:00:00:01:11:00:00:01 local-es Origin IGP, valid, external Extended Community: RT:5551:1000 RT:5551:4001 ET:8 Rmac:00:02:00:00:00:2d Last update: Fri Mar 27 02:26:35 2020 >>>>>>>>>>>>>>>>>>>> SNIP >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Route [2]:[0]:[48]:[00:00:00:00:00:11] VNI 1000/4001 Local 27.0.0.15 from 0.0.0.0 (27.0.0.15) ESI 03:00:00:00:00:01:11:00:00:01 local-es peer-info: (active MM: 0) >>> Origin IGP, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (EVPN local ES path) Extended Community: ET:8 RT:5550:1000 RT:5550:4001 Rmac:00:02:00:00:00:25 Last update: Fri Mar 27 02:26:35 2020 Displayed 5 paths for requested prefix root@torm-11:mgmt:~# Signed-off-by: Anuradha Karuppiah --- bgpd/bgp_route.c | 77 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 37a98c10ce98..80ffa18424cd 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8738,9 +8738,67 @@ static const char *bgp_path_selection_reason2str( return "Invalid (internal error)"; } -void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, - struct bgp_path_info *path, afi_t afi, safi_t safi, - json_object *json_paths) +static void route_vty_out_detail_es_info(struct vty *vty, + struct attr *attr, json_object *json_path) +{ + char esi_buf[ESI_STR_LEN]; + bool es_local = !!CHECK_FLAG(attr->es_flags, ATTR_ES_IS_LOCAL); + bool peer_router = !!CHECK_FLAG(attr->es_flags, + ATTR_ES_PEER_ROUTER); + bool peer_active = !!CHECK_FLAG(attr->es_flags, + ATTR_ES_PEER_ACTIVE); + bool peer_proxy = !!CHECK_FLAG(attr->es_flags, + ATTR_ES_PEER_PROXY); + + esi_to_str(&attr->esi, esi_buf, sizeof(esi_buf)); + if (json_path) { + json_object *json_es_info = NULL; + + json_object_string_add( + json_path, "esi", + esi_buf); + if (es_local || bgp_evpn_attr_is_sync(attr)) { + json_es_info = json_object_new_object(); + if (es_local) + json_object_boolean_true_add( + json_es_info, "localEs"); + if (peer_active) + json_object_boolean_true_add( + json_es_info, "peerActive"); + if (peer_proxy) + json_object_boolean_true_add( + json_es_info, "peerProxy"); + if (peer_router) + json_object_boolean_true_add( + json_es_info, "peerRouter"); + if (attr->mm_sync_seqnum) + json_object_int_add( + json_es_info, "peerSeq", + attr->mm_sync_seqnum); + json_object_object_add( + json_path, "es_info", + json_es_info); + } + } else { + if (bgp_evpn_attr_is_sync(attr)) + vty_out(vty, + " ESI %s %s peer-info: (%s%s%sMM: %d)\n", + esi_buf, + es_local ? "local-es":"", + peer_proxy ? "proxy " : "", + peer_active ? "active ":"", + peer_router ? "router ":"", + attr->mm_sync_seqnum); + else + vty_out(vty, " ESI %s %s\n", + esi_buf, + es_local ? "local-es":""); + } +} + +void route_vty_out_detail(struct vty *vty, struct bgp *bgp, + struct bgp_dest *bn, struct bgp_path_info *path, + afi_t afi, safi_t safi, json_object *json_paths) { char buf[INET6_ADDRSTRLEN]; char buf1[BUFSIZ]; @@ -9211,17 +9269,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, } if (safi == SAFI_EVPN && - memcmp(&attr->esi, zero_esi, sizeof(esi_t))) { - char esi_buf[ESI_STR_LEN]; - - esi_to_str(&attr->esi, esi_buf, sizeof(esi_buf)); - if (json_paths) - json_object_string_add( - json_path, "esi", - esi_buf); - else - vty_out(vty, " ESI %s\n", - esi_buf); + bgp_evpn_is_esi_valid(&attr->esi)) { + route_vty_out_detail_es_info(vty, attr, json_path); } /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid,