diff options
-rw-r--r-- | server/server.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/server/server.go b/server/server.go index 458703fe..c5c57ddf 100644 --- a/server/server.go +++ b/server/server.go @@ -1472,6 +1472,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { if err != nil { break } + result := &GrpcResponse{} reqApplyPolicy := grpcReq.Data.(*api.ApplyPolicy) reqPolicyMap := server.policyMap applyPolicy := &peer.conf.ApplyPolicy.ApplyPolicyConfig @@ -1509,11 +1510,15 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { grpcReq.RequestType == REQ_NEIGHBOR_POLICY_DEL_DISTRIBUTE { peer.setPolicy(reqPolicyMap) } else { - loc := server.localRibMap[peer.conf.NeighborConfig.NeighborAddress.String()] - loc.setPolicy(peer, reqPolicyMap) + loc, ok := server.localRibMap[peer.conf.NeighborConfig.NeighborAddress.String()] + if ok { + loc.setPolicy(peer, reqPolicyMap) + } else { + result.ResponseErr = fmt.Errorf("no local rib for %s", peer.conf.NeighborConfig.NeighborAddress.String()) + } } - grpcReq.ResponseCh <- &GrpcResponse{} + grpcReq.ResponseCh <- result close(grpcReq.ResponseCh) case REQ_POLICY_PREFIXES, REQ_POLICY_NEIGHBORS, REQ_POLICY_ASPATHS, |