summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
Diffstat (limited to 'table')
-rw-r--r--table/destination.go11
-rw-r--r--table/table_manager.go24
-rw-r--r--table/table_manager_test.go2
3 files changed, 20 insertions, 17 deletions
diff --git a/table/destination.go b/table/destination.go
index f323a6d7..31072561 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -117,8 +117,6 @@ type Destination struct {
knownPathList paths
withdrawList paths
newPathList paths
- WithdrawnList paths
- UpdatedPathList paths
RadixKey string
}
@@ -236,15 +234,13 @@ func (dd *Destination) validatePath(path *Path) {
// Calculates best-path among known paths for this destination.
//
-// Returns: - Best 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() {
+func (dest *Destination) Calculate() ([]*Path, []*Path) {
dest.oldKnownPathList = dest.knownPathList
- dest.UpdatedPathList = dest.newPathList
+ updated := dest.newPathList
// First remove the withdrawn paths.
- dest.WithdrawnList = dest.explicitWithdraw()
+ withdrawnList := dest.explicitWithdraw()
// Do implicit withdrawal
dest.implicitWithdraw()
// Collect all new paths into known paths.
@@ -253,6 +249,7 @@ func (dest *Destination) Calculate() {
dest.newPathList = make([]*Path, 0)
// Compute new best path
dest.computeKnownBestPath()
+ return updated, withdrawnList
}
func (dest *Destination) NewFeed(id string) *Path {
diff --git a/table/table_manager.go b/table/table_manager.go
index afb4deac..f908bd69 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -216,26 +216,32 @@ func (manager *TableManager) DeleteVrf(name string) ([]*Path, error) {
return msgs, nil
}
-func (manager *TableManager) calculate(destinations []*Destination) {
+func (manager *TableManager) calculate(destinations []*Destination) ([]*Path, []*Path) {
+ newly := make([]*Path, 0, len(destinations))
+ withdrawn := make([]*Path, 0, len(destinations))
for _, destination := range destinations {
log.WithFields(log.Fields{
"Topic": "table",
"Key": destination.GetNlri().String(),
}).Debug("Processing destination")
- destination.Calculate()
+ n, w := destination.Calculate()
+ newly = append(newly, n...)
+ withdrawn = append(withdrawn, w...)
}
+ return newly, withdrawn
}
-func (manager *TableManager) DeletePathsByPeer(info *PeerInfo, rf bgp.RouteFamily) []*Destination {
+func (manager *TableManager) DeletePathsByPeer(info *PeerInfo, rf bgp.RouteFamily) ([]*Destination, []*Path) {
if t, ok := manager.Tables[rf]; ok {
dsts := t.DeleteDestByPeer(info)
- manager.calculate(dsts)
- return dsts
+ // no newly added paths
+ _, withdrawn := manager.calculate(dsts)
+ return dsts, withdrawn
}
- return nil
+ return nil, nil
}
-func (manager *TableManager) ProcessPaths(pathList []*Path) []*Destination {
+func (manager *TableManager) ProcessPaths(pathList []*Path) ([]*Destination, []*Path, []*Path) {
m := make(map[string]bool, len(pathList))
dsts := make([]*Destination, 0, len(pathList))
for _, path := range pathList {
@@ -261,8 +267,8 @@ func (manager *TableManager) ProcessPaths(pathList []*Path) []*Destination {
}
}
}
- manager.calculate(dsts)
- return dsts
+ newly, withdrawn := manager.calculate(dsts)
+ return dsts, newly, withdrawn
}
// EVPN MAC MOBILITY HANDLING
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index 02d96299..becf69a1 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())
- dsts := manager.ProcessPaths(paths)
+ dsts, _, _ := manager.ProcessPaths(paths)
paths2 := make([]*Path, 0, len(paths))
for _, dst := range dsts {
p := dst.NewFeed(GLOBAL_RIB_NAME)