diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-03-19 17:18:16 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-19 17:18:16 +0900 |
commit | 9152c24906d712ab1334e22df6d9b48c38cdf665 (patch) | |
tree | 99201b7e5bfb8097fa999b4da701b4182986d79c /table/table_manager.go | |
parent | 0076c6d4104c1c03715683b11766c69ebfeaee87 (diff) |
table: remove unnecessary distinction of paths
struct Path has a flag which can tell whether the path is withdrawal
path or not. so table.ProcessPaths() needs not to return withdrawal path
and non-withdrawal path separetly.
this removes such unnecessary distinction.
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 | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index f2ff1ee6..c8ff0833 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -146,9 +146,8 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily) *TableManager { return t } -func (manager *TableManager) calculate(destinationList []Destination) ([]Path, []Path, error) { - bestPaths := make([]Path, 0) - lostPaths := make([]Path, 0) +func (manager *TableManager) calculate(destinationList []Destination) ([]Path, error) { + newPaths := make([]Path, 0) for _, destination := range destinationList { // compute best path @@ -202,7 +201,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [ p := destination.getBestPath() destination.setOldBestPath(p) - lostPaths = append(lostPaths, p.clone(true)) + newPaths = append(newPaths, p.clone(true)) } destination.setBestPath(nil) } else { @@ -223,7 +222,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [ "reason": reason, }).Debug("new best path") - bestPaths = append(bestPaths, newBestPath) + newPaths = append(newPaths, newBestPath) destination.setBestPath(newBestPath) } @@ -239,18 +238,18 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [ }).Debug("destination removed") } } - return bestPaths, lostPaths, nil + return newPaths, nil } -func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo, rf bgp.RouteFamily) ([]Path, []Path, error) { +func (manager *TableManager) DeletePathsforPeer(peerInfo *PeerInfo, rf bgp.RouteFamily) ([]Path, error) { if _, ok := manager.Tables[rf]; ok { destinationList := manager.Tables[rf].DeleteDestByPeer(peerInfo) return manager.calculate(destinationList) } - return []Path{}, []Path{}, nil + return []Path{}, nil } -func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Path, error) { +func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, error) { destinationList := make([]Destination, 0) for _, path := range pathList { rf := path.GetRouteFamily() @@ -264,7 +263,7 @@ func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Path, erro // process BGPUpdate message // this function processes only BGPUpdate -func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, []Path, error) { +func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPMessage) ([]Path, error) { // check msg's type if it's BGPUpdate if message.Header.Type != bgp.BGP_MSG_UPDATE { log.WithFields(log.Fields{ @@ -273,7 +272,7 @@ func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPM "key": fromPeer.Address.String(), "Type": message.Header.Type, }).Warn("message is not BGPUpdate") - return []Path{}, []Path{}, nil + return []Path{}, nil } msg := &ProcessMessage{ |