diff options
author | Foivos Filippopoulos <ffilippopoulos@utilitywarehouse.co.uk> | 2019-01-17 17:07:34 +0000 |
---|---|---|
committer | Foivos Filippopoulos <ffilippopoulos@utilitywarehouse.co.uk> | 2019-01-17 17:07:34 +0000 |
commit | 318a91e31b8baed86bb66a3767525da68ae49a5d (patch) | |
tree | a60f6d6c7c4326e33314e466f1053db4ae98984b /pkg/server | |
parent | 61d7a5e90bae220a45accf9914604ea568ae8c4a (diff) |
Allow graceful restart for dynamic neighbors
Diffstat (limited to 'pkg/server')
-rw-r--r-- | pkg/server/server.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go index 941afdeb..c95ba700 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1150,6 +1150,18 @@ func (s *BgpServer) propagateUpdateToNeighbors(source *peer, newPath *table.Path } } +func (s *BgpServer) deleteDynamicNeighbor(peer *peer, oldState bgp.FSMState, e *fsmMsg) { + if peer.isDynamicNeighbor() { + peer.stopPeerRestarting() + go peer.stopFSM() + peer.fsm.lock.RLock() + delete(s.neighborMap, peer.fsm.pConf.State.NeighborAddress) + peer.fsm.lock.RUnlock() + s.broadcastPeerState(peer, oldState, e) + return + } +} + func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { switch e.MsgType { case fsmMsgStateChange: @@ -1196,15 +1208,10 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { } peer.fsm.lock.Unlock() - if peer.isDynamicNeighbor() { - peer.stopPeerRestarting() - go peer.stopFSM() - peer.fsm.lock.RLock() - delete(s.neighborMap, peer.fsm.pConf.State.NeighborAddress) - peer.fsm.lock.RUnlock() - s.broadcastPeerState(peer, oldState, e) - return + if !graceful { + s.deleteDynamicNeighbor(peer, oldState, e) } + } else if nextStateIdle { peer.fsm.lock.RLock() longLivedEnabled := peer.fsm.pConf.GracefulRestart.State.LongLivedEnabled @@ -1274,6 +1281,8 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { peer.fsm.lock.Unlock() peer.DropAll(peer.configuredRFlist()) s.dropPeerAllRoutes(peer, peer.configuredRFlist()) + + s.deleteDynamicNeighbor(peer, oldState, e) } } |