struct peer *peer;
bgp_size_t size;
char notify_data_length[2];
+ u_int32_t notify_out;
/* Yes first of all get peer pointer. */
peer = THREAD_ARG (thread);
peer->t_read = NULL;
+ /* Note notify_out so we can check later to see if we sent another one */
+ notify_out = peer->notify_out;
+
/* For non-blocking IO check. */
if (peer->status == Connect)
{
break;
}
+ /* If reading this packet caused us to send a NOTIFICATION then store a copy
+ * of the packet for troubleshooting purposes
+ */
+ if (notify_out < peer->notify_out)
+ {
+ memcpy(peer->last_reset_cause, peer->ibuf->data, peer->packet_size);
+ peer->last_reset_cause_size = peer->packet_size;
+ notify_out = peer->notify_out;
+ }
+
/* Clear input buffer. */
peer->packet_size = 0;
if (peer->ibuf)
stream_reset (peer->ibuf);
done:
+ /* If reading this packet caused us to send a NOTIFICATION then store a copy
+ * of the packet for troubleshooting purposes
+ */
+ if (notify_out < peer->notify_out)
+ {
+ memcpy(peer->last_reset_cause, peer->ibuf->data, peer->packet_size);
+ peer->last_reset_cause_size = peer->packet_size;
+ }
+
return 0;
}
char timebuf[BGP_UPTIME_LEN];
afi_t afi;
safi_t safi;
+ u_int16_t i;
+ u_char *msg;
bgp = p->bgp;
p->established, p->dropped,
VTY_NEWLINE);
- if (! p->dropped)
+ if (! p->last_reset)
vty_out (vty, " Last reset never%s", VTY_NEWLINE);
else
- vty_out (vty, " Last reset %s, due to %s%s",
- peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
- peer_down_str[(int) p->last_reset], VTY_NEWLINE);
+ {
+ vty_out (vty, " Last reset %s, due to %s%s",
+ peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
+ peer_down_str[(int) p->last_reset], VTY_NEWLINE);
+
+ if (p->last_reset_cause_size)
+ {
+ msg = p->last_reset_cause;
+ vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
+ for (i = 1; i <= p->last_reset_cause_size; i++)
+ {
+ vty_out(vty, "%02X", *msg++);
+
+ if (i != p->last_reset_cause_size)
+ if (i % 16 == 0)
+ vty_out(vty, "%s ", VTY_NEWLINE);
+ else if (i % 4 == 0)
+ vty_out(vty, " ");
+ }
+ vty_out(vty, "%s", VTY_NEWLINE);
+ }
+ }
if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
{
BGP_PEER_CONFED,
} bgp_peer_sort_t;
+/* BGP message header and packet size. */
+#define BGP_MARKER_SIZE 16
+#define BGP_HEADER_SIZE 19
+#define BGP_MAX_PACKET_SIZE 4096
+
/* BGP neighbor structure. */
struct peer
{
#define PEER_DOWN_PASSIVE_CHANGE 20 /* neighbor passive command */
#define PEER_DOWN_MULTIHOP_CHANGE 21 /* neighbor multihop command */
#define PEER_DOWN_NSF_CLOSE_SESSION 22 /* NSF tcp session close */
+unsigned long last_reset_cause_size;
+u_char last_reset_cause[BGP_MAX_PACKET_SIZE];
/* The kind of route-map Flags.*/
u_char rmap_type;
/* Default BGP port number. */
#define BGP_PORT_DEFAULT 179
-/* BGP message header and packet size. */
-#define BGP_MARKER_SIZE 16
-#define BGP_HEADER_SIZE 19
-#define BGP_MAX_PACKET_SIZE 4096
-
/* BGP minimum message size. */
#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)