diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-02-24 11:12:45 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-02-24 11:16:08 +0000 |
commit | 2c0eddfb9ddbaacf8fdea69d191b7c5857abd938 (patch) | |
tree | 3f5b681ea5fb97a7664328bacc2a0023d91be3b9 | |
parent | 81ffbdf484622065ffc9dae9e28dc1ab83545fc2 (diff) |
table: also sort adj-rib tables when marshaling as well as local-rib
-rw-r--r-- | table/table_manager.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index 10d76565..876ea331 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -17,6 +17,7 @@ package table import ( log "github.com/Sirupsen/logrus" + "github.com/osrg/go-patricia/patricia" "github.com/osrg/gobgp/packet" "reflect" "time" @@ -315,11 +316,18 @@ func (adj *AdjRib) UpdateOut(pathList []Path) { } func (adj *AdjRib) getPathList(rib map[string]*ReceivedRoute) []Path { - pathList := []Path{} - + trie := patricia.NewTrie() for _, rr := range rib { - pathList = append(pathList, rr.path) + key := rr.path.getNlri().String() + trie.Insert(cidr2prefix(key), rr.path) } + + pathList := []Path{} + trie.Visit(func(prefix patricia.Prefix, item patricia.Item) error { + path, _ := item.(Path) + pathList = append(pathList, path) + return nil + }) return pathList } |