diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-27 19:40:44 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-27 19:40:44 +0900 |
commit | 28ff2fa2ec6ae6e6e0e2d2bfb35820ac086e49b1 (patch) | |
tree | c3fb8621e86275e8134fb7ca9bef39135fe9b9ba /server/server.go | |
parent | 7ed162a4786b775376dcf884fdeb1a4d59301870 (diff) |
move gRPC-related code for REQ_VALIDATE_RIB 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 | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/server/server.go b/server/server.go index 5d01ecfa..10ee11aa 100644 --- a/server/server.go +++ b/server/server.go @@ -1623,8 +1623,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { } grpcReq.ResponseCh <- &GrpcResponse{Data: &api.SoftResetNeighborResponse{}} close(grpcReq.ResponseCh) - case REQ_VALIDATE_RIB: - server.handleValidateRib(grpcReq) case REQ_INITIALIZE_RPKI: g := grpcReq.Data.(*config.Global) grpcDone(grpcReq, server.roaManager.SetAS(g.Config.As)) @@ -2622,27 +2620,29 @@ func (s *BgpServer) DisableMrt() (err error) { return err } -func (server *BgpServer) handleValidateRib(grpcReq *GrpcRequest) { - arg := grpcReq.Data.(*api.ValidateRibRequest) - for _, rf := range server.globalRib.GetRFlist() { - if t, ok := server.globalRib.Tables[rf]; ok { - dsts := t.GetDestinations() - if arg.Prefix != "" { - _, prefix, _ := net.ParseCIDR(arg.Prefix) - if dst := t.GetDestination(prefix.String()); dst != nil { - dsts = map[string]*table.Destination{prefix.String(): dst} +func (s *BgpServer) ValidateRib(prefix string) (err error) { + ch := make(chan struct{}) + defer func() { <-ch }() + + s.mgmtCh <- func() { + defer close(ch) + + for _, rf := range s.globalRib.GetRFlist() { + if t, ok := s.globalRib.Tables[rf]; ok { + dsts := t.GetDestinations() + if prefix != "" { + _, p, _ := net.ParseCIDR(prefix) + if dst := t.GetDestination(p.String()); dst != nil { + dsts = map[string]*table.Destination{p.String(): dst} + } + } + for _, dst := range dsts { + s.roaManager.validate(dst.GetAllKnownPathList()) } - } - for _, dst := range dsts { - server.roaManager.validate(dst.GetAllKnownPathList()) } } } - result := &GrpcResponse{ - Data: &api.ValidateRibResponse{}, - } - grpcReq.ResponseCh <- result - close(grpcReq.ResponseCh) + return err } func (server *BgpServer) handleModRpki(grpcReq *GrpcRequest) { |