From 3573b171e0095ac0714d8bf5f141e392f5cdf45b Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 24 Nov 2022 13:07:32 +0200 Subject: [PATCH] bgpd: Keep the notification data under peer's struct when sending Before this patch, data is flushed, and we can't see the data after we send the notification. Signed-off-by: Donatas Abraitis --- bgpd/bgp_packet.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index f3ca3bba0a..5d4cf2a6aa 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -979,10 +979,11 @@ static void bgp_notify_send_internal(struct peer *peer, uint8_t code, peer->notify.code = bgp_notify.code; peer->notify.subcode = bgp_notify.subcode; + peer->notify.length = bgp_notify.length; if (bgp_notify.length && data) { - bgp_notify.data = - XMALLOC(MTYPE_TMP, bgp_notify.length * 3); + bgp_notify.data = XMALLOC(MTYPE_BGP_NOTIFICATION, + bgp_notify.length * 3); for (i = 0; i < bgp_notify.length; i++) if (first) { snprintf(c, sizeof(c), " %02x", @@ -1002,7 +1003,15 @@ static void bgp_notify_send_internal(struct peer *peer, uint8_t code, bgp_notify_print(peer, &bgp_notify, "sending", hard_reset); if (bgp_notify.data) { - XFREE(MTYPE_TMP, bgp_notify.data); + if (data) { + XFREE(MTYPE_BGP_NOTIFICATION, + peer->notify.data); + peer->notify.data = XCALLOC( + MTYPE_BGP_NOTIFICATION, datalen); + memcpy(peer->notify.data, data, datalen); + } + + XFREE(MTYPE_BGP_NOTIFICATION, bgp_notify.data); bgp_notify.length = 0; } }