]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Keep the notification data under peer's struct when sending
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 24 Nov 2022 11:07:32 +0000 (13:07 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 24 Nov 2022 14:57:02 +0000 (16:57 +0200)
Before this patch, data is flushed, and we can't see the data after we send
the notification.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_packet.c

index f3ca3bba0a0651299f63bed039b01a011cd735e6..5d4cf2a6aaadb7a64cc14eae7d289f60351a0a8b 100644 (file)
@@ -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;
                }
        }