From 39e871e6f31dc044ac009096e8b4fa11d96414b0 Mon Sep 17 00:00:00 2001 From: Sam Tannous Date: Mon, 13 Jun 2016 15:39:57 -0700 Subject: [PATCH] Quagga: bgpd needs extra neighbor and route json attributes for SNMP BGP4 MIB Ticket: CM-11344 Reviewed By: dwalton, dsharp Testing Done: built and tested amd64 debs This patch adds the peerID JSON attribute for routes for show ip bgp json. It also corrects the bgpTimerLastWrite in show ip bgp neigh json as well as adds bgpInUpdateElapsedTimeMsecs, lastErrorCodeSubcode, and connectRetryTimer. These are needed for the bgp4 mib implementation (rfc 4273) from the json output of vtysh commands. --- bgpd/bgp_route.c | 5 +++++ bgpd/bgp_vty.c | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index d927c58625..a74d59ee32 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6010,6 +6010,11 @@ route_vty_out (struct vty *vty, struct prefix *p, else vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); + if (json_paths) { + char buf[BUFSIZ]; + json_object_string_add(json_path, "peerId", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN)); + } + /* Print aspath */ if (attr->aspath) { diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index bbeaf37615..bef95981a0 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11477,7 +11477,13 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js uptime = bgp_clock(); uptime -= p->last_write; tm = gmtime(&uptime); - json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); + json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); + + uptime = bgp_clock(); + uptime -= p->update_time; + tm = gmtime(&uptime); + json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", + (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); /* Configured timer values. */ json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); @@ -12157,10 +12163,9 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]); if (p->last_reset_cause_size) { - msg = p->last_reset_cause; - char adapter[BUFSIZ]; - sprintf(adapter, "%s", msg); - json_object_string_add(json_hold, "messageReceivedThatCausedBgpNotification", adapter); + char errorcodesubcode_hexstr[5]; + sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); + json_object_string_add(json_hold, "lastErrorCodeSubcode", errorcodesubcode_hexstr); } } else @@ -12339,6 +12344,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js /* Timer information. */ if (use_json) { + json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); if (p->status == Established && p->rtt) json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); if (p->t_start) @@ -12362,7 +12368,8 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - /* TCP metrics. */ + vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", + p->v_connect, VTY_NEWLINE); if (p->status == Established && p->rtt) vty_out (vty, "Estimated round trip time: %d ms%s", p->rtt, VTY_NEWLINE); -- 2.39.5