]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Expose bgp_peer_connection_free and make it a double pointer
authorDonald Sharp <sharpd@nvidia.com>
Sat, 26 Aug 2023 21:33:27 +0000 (17:33 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 10 Sep 2023 12:31:25 +0000 (08:31 -0400)
The bgp_peer_connection_free function should be exposed outside of
bgpd.c so that it can be used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgpd.c
bgpd/bgpd.h

index 278ab40e16a75d1d4094caccb6ad88e4627d937f..8dae69817a08cb65c647857fd80640891e82a804 100644 (file)
@@ -1149,13 +1149,15 @@ void bgp_peer_connection_buffers_free(struct peer_connection *connection)
        }
 }
 
-static void bgp_peer_connection_free(struct peer_connection *connection)
+void bgp_peer_connection_free(struct peer_connection **connection)
 {
-       bgp_peer_connection_buffers_free(connection);
-       pthread_mutex_destroy(&connection->io_mtx);
+       bgp_peer_connection_buffers_free(*connection);
+       pthread_mutex_destroy(&(*connection)->io_mtx);
 
-       memset(connection, 0, sizeof(struct peer_connection));
-       XFREE(MTYPE_BGP_PEER_CONNECTION, connection);
+       memset(*connection, 0, sizeof(struct peer_connection));
+       XFREE(MTYPE_BGP_PEER_CONNECTION, *connection);
+
+       connection = NULL;
 }
 
 struct peer_connection *bgp_peer_connection_new(struct peer *peer)
@@ -1268,7 +1270,7 @@ static void peer_free(struct peer *peer)
        if (peer->as_pretty)
                XFREE(MTYPE_BGP, peer->as_pretty);
 
-       bgp_peer_connection_free(peer->connection);
+       bgp_peer_connection_free(&peer->connection);
 
        bgp_unlock(peer->bgp);
 
index fb2bd6e503ada6d03e662ab4ef7197a52988ca0b..1fc7e02a6702b0196424bdacd06baca112c97da7 100644 (file)
@@ -1162,6 +1162,7 @@ struct peer_connection {
 #define PEER_THREAD_READS_ON (1U << 1)
 };
 extern struct peer_connection *bgp_peer_connection_new(struct peer *peer);
+extern void bgp_peer_connection_free(struct peer_connection **connection);
 extern void bgp_peer_connection_buffers_free(struct peer_connection *connection);
 
 /* BGP neighbor structure. */