diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-10 20:57:35 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-14 00:44:15 +0900 |
commit | c0551cffebdf0accc71a4f0b0bf56c374176328c (patch) | |
tree | f499216a80fe9593d31f6eb168969fdf0ea0058c /table | |
parent | 2ef757bc5f71d4131910d0973ffd7026cca73f9f (diff) |
table: remove empty destinations after withdraw
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/table_manager.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index 8eeff459..a40e1221 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -221,17 +221,28 @@ func (manager *TableManager) calculate(ids []string, destinations []*Destination withdrawn := make([]*Path, 0, len(destinations)) best := make(map[string][]*Path, len(ids)) - for _, destination := range destinations { + emptyDsts := make([]*Destination, 0, len(destinations)) + + for _, dst := range destinations { log.WithFields(log.Fields{ "Topic": "table", - "Key": destination.GetNlri().String(), + "Key": dst.GetNlri().String(), }).Debug("Processing destination") - paths, n, w := destination.Calculate(ids) + paths, n, 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 { + emptyDsts = append(emptyDsts, dst) + } + } + + for _, dst := range emptyDsts { + t := manager.Tables[dst.Family()] + t.deleteDest(dst) } return best, newly, withdrawn } |