From 0e64f7c080fafb61dd97023bb25e0c59b53b7556 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 21 Oct 2015 10:10:17 +0900 Subject: server: remove peer's getBests method Use TableManager's getBestPathList Signed-off-by: FUJITA Tomonori --- table/table_manager.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'table') diff --git a/table/table_manager.go b/table/table_manager.go index f52f1ae9..4cb196a1 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -456,6 +456,16 @@ func (manager *TableManager) handleMacMobility(path *Path) []*Destination { return dsts } +func (manager *TableManager) getDestinationCount(rfList []bgp.RouteFamily) int { + count := 0 + for _, rf := range rfList { + if _, ok := manager.Tables[rf]; ok { + count += len(manager.Tables[rf].GetDestinations()) + } + } + return count +} + func (manager *TableManager) GetPathList(rf bgp.RouteFamily) []*Path { if _, ok := manager.Tables[rf]; !ok { return []*Path{} @@ -468,14 +478,15 @@ func (manager *TableManager) GetPathList(rf bgp.RouteFamily) []*Path { return paths } -func (manager *TableManager) GetBestPathList(rf bgp.RouteFamily) []*Path { - if _, ok := manager.Tables[rf]; !ok { - return []*Path{} - } - destinations := manager.Tables[rf].GetDestinations() - paths := make([]*Path, 0, len(destinations)) - for _, dest := range destinations { - paths = append(paths, dest.GetBestPath()) +func (manager *TableManager) GetBestPathList(rfList []bgp.RouteFamily) []*Path { + paths := make([]*Path, 0, manager.getDestinationCount(rfList)) + for _, rf := range rfList { + if _, ok := manager.Tables[rf]; ok { + destinations := manager.Tables[rf].GetDestinations() + for _, dest := range destinations { + paths = append(paths, dest.GetBestPath()) + } + } } return paths } -- cgit v1.2.3