diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-15 09:24:49 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-15 09:24:49 +0900 |
commit | 2c12fa2b92c3372d8639e84be6ee89a9ab581158 (patch) | |
tree | 22de5e752ecb359f319d790bb838eee91123e315 /server/server.go | |
parent | cdca8b5ceffd12ff702903e3369f3cafff2787ae (diff) |
mrt: support per-peer table dump with route server configuration
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/server/server.go b/server/server.go index c0ac7c7c..81950c91 100644 --- a/server/server.go +++ b/server/server.go @@ -2417,6 +2417,7 @@ type watchOptions struct { initUpdate bool initPostUpdate bool initPeerState bool + tableName string } type WatchOption func(*watchOptions) @@ -2454,6 +2455,12 @@ func WatchPeerState(current bool) WatchOption { } } +func WatchTableName(name string) WatchOption { + return func(o *watchOptions) { + o.tableName = name + } +} + type Watcher struct { opts watchOptions realCh chan WatchEvent @@ -2480,11 +2487,25 @@ func (w *Watcher) Generate(t WatchEventType) (err error) { } w.notify(&WatchEventAdjIn{PathList: clonePathList(pathList)}) case WATCH_EVENT_TYPE_TABLE: + id := table.GLOBAL_RIB_NAME + if len(w.opts.tableName) > 0 { + peer, ok := w.s.neighborMap[w.opts.tableName] + if !ok { + err = fmt.Errorf("Neighbor that has %v doesn't exist.", w.opts.tableName) + break + } + if !peer.isRouteServerClient() { + err = fmt.Errorf("Neighbor %v doesn't have local rib", w.opts.tableName) + return + } + id = peer.ID() + } + pathList := func() map[string][]*table.Path { pathList := make(map[string][]*table.Path) for _, t := range w.s.globalRib.Tables { for _, dst := range t.GetSortedDestinations() { - if paths := dst.GetKnownPathList(table.GLOBAL_RIB_NAME); len(paths) > 0 { + if paths := dst.GetKnownPathList(id); len(paths) > 0 { pathList[dst.GetNlri().String()] = clonePathList(paths) } } |