summaryrefslogtreecommitdiffhomepage
path: root/server/monitor.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-06-02 05:53:02 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-06 12:43:20 +0900
commitc96b6d119849677aa8db8298a412f7ff501b879a (patch)
tree0dd3448f6a5a54a7bea082018c50492275f20630 /server/monitor.go
parentc54f6e8289dd4f8b3df1d78b37e4cad9c601c7d1 (diff)
server: support monitoring multipath via gRPC
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/monitor.go')
-rw-r--r--server/monitor.go34
1 files changed, 26 insertions, 8 deletions
diff --git a/server/monitor.go b/server/monitor.go
index e8e7df4d..35c14eca 100644
--- a/server/monitor.go
+++ b/server/monitor.go
@@ -85,16 +85,20 @@ func (w *grpcWatcher) loop() error {
reqs = append(reqs, req)
w.reqs[reqType] = reqs
case ev := <-w.ch:
- sendPaths := func(reqType watcherEventType, paths []*table.Path) {
- for _, path := range paths {
- if path == nil {
+ sendMultiPaths := func(reqType watcherEventType, dsts [][]*table.Path) {
+ for _, dst := range dsts {
+ paths := make([]*api.Path, 0, len(dst))
+ for _, path := range dst {
+ paths = append(paths, path.ToApiStruct(table.GLOBAL_RIB_NAME))
+ }
+ if len(paths) == 0 {
continue
}
remains := make([]*GrpcRequest, 0, len(w.reqs[reqType]))
result := &GrpcResponse{
Data: &api.Destination{
- Prefix: path.GetNlri().String(),
- Paths: []*api.Path{path.ToApiStruct(table.GLOBAL_RIB_NAME)},
+ Prefix: dst[0].GetNlri().String(),
+ Paths: paths,
},
}
for _, req := range w.reqs[reqType] {
@@ -104,10 +108,10 @@ func (w *grpcWatcher) loop() error {
default:
}
remains = append(remains, req)
- if req.RouteFamily != bgp.RouteFamily(0) && req.RouteFamily != path.GetRouteFamily() {
+ if req.RouteFamily != bgp.RouteFamily(0) && req.RouteFamily != dst[0].GetRouteFamily() {
continue
}
- if req.Name != "" && req.Name != path.GetSource().Address.String() {
+ if req.Name != "" && req.Name != paths[0].NeighborIp {
continue
}
req.ResponseCh <- result
@@ -115,9 +119,23 @@ func (w *grpcWatcher) loop() error {
w.reqs[reqType] = remains
}
}
+ sendPaths := func(reqType watcherEventType, paths []*table.Path) {
+ dsts := make([][]*table.Path, 0, len(paths))
+ for _, path := range paths {
+ if path == nil {
+ continue
+ }
+ dsts = append(dsts, []*table.Path{path})
+ }
+ sendMultiPaths(reqType, dsts)
+ }
switch msg := ev.(type) {
case *watcherEventBestPathMsg:
- sendPaths(WATCHER_EVENT_BESTPATH_CHANGE, msg.pathList)
+ if table.UseMultiplePaths.Enabled {
+ sendMultiPaths(WATCHER_EVENT_BESTPATH_CHANGE, msg.multiPathList)
+ } else {
+ sendPaths(WATCHER_EVENT_BESTPATH_CHANGE, msg.pathList)
+ }
case *watcherEventUpdateMsg:
if msg.postPolicy {
sendPaths(WATCHER_EVENT_POST_POLICY_UPDATE_MSG, msg.pathList)