]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Quagga: bgpd needs extra neighbor and route json attributes for SNMP BGP4 MIB
authorSam Tannous <stannous@cumulusnetworks.com>
Mon, 13 Jun 2016 22:39:57 +0000 (15:39 -0700)
committerSam Tannous <stannous@cumulusnetworks.com>
Mon, 13 Jun 2016 22:39:57 +0000 (15:39 -0700)
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
bgpd/bgp_vty.c

index d927c58625e3d64f7ea452ad9ac5d37797107480..a74d59ee32a2a2daaa6c54647ed9882ecf597b45 100644 (file)
@@ -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)
         {
index bbeaf37615efad5cc0d714ae25cbca60857683ca..bef95981a0105f09819755773c3d851ca3d490ec 100644 (file)
@@ -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);