diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-21 10:10:17 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-21 10:10:17 +0900 |
commit | 0e64f7c080fafb61dd97023bb25e0c59b53b7556 (patch) | |
tree | a473434c09fefa27cd9c4a80018841cd3afcc4f1 /table/table_manager.go | |
parent | a1a86cd2127cd30c7781563ac8e00257f1214779 (diff) |
server: remove peer's getBests method
Use TableManager's getBestPathList
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r-- | table/table_manager.go | 27 |
1 files changed, 19 insertions, 8 deletions
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 } |