diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-26 16:01:20 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-26 16:01:20 +0900 |
commit | 5966466632bd73676ec80ca71c5082f88cb65bd6 (patch) | |
tree | fecd12fd6d7f02e5efb79f3d9511161fd0fa56a6 /server/server.go | |
parent | e7354de8bbc20bc507723dc185940f7368723ca4 (diff) |
move gRPC-related code for REQ_GET_VRF to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/server/server.go b/server/server.go index 17d42ce5..82195a93 100644 --- a/server/server.go +++ b/server/server.go @@ -1247,12 +1247,6 @@ func (server *BgpServer) handleVrfRequest(req *GrpcRequest) []*table.Path { Data: paths, } goto END - case REQ_GET_VRF: - l := make([]*table.Vrf, 0, len(server.globalRib.Vrfs)) - for _, vrf := range server.globalRib.Vrfs { - l = append(l, vrf.Clone()) - } - result.Data = l case REQ_ADD_VRF: msgs, result.ResponseErr = server.handleAddVrfRequest(req) result.Data = &api.AddVrfResponse{} @@ -1309,6 +1303,21 @@ func (s *BgpServer) Start(c *config.Global) (err error) { return nil } +func (s *BgpServer) GetVrf() (l []*table.Vrf) { + ch := make(chan struct{}) + defer func() { <-ch }() + + s.mgmtCh <- func() { + defer close(ch) + + l = make([]*table.Vrf, 0, len(s.globalRib.Vrfs)) + for _, vrf := range s.globalRib.Vrfs { + l = append(l, vrf.Clone()) + } + } + return l +} + func (s *BgpServer) Stop() (err error) { ch := make(chan struct{}) defer func() { <-ch }() @@ -1693,7 +1702,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { rsp := server.roaManager.handleGRPC(grpcReq) grpcReq.ResponseCh <- rsp close(grpcReq.ResponseCh) - case REQ_VRF, REQ_GET_VRF, REQ_ADD_VRF, REQ_DELETE_VRF: + case REQ_VRF, REQ_ADD_VRF, REQ_DELETE_VRF: pathList := server.handleVrfRequest(grpcReq) if len(pathList) > 0 { server.propagateUpdate(nil, pathList) |