summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-10 12:18:29 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-14 00:44:15 +0900
commit7d68855c86daa8fa8202f5cbdf585d9d8c1d3d21 (patch)
tree0bcc5384b45f7d5461c5a759413accda1b29b9de /table/table_manager.go
parentce5917c0a8d6206fd1d70a5a476eb99e510fc9f6 (diff)
table: remove Destination's WithdrawnList and UpdatedPathList used for validation
Withdrawn pathes are kept to be referenced thus the memory for them are not freed. Nobody uses this so let's remove it. Paths in UpdatedPathList are also in KnownPathList so doesn't lead to memory leak. But remove it for simplicity. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go24
1 files changed, 15 insertions, 9 deletions
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