Skip to content

Commit

Permalink
Merge pull request #14325 from donaldsharp/peerhash_take_two
Browse files Browse the repository at this point in the history
bgpd: Add peers back to peer hash when peer_xfer_conn fails
  • Loading branch information
ton31337 authored Sep 1, 2023
2 parents e903db3 + ce1f5d3 commit 2ed81c8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,7 @@ bgp_establish(struct peer_connection *connection)
struct peer *other;
int status;
struct peer *peer = connection->peer;
struct peer *orig = peer;

other = peer->doppelganger;
hash_release(peer->bgp->peerhash, peer);
Expand All @@ -2146,6 +2147,17 @@ bgp_establish(struct peer_connection *connection)
peer = peer_xfer_conn(peer);
if (!peer) {
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;
}

Expand Down

0 comments on commit 2ed81c8

Please sign in to comment.