]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add decoded notification code strings to JSON output
authorDinesh G Dutt <ddutt@cumulusnetworks.com>
Mon, 16 Jan 2017 14:24:09 +0000 (06:24 -0800)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 30 Jan 2017 18:40:53 +0000 (13:40 -0500)
Ticket: CM-14136
Reviewed By: CCR-5585
Testing Done: bgpmin

The JSON output of 'bgp neighbor show' lacked the decoded strings for
the last notification error code/subcode. Decoding these strings outside
quagga is painful, and then needs to match with any updates to the codes
from RFCs/drafts. Further, all apps that look to understanding this need
to then add their own decoders for these strings.

Just add the decoded strings to the JSON output as well. JSON key name
for this is 'lastNotificationReason'.

Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
bgpd/bgp_vty.c

index 52ce1273c3e4e0534cc06f0aa5f7fdab4f85bdba..79e5a0c33272034725295e06c991b8135eb28b11 100644 (file)
@@ -11917,11 +11917,19 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js
           tm = gmtime(&uptime);
           json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
           json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
-          if (p->last_reset_cause_size)
+          if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
+              p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
             {
               char errorcodesubcode_hexstr[5];
+              char errorcodesubcode_str[256];
+
+              code_str = bgp_notify_code_str(p->notify.code);
+              subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
+
               sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode);
               json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr);
+              snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str);
+              json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str);
             }
         }
       else