Skip to content

Commit

Permalink
fix(bgp): use PeerState_ESTABLISHED logic like function name(#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
lx1036 authored and aauren committed Nov 8, 2021
1 parent bee2c20 commit 8e7d585
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,10 @@ func (nrc *NetworkRoutingController) injectRoute(path *gobgpapi.Path) error {
}

func (nrc *NetworkRoutingController) isPeerEstablished(peerIP string) (bool, error) {
var peerDisconnected bool
var peerConnected bool
peerFunc := func(peer *gobgpapi.Peer) {
if peer.Conf.NeighborAddress == peerIP {
if peer.State.SessionState != gobgpapi.PeerState_ESTABLISHED {
peerDisconnected = true
}
if peer.Conf.NeighborAddress == peerIP && peer.State.SessionState == gobgpapi.PeerState_ESTABLISHED {
peerConnected = true
}
}
err := nrc.bgpServer.ListPeer(context.Background(), &gobgpapi.ListPeerRequest{
Expand All @@ -633,7 +631,7 @@ func (nrc *NetworkRoutingController) isPeerEstablished(peerIP string) (bool, err
return false, fmt.Errorf("unable to list peers to see if tunnel & routes need to be removed: %v", err)
}

return peerDisconnected, nil
return peerConnected, nil
}

// cleanupTunnel removes any traces of tunnels / routes that were setup by nrc.setupOverlayTunnel() and are no longer
Expand Down

0 comments on commit 8e7d585

Please sign in to comment.