summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2017-02-13 06:30:58 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-15 00:10:15 +0900
commit52356c26f821fdebb3fdf943a1b898a2d1b4d0db (patch)
tree0ebe5f222851168489f9118eeb77f71547d5ccb6 /table/table_manager.go
parentf276279bf6d90b3f5940bc63780cc3483e9d734e (diff)
server: add a current option to WatchBestPath()
also, use it for zebra integration Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go53
1 files changed, 34 insertions, 19 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index ae00d3ce..15caa924 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -299,38 +299,53 @@ func (manager *TableManager) handleMacMobility(path *Path) []*Destination {
return dsts
}
+func (manager *TableManager) tables(list ...bgp.RouteFamily) []*Table {
+ l := make([]*Table, 0, len(manager.Tables))
+ if len(list) == 0 {
+ for _, v := range manager.Tables {
+ l = append(l, v)
+ }
+ return l
+ }
+ for _, f := range list {
+ if t, ok := manager.Tables[f]; ok {
+ l = append(l, t)
+ }
+ }
+ return l
+}
+
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())
- }
+ for _, t := range manager.tables(rfList...) {
+ count += len(t.GetDestinations())
}
return count
}
func (manager *TableManager) GetBestPathList(id string, rfList []bgp.RouteFamily) []*Path {
paths := make([]*Path, 0, manager.getDestinationCount(rfList))
- for _, rf := range rfList {
- if t, ok := manager.Tables[rf]; ok {
- paths = append(paths, t.Bests(id)...)
- }
+ for _, t := range manager.tables(rfList...) {
+ paths = append(paths, t.Bests(id)...)
}
return paths
}
-func (manager *TableManager) GetPathList(id string, rfList []bgp.RouteFamily) []*Path {
- c := 0
- for _, rf := range rfList {
- if t, ok := manager.Tables[rf]; ok {
- c += len(t.destinations)
- }
+func (manager *TableManager) GetBestMultiPathList(id string, rfList []bgp.RouteFamily) [][]*Path {
+ if !UseMultiplePaths.Enabled {
+ return nil
}
- paths := make([]*Path, 0, c)
- for _, rf := range rfList {
- if t, ok := manager.Tables[rf]; ok {
- paths = append(paths, t.GetKnownPathList(id)...)
- }
+ paths := make([][]*Path, 0, manager.getDestinationCount(rfList))
+ for _, t := range manager.tables(rfList...) {
+ paths = append(paths, t.MultiBests(id)...)
+ }
+ return paths
+}
+
+func (manager *TableManager) GetPathList(id string, rfList []bgp.RouteFamily) []*Path {
+ paths := make([]*Path, 0, manager.getDestinationCount(rfList))
+ for _, t := range manager.tables(rfList...) {
+ paths = append(paths, t.GetKnownPathList(id)...)
}
return paths
}