bgpd: Expose bgp_peer_connection_free and make it a double pointer

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>
This commit is contained in:
Donald Sharp 2023-08-26 17:33:27 -04:00
parent d2ba78929f
commit 8e90c4c953
2 changed files with 9 additions and 6 deletions

View 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); bgp_peer_connection_buffers_free(*connection);
pthread_mutex_destroy(&connection->io_mtx); pthread_mutex_destroy(&(*connection)->io_mtx);
memset(connection, 0, sizeof(struct peer_connection)); memset(*connection, 0, sizeof(struct peer_connection));
XFREE(MTYPE_BGP_PEER_CONNECTION, connection); XFREE(MTYPE_BGP_PEER_CONNECTION, *connection);
connection = NULL;
} }
struct peer_connection *bgp_peer_connection_new(struct peer *peer) 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) if (peer->as_pretty)
XFREE(MTYPE_BGP, 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); bgp_unlock(peer->bgp);

View File

@ -1162,6 +1162,7 @@ struct peer_connection {
#define PEER_THREAD_READS_ON (1U << 1) #define PEER_THREAD_READS_ON (1U << 1)
}; };
extern struct peer_connection *bgp_peer_connection_new(struct peer *peer); 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); extern void bgp_peer_connection_buffers_free(struct peer_connection *connection);
/* BGP neighbor structure. */ /* BGP neighbor structure. */