The last_reset_cause is a plain old BGP_MAX_PACKET_SIZE buffer
that is really enlarging the peer data structure. Let's just
copy the stream that failed and only allocate how ever much
the packet size actually was. While it's likely that we have
a reset reason, the packet typically is not going to be 65k
in size. Let's save space.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit
73b66bed83a38eea37371c6bbb0655c72c903293)
if (use_curr && peer->curr) {
size_t packetsize = stream_get_endp(peer->curr);
assert(packetsize <= peer->max_packet_size);
- memcpy(peer->last_reset_cause, peer->curr->data, packetsize);
- peer->last_reset_cause_size = packetsize;
+ if (peer->last_reset_cause)
+ stream_free(peer->last_reset_cause);
+ peer->last_reset_cause = stream_dup(peer->curr);
}
/* For debug */
BGP_UPTIME_LEN, 0, NULL));
bgp_show_peer_reset(vty, p, NULL, false);
- if (p->last_reset_cause_size) {
- msg = p->last_reset_cause;
+ if (p->last_reset_cause) {
+ msg = p->last_reset_cause->data;
vty_out(vty,
" Message received that caused BGP to send a NOTIFICATION:\n ");
- for (i = 1; i <= p->last_reset_cause_size;
+ for (i = 1; i <= p->last_reset_cause->size;
i++) {
vty_out(vty, "%02X", *msg++);
- if (i != p->last_reset_cause_size) {
+ if (i != p->last_reset_cause->size) {
if (i % 16 == 0) {
vty_out(vty, "\n ");
} else if (i % 4 == 0) {
bgp_unlock(peer->bgp);
+ stream_free(peer->last_reset_cause);
+
memset(peer, 0, sizeof(struct peer));
XFREE(MTYPE_BGP_PEER, peer);
* a new value to the last_reset reason
*/
- uint16_t last_reset_cause_size;
- uint8_t last_reset_cause[BGP_MAX_PACKET_SIZE];
+ struct stream *last_reset_cause;
/* The kind of route-map Flags.*/
uint16_t rmap_type;