return "";
}
+/* extract notify admin reason if correctly present */
+const char *
+bgp_notify_admin_message(char *buf, size_t bufsz, u_char *data, size_t datalen)
+{
+ if (!data || datalen < 1)
+ return NULL;
+
+ u_char len = data[0];
+ if (len > 128
+ || len > datalen - 1)
+ return NULL;
+
+ return zlog_sanitize(buf, bufsz, data + 1, len);
+}
+
/* dump notify packet */
void
bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify,
{
const char *subcode_str;
const char *code_str;
+ const char *msg_str = NULL;
+ char msg_buf[1024];
if (BGP_DEBUG (neighbor_events, NEIGHBOR_EVENTS) || bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
{
code_str = bgp_notify_code_str(bgp_notify->code);
subcode_str = bgp_notify_subcode_str(bgp_notify->code, bgp_notify->subcode);
- zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
- strcmp (direct, "received") == 0 ? "received from" : "sent to",
- peer->host, bgp_notify->code, bgp_notify->subcode,
- code_str, subcode_str, bgp_notify->length,
- bgp_notify->data ? bgp_notify->data : "");
+ if (bgp_notify->code == BGP_NOTIFY_CEASE
+ && (bgp_notify->subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
+ || bgp_notify->subcode == BGP_NOTIFY_CEASE_ADMIN_RESET))
+ {
+ msg_str = bgp_notify_admin_message(msg_buf, sizeof(msg_buf),
+ bgp_notify->raw_data, bgp_notify->length);
+ }
+
+ if (msg_str)
+ {
+ zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) \"%s\"",
+ strcmp (direct, "received") == 0 ? "received from" : "sent to",
+ peer->host, bgp_notify->code, bgp_notify->subcode,
+ code_str, subcode_str, msg_str);
+ }
+ else
+ {
+ msg_str = bgp_notify->data ? bgp_notify->data : "";
+ zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
+ strcmp (direct, "received") == 0 ? "received from" : "sent to",
+ peer->host, bgp_notify->code, bgp_notify->subcode,
+ code_str, subcode_str, bgp_notify->length, msg_str);
+ }
}
}
extern int bgp_debug_count(void);
extern const char *bgp_debug_rdpfxpath2str (struct prefix_rd *, union prefixconstptr,
int, u_int32_t, char *, int);
+const char *bgp_notify_admin_message(char *buf, size_t bufsz, u_char *data, size_t datalen);
+
#endif /* _QUAGGA_BGP_DEBUG_H */
bgp_notify.subcode = sub_code;
bgp_notify.data = NULL;
bgp_notify.length = length - BGP_MSG_NOTIFY_MIN_SIZE;
+ bgp_notify.raw_data = data;
peer->notify.code = bgp_notify.code;
peer->notify.subcode = bgp_notify.subcode;
sprintf (c, "%02x", stream_getc (peer->ibuf));
strcpy (bgp_notify.data, c);
}
+ bgp_notify.raw_data = (u_char*)peer->notify.data;
}
bgp_notify_print(peer, &bgp_notify, "received");
vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
code_str, subcode_str, VTY_NEWLINE);
+ if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED
+ && p->notify.code == BGP_NOTIFY_CEASE
+ && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
+ || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET)
+ && p->notify.length)
+ {
+ char msgbuf[1024];
+ const char *msg_str;
+
+ msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf),
+ (u_char*)p->notify.data, p->notify.length);
+ if (msg_str)
+ vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE);
+ }
}
else
{