summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-08-26 10:26:07 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-08-26 10:26:07 +0900
commit5856fe44297cb4248356671bc7a7f9c3bf17b699 (patch)
tree7a296d2057b0bbc03467e6417a3db20950281ef0 /pkg
parenta472a4964087989814740ac175d12b2759394c85 (diff)
table: kill GetPathListByPeer()
when a peer is down, use paths in its adj table instead of searching for the global table. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/server/peer.go4
-rw-r--r--pkg/server/server.go34
2 files changed, 8 insertions, 30 deletions
diff --git a/pkg/server/peer.go b/pkg/server/peer.go
index f7b89371..7d85ec52 100644
--- a/pkg/server/peer.go
+++ b/pkg/server/peer.go
@@ -558,6 +558,6 @@ func (peer *peer) PassConn(conn *net.TCPConn) {
}
}
-func (peer *peer) DropAll(rfList []bgp.RouteFamily) {
- peer.adjRibIn.Drop(rfList)
+func (peer *peer) DropAll(rfList []bgp.RouteFamily) []*table.Path {
+ return peer.adjRibIn.Drop(rfList)
}
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 30ccbc37..16b6e869 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -1184,25 +1184,6 @@ func (s *BgpServer) propagateUpdate(peer *peer, pathList []*table.Path) {
}
}
-func (s *BgpServer) dropPeerAllRoutes(peer *peer, families []bgp.RouteFamily) {
- peer.fsm.lock.RLock()
- peerInfo := peer.fsm.peerInfo
- peer.fsm.lock.RUnlock()
-
- rib := s.globalRib
- if peer.isRouteServerClient() {
- rib = s.rsRib
- }
- for _, family := range peer.toGlobalFamilies(families) {
- for _, path := range rib.GetPathListByPeer(peerInfo, family) {
- p := path.Clone(true)
- if dsts := rib.Update(p); len(dsts) > 0 {
- s.propagateUpdateToNeighbors(peer, p, dsts, false)
- }
- }
- }
-}
-
func dstsToPaths(id string, as uint32, dsts []*table.Update) ([]*table.Path, []*table.Path, [][]*table.Path) {
bestList := make([]*table.Path, 0, len(dsts))
oldList := make([]*table.Path, 0, len(dsts))
@@ -1345,8 +1326,7 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) {
drop = peer.configuredRFlist()
}
peer.prefixLimitWarned = make(map[bgp.RouteFamily]bool)
- peer.DropAll(drop)
- s.dropPeerAllRoutes(peer, drop)
+ s.propagateUpdate(peer, peer.DropAll(drop))
peer.fsm.lock.Lock()
if peer.fsm.pConf.Config.PeerAs == 0 {
@@ -1367,8 +1347,7 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) {
if longLivedEnabled {
llgr, no_llgr := peer.llgrFamilies()
- peer.DropAll(no_llgr)
- s.dropPeerAllRoutes(peer, no_llgr)
+ s.propagateUpdate(peer, peer.DropAll(no_llgr))
// attach LLGR_STALE community to paths in peer's adj-rib-in
// paths with NO_LLGR are deleted
@@ -1401,8 +1380,7 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) {
"Key": peer.ID(),
"Family": family,
}).Debugf("LLGR restart timer (%d sec) for %s expired", t, family)
- peer.DropAll([]bgp.RouteFamily{family})
- s.dropPeerAllRoutes(peer, []bgp.RouteFamily{family})
+ s.propagateUpdate(peer, peer.DropAll([]bgp.RouteFamily{family}))
// when all llgr restart timer expired, stop PeerRestarting
if peer.llgrRestartTimerExpired(family) {
@@ -1427,8 +1405,8 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) {
peer.fsm.lock.Lock()
peer.fsm.pConf.GracefulRestart.State.PeerRestarting = false
peer.fsm.lock.Unlock()
- peer.DropAll(peer.configuredRFlist())
- s.dropPeerAllRoutes(peer, peer.configuredRFlist())
+
+ s.propagateUpdate(peer, peer.DropAll(peer.configuredRFlist()))
if peer.isDynamicNeighbor() {
s.deleteDynamicNeighbor(peer, oldState, e)
@@ -2908,7 +2886,7 @@ func (s *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8) erro
n.fsm.h.ctxCancel()
delete(s.neighborMap, addr)
- s.dropPeerAllRoutes(n, n.configuredRFlist())
+ s.propagateUpdate(n, n.DropAll(n.configuredRFlist()))
return nil
}