summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-09-02 21:45:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-02 22:25:05 +0900
commit3313e8f8d63e0b502d6324d4d900f32776e11130 (patch)
treed504c8ab355744348c37ff78e33c314596e50734
parent21e90498549fedb59dfe288e866e020bb30e58a3 (diff)
server: guard against nil pointer dereference
non-route-server-client peers don't have local rib. Reported-by: Pavel Odintsov <pavel.odintsov@gmail.com> Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--server/server.go11
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,