diff options
author | Eiichiro Watanabe <a16tochjp@gmail.com> | 2018-11-10 18:39:30 +0900 |
---|---|---|
committer | Eiichiro Watanabe <a16tochjp@gmail.com> | 2018-11-10 18:40:14 +0900 |
commit | 289fc39deb9cfa4ee678ff902d51f84c6c828136 (patch) | |
tree | cc855247aea28a4ca5ba4a9d028df85eeb638df4 /pkg/server/server.go | |
parent | eebc7291cec739ffd84b376bd2abaf3867944380 (diff) |
server: avoid deadlock
peer.configuredRFlist() uses lock in itself.
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r-- | pkg/server/server.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go index 1377e4d0..749750f9 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -698,14 +698,16 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *config.Neighbor { } } - peer.fsm.lock.RLock() conf.State.RemoteCapabilityList = remoteCap - conf.State.LocalCapabilityList = capabilitiesFromConfig(peer.fsm.pConf) + peer.fsm.lock.RLock() + conf.State.LocalCapabilityList = capabilitiesFromConfig(peer.fsm.pConf) conf.State.SessionState = config.IntToSessionStateMap[int(peer.fsm.state)] conf.State.AdminState = config.IntToAdminStateMap[int(peer.fsm.adminState)] + state := peer.fsm.state + peer.fsm.lock.RUnlock() - if peer.fsm.state == bgp.BGP_FSM_ESTABLISHED { + if state == bgp.BGP_FSM_ESTABLISHED { rfList := peer.configuredRFlist() if getAdvertised { pathList, filtered := s.getBestFromLocal(peer, rfList) @@ -717,14 +719,15 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *config.Neighbor { conf.State.AdjTable.Received = uint32(peer.adjRibIn.Count(rfList)) conf.State.AdjTable.Accepted = uint32(peer.adjRibIn.Accepted(rfList)) + peer.fsm.lock.RLock() conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort() _, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort() buf, _ := peer.fsm.recvOpen.Serialize() // need to copy all values here conf.State.ReceivedOpenMessage, _ = bgp.ParseBGPMessage(buf) conf.State.RemoteRouterId = peer.fsm.peerInfo.ID.To4().String() + peer.fsm.lock.RUnlock() } - peer.fsm.lock.RUnlock() return &conf } |