diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-30 20:25:35 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-30 20:25:35 +0900 |
commit | 7e7b78e775bb40e0998418c5c294ed2668e3ea1a (patch) | |
tree | fef0f5d28ec733077ddd4115dbf7362561420302 /table/table_manager.go | |
parent | ebd6f9a06639df996da8e4570b8c26b664bbbc1a (diff) |
table: use Path as API instead of destination
ProcessPaths and DeletePathsforPeer API uses both Path and Destination
for outside. There is no good reason to use Destination. Let's use
Path.
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 | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index 3d056b08..4b9c0b97 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -132,9 +132,9 @@ func NewTableManager() *TableManager { return t } -func (manager *TableManager) calculate(destinationList []Destination) ([]Path, []Destination, error) { +func (manager *TableManager) calculate(destinationList []Destination) ([]Path, []Path, error) { bestPaths := make([]Path, 0) - lostDest := make([]Destination, 0) + lostPaths := make([]Path, 0) for _, destination := range destinationList { // compute best path @@ -163,7 +163,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [ if currentBestPath != nil { log.Debug("best path is lost") destination.setOldBestPath(destination.getBestPath()) - lostDest = append(lostDest, destination) + lostPaths = append(lostPaths, destination.getBestPath()) } destination.setBestPath(nil) } else { @@ -186,15 +186,16 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [ log.Debugf("destination removed route_family=%v, destination=%v", rf, destination) } } - return bestPaths, lostDest, nil + return bestPaths, lostPaths, nil } -func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo) ([]Path, []Destination, error) { +func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo) ([]Path, []Path, error) { destinationList := manager.Tables[peerInfo.RF].DeleteDestByPeer(peerInfo) return manager.calculate(destinationList) + } -func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Destination, error) { +func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Path, error) { destinationList := make([]Destination, 0) for _, path := range pathList { rf := path.GetRouteFamily() @@ -207,14 +208,11 @@ func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Destinatio // process BGPUpdate message // this function processes only BGPUpdate -func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, []Destination, error) { - var bestPaths []Path = make([]Path, 0) - var lostDest []Destination = make([]Destination, 0) - +func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, []Path, error) { // check msg's type if it's BGPUpdate if message.Header.Type != bgp.BGP_MSG_UPDATE { log.Warn("message is not BGPUpdate") - return bestPaths, lostDest, nil + return []Path{}, []Path{}, nil } msg := &ProcessMessage{ |