diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-17 08:50:55 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-17 08:52:28 +0900 |
commit | 8fd25af4ce9ab902e24eb06644ef2e9c42cee7e0 (patch) | |
tree | fca38cf5df338ca0abae36c4579fb551fef2a66d /server | |
parent | 949c58fbf6d5ccb79ee87a5105968d3fe591a3a9 (diff) |
zebra: make zebra config consistent with the rests
- split config and state
- move to Bgp structure (aligned with Rpki, Bmp, and Mrt)
Also makes zebra configured via GRPC channel.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/grpc_server.go | 1 | ||||
-rw-r--r-- | server/server.go | 33 |
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 |