summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
Diffstat (limited to 'table')
-rw-r--r--table/table_manager.go27
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
}