diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-06-11 18:53:54 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-06-16 06:22:11 +0900 |
commit | 5f2b37d487fa815a8ca994edd6d47e0af91b93b2 (patch) | |
tree | 758ddc87cf9e56d7281943bf17a5eb7292f54608 /server | |
parent | 6250195ce4b504aee150eb6004f1de9d98b6ccc4 (diff) |
server: add error handling for grpc
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/grpc_server.go | 3 | ||||
-rw-r--r-- | server/server.go | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index 79a3dc4d..19a2ba28 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -68,6 +68,9 @@ const ( const GRPC_PORT = 8080 func convertAf2Rf(af *api.AddressFamily) (bgp.RouteFamily, error) { + if af == nil { + return bgp.RouteFamily(0), fmt.Errorf("address family is nil") + } if af.Equal(api.AF_IPV4_UC) { return bgp.RF_IPv4_UC, nil } else if af.Equal(api.AF_IPV6_UC) { diff --git a/server/server.go b/server/server.go index e15e1360..105cdccb 100644 --- a/server/server.go +++ b/server/server.go @@ -1384,6 +1384,13 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { server.handlePolicy(server.routingPolicy) grpcReq.ResponseCh <- result close(grpcReq.ResponseCh) + default: + errmsg := "Unknown request type" + result := &GrpcResponse{ + ResponseErr: fmt.Errorf(errmsg), + } + grpcReq.ResponseCh <- result + close(grpcReq.ResponseCh) } return msgs } |