From 318a91e31b8baed86bb66a3767525da68ae49a5d Mon Sep 17 00:00:00 2001 From: Foivos Filippopoulos Date: Thu, 17 Jan 2019 17:07:34 +0000 Subject: Allow graceful restart for dynamic neighbors --- pkg/server/server.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'pkg/server/server.go') 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) } } -- cgit v1.2.3