diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 12 | ||||
-rw-r--r-- | server/server_test.go | 2 | ||||
-rw-r--r-- | server/zclient.go | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/server/server.go b/server/server.go index 435c9f72..ba30f578 100644 --- a/server/server.go +++ b/server/server.go @@ -2133,6 +2133,7 @@ type watchOptions struct { preUpdate bool postUpdate bool peerState bool + initBest bool initUpdate bool initPostUpdate bool initPeerState bool @@ -2141,9 +2142,12 @@ type watchOptions struct { type WatchOption func(*watchOptions) -func WatchBestPath() WatchOption { +func WatchBestPath(current bool) WatchOption { return func(o *watchOptions) { o.bestpath = true + if current { + o.initBest = true + } } } @@ -2319,6 +2323,12 @@ func (s *BgpServer) Watch(opts ...WatchOption) (w *Watcher) { w.notify(createWatchEventPeerState(peer)) } } + if w.opts.initBest { + w.notify(&WatchEventBestPath{ + PathList: s.globalRib.GetBestPathList(table.GLOBAL_RIB_NAME, nil), + MultiPathList: s.globalRib.GetBestMultiPathList(table.GLOBAL_RIB_NAME, nil), + }) + } if w.opts.initUpdate { for _, peer := range s.neighborMap { if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED { diff --git a/server/server_test.go b/server/server_test.go index 73eadb0a..5e0dc5e0 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -113,7 +113,7 @@ func TestMonitor(test *testing.T) { } } - w := s.Watch(WatchBestPath()) + w := s.Watch(WatchBestPath(false)) attrs := []bgp.PathAttributeInterface{ bgp.NewPathAttributeOrigin(0), diff --git a/server/zclient.go b/server/zclient.go index df92f038..5f81cfcf 100644 --- a/server/zclient.go +++ b/server/zclient.go @@ -177,7 +177,7 @@ func (z *zebraClient) stop() { } func (z *zebraClient) loop() { - w := z.server.Watch(WatchBestPath()) + w := z.server.Watch(WatchBestPath(true)) defer func() { w.Stop() }() for { |