diff options
-rw-r--r-- | server/server.go | 4 | ||||
-rw-r--r-- | table/destination.go | 5 | ||||
-rw-r--r-- | table/table_manager.go | 14 | ||||
-rw-r--r-- | table/table_manager_test.go | 2 |
4 files changed, 10 insertions, 15 deletions
diff --git a/server/server.go b/server/server.go index 61e52a45..c774e47e 100644 --- a/server/server.go +++ b/server/server.go @@ -668,7 +668,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([] ids = append(ids, targetPeer.TableID()) } } - best, _, withdrawn = rib.ProcessPaths(ids, append(pathList, moded...)) + best, withdrawn = rib.ProcessPaths(ids, append(pathList, moded...)) } else { for idx, path := range pathList { path = server.policy.ApplyPolicy(table.GLOBAL_RIB_NAME, table.POLICY_DIRECTION_IMPORT, path, nil) @@ -715,7 +715,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([] } } alteredPathList = pathList - best, _, withdrawn = rib.ProcessPaths([]string{table.GLOBAL_RIB_NAME}, pathList) + best, withdrawn = rib.ProcessPaths([]string{table.GLOBAL_RIB_NAME}, pathList) if len(best[table.GLOBAL_RIB_NAME]) == 0 { return nil, alteredPathList } diff --git a/table/destination.go b/table/destination.go index 2111f695..131cb129 100644 --- a/table/destination.go +++ b/table/destination.go @@ -226,10 +226,9 @@ func (dd *Destination) validatePath(path *Path) { // // Modifies destination's state related to stored paths. Removes withdrawn // paths from known paths. Also, adds new paths to known paths. -func (dest *Destination) Calculate(ids []string) (map[string]*Path, []*Path, []*Path) { +func (dest *Destination) Calculate(ids []string) (map[string]*Path, []*Path) { best := make(map[string]*Path, len(ids)) oldKnownPathList := dest.knownPathList - updated := dest.newPathList // First remove the withdrawn paths. withdrawnList := dest.explicitWithdraw() // Do implicit withdrawal @@ -266,7 +265,7 @@ func (dest *Destination) Calculate(ids []string) (map[string]*Path, []*Path, []* for _, id := range ids { best[id] = f(id) } - return best, updated, withdrawnList + return best, withdrawnList } // Removes withdrawn paths. diff --git a/table/table_manager.go b/table/table_manager.go index 287c5a46..a041c5b9 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -216,8 +216,7 @@ func (manager *TableManager) DeleteVrf(name string) ([]*Path, error) { return msgs, nil } -func (manager *TableManager) calculate(ids []string, destinations []*Destination) (map[string][]*Path, []*Path, []*Path) { - newly := make([]*Path, 0, len(destinations)) +func (manager *TableManager) calculate(ids []string, destinations []*Destination) (map[string][]*Path, []*Path) { withdrawn := make([]*Path, 0, len(destinations)) best := make(map[string][]*Path, len(ids)) @@ -228,11 +227,10 @@ func (manager *TableManager) calculate(ids []string, destinations []*Destination "Topic": "table", "Key": dst.GetNlri().String(), }).Debug("Processing destination") - paths, n, w := dst.Calculate(ids) + paths, w := dst.Calculate(ids) for id, path := range paths { best[id] = append(best[id], path) } - newly = append(newly, n...) withdrawn = append(withdrawn, w...) if len(dst.knownPathList) == 0 { @@ -244,20 +242,18 @@ func (manager *TableManager) calculate(ids []string, destinations []*Destination t := manager.Tables[dst.Family()] t.deleteDest(dst) } - return best, newly, withdrawn + return best, withdrawn } func (manager *TableManager) DeletePathsByPeer(ids []string, info *PeerInfo, rf bgp.RouteFamily) (map[string][]*Path, []*Path) { if t, ok := manager.Tables[rf]; ok { dsts := t.DeleteDestByPeer(info) - // no newly added paths - best, _, withdrawn := manager.calculate(ids, dsts) - return best, withdrawn + return manager.calculate(ids, dsts) } return nil, nil } -func (manager *TableManager) ProcessPaths(ids []string, pathList []*Path) (map[string][]*Path, []*Path, []*Path) { +func (manager *TableManager) ProcessPaths(ids []string, pathList []*Path) (map[string][]*Path, []*Path) { m := make(map[string]bool, len(pathList)) dsts := make([]*Destination, 0, len(pathList)) for _, path := range pathList { diff --git a/table/table_manager_test.go b/table/table_manager_test.go index 38f16eaf..21d70d84 100644 --- a/table/table_manager_test.go +++ b/table/table_manager_test.go @@ -30,7 +30,7 @@ import ( // this function processes only BGPUpdate func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]*Path, error) { paths := ProcessMessage(message, fromPeer, time.Now()) - best, _, _ := manager.ProcessPaths([]string{GLOBAL_RIB_NAME}, paths) + best, _ := manager.ProcessPaths([]string{GLOBAL_RIB_NAME}, paths) paths2 := make([]*Path, 0, len(paths)) for _, p := range best[GLOBAL_RIB_NAME] { if p != nil { |