Merge pull request #14325 from donaldsharp/peerhash_take_two

bgpd: Add peers back to peer hash when peer_xfer_conn fails
This commit is contained in:
Donatas Abraitis 2023-09-01 08:28:13 +03:00 committed by GitHub
commit 2ed81c8ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2137,6 +2137,7 @@ bgp_establish(struct peer_connection *connection)
struct peer *other; struct peer *other;
int status; int status;
struct peer *peer = connection->peer; struct peer *peer = connection->peer;
struct peer *orig = peer;
other = peer->doppelganger; other = peer->doppelganger;
hash_release(peer->bgp->peerhash, peer); hash_release(peer->bgp->peerhash, peer);
@ -2146,6 +2147,17 @@ bgp_establish(struct peer_connection *connection)
peer = peer_xfer_conn(peer); peer = peer_xfer_conn(peer);
if (!peer) { if (!peer) {
flog_err(EC_BGP_CONNECT, "%%Neighbor failed in xfer_conn"); flog_err(EC_BGP_CONNECT, "%%Neighbor failed in xfer_conn");
/*
* A failure of peer_xfer_conn but not putting the peers
* back in the hash ends up with a situation where incoming
* connections are rejected, as that the peer is not found
* when a lookup is done
*/
(void)hash_get(orig->bgp->peerhash, orig, hash_alloc_intern);
if (other)
(void)hash_get(other->bgp->peerhash, other,
hash_alloc_intern);
return BGP_FSM_FAILURE; return BGP_FSM_FAILURE;
} }