summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/grpc_server.go1
-rw-r--r--server/server.go33
2 files changed, 27 insertions, 7 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 6a4a98cc..e2757d87 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -96,6 +96,7 @@ const (
REQ_BMP_ADJ_IN
REQ_DEFERRAL_TIMER_EXPIRED
REQ_RELOAD_POLICY
+ REQ_INITIALIZE_ZEBRA
)
type Server struct {
diff --git a/server/server.go b/server/server.go
index ce18f2a2..81d678b9 100644
--- a/server/server.go
+++ b/server/server.go
@@ -990,13 +990,21 @@ func (server *BgpServer) SetGlobalType(g config.Global) error {
if err := (<-ch).Err(); err != nil {
return err
}
- if g.Zebra.Enabled {
- cli, err := NewZclient(g.Zebra.Url, g.Zebra.RedistributeRouteTypeList)
- if err != nil {
- return err
- }
- server.zclient = cli
- server.zapiMsgCh = server.zclient.Receive()
+ return nil
+}
+
+func (server *BgpServer) SetZebraConfig(z config.Zebra) error {
+ if !z.Config.Enabled {
+ return nil
+ }
+ ch := make(chan *GrpcResponse)
+ server.GrpcReqCh <- &GrpcRequest{
+ RequestType: REQ_INITIALIZE_ZEBRA,
+ Data: &z.Config,
+ ResponseCh: ch,
+ }
+ if err := (<-ch).Err(); err != nil {
+ return err
}
return nil
}
@@ -2338,6 +2346,17 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
ResponseErr: err,
}
close(grpcReq.ResponseCh)
+ case REQ_INITIALIZE_ZEBRA:
+ c := grpcReq.Data.(*config.ZebraConfig)
+ cli, err := NewZclient(c.Url, c.RedistributeRouteTypeList)
+ if err == nil {
+ server.zclient = cli
+ server.zapiMsgCh = server.zclient.Receive()
+ }
+ grpcReq.ResponseCh <- &GrpcResponse{
+ ResponseErr: err,
+ }
+ close(grpcReq.ResponseCh)
default:
err = fmt.Errorf("Unknown request type: %v", grpcReq.RequestType)
goto ERROR