Commit af39305b97 for frr
commit af39305b974a33126df4a12785868dcbd72067bf
Author: Jing Kan <kanjing.kj@alibaba-inc.com>
Date: Tue Nov 3 11:20:26 2026 +0800
tests: reuse peer connections in BGP test fixtures
peer_create_accept() already allocates a connection and registers it in
the BGP connection hash. Replacing peer->connection loses ownership of
the original connection and its buffers while the hash retains it.
Reuse that connection in the capability and MP attribute fixtures. In
the capability test, also keep the existing curr stream when moving to
the dynamic capability cases; parse_test() resets it before each case.
Signed-off-by: Jing Kan <kanjing.kj@alibaba-inc.com>
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c
index 261b7c9da7..3f530e9c68 100644
--- a/tests/bgpd/test_capability.c
+++ b/tests/bgpd/test_capability.c
@@ -972,9 +972,7 @@ int main(void)
parse_test(peer, &opt_params[i++], OPT_PARAM);
SET_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV);
- peer->connection = bgp_peer_connection_new(peer, NULL, UNKNOWN);
peer->connection->status = Established;
- peer->connection->curr = stream_new(BGP_MAX_PACKET_SIZE);
i = 0;
while (dynamic_cap_msgs[i].name)
diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c
index a335acc602..446c06114c 100644
--- a/tests/bgpd/test_mp_attr.c
+++ b/tests/bgpd/test_mp_attr.c
@@ -1256,7 +1256,6 @@ int main(void)
peer = peer_create_accept(bgp, NULL);
peer->host = (char *)"foo";
- peer->connection = bgp_peer_connection_new(peer, NULL, UNKNOWN);
peer->connection->status = Established;
peer->connection->curr = stream_new(BGP_MAX_PACKET_SIZE);