diff options
| author | Dinesh G Dutt <ddutt@cumulusnetworks.com> | 2017-01-16 06:24:09 -0800 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-01-30 13:40:53 -0500 |
| commit | cca1dda8bf5aca42aec577b2e156b5e56a2bc996 (patch) | |
| tree | 31d9f948749e160f5f80fb0cd94748d381ed7a0d | |
| parent | 1a11782c408a60afb464fe232fc2e3fa1e298436 (diff) | |
bgpd: Add decoded notification code strings to JSON output
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>
| -rw-r--r-- | bgpd/bgp_vty.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 52ce1273c3..79e5a0c332 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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 |
