summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2017-02-13 06:30:58 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-15 00:10:15 +0900
commit52356c26f821fdebb3fdf943a1b898a2d1b4d0db (patch)
tree0ebe5f222851168489f9118eeb77f71547d5ccb6 /server
parentf276279bf6d90b3f5940bc63780cc3483e9d734e (diff)
server: add a current option to WatchBestPath()
also, use it for zebra integration Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server.go12
-rw-r--r--server/server_test.go2
-rw-r--r--server/zclient.go2
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 {