diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-06 09:37:17 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-07-20 04:25:25 +0900 |
commit | 804973bff5110b1c925167d6e8da6b188b63eb0a (patch) | |
tree | 13893e49735c0fa81a1f1f3ba765238cc364d22d /server/server.go | |
parent | d59f1b147eba8199458df22bba1d2462b65a2308 (diff) |
remove REQ_GRPC_DELETE_NEIGHBOR
replace REQ_GRPC_DELETE_NEIGHBOR with REQ_DEL_NEIGHBOR
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, 8 insertions, 30 deletions
diff --git a/server/server.go b/server/server.go index 602867fb..8552810c 100644 --- a/server/server.go +++ b/server/server.go @@ -915,7 +915,7 @@ func (server *BgpServer) PeerAdd(peer config.Neighbor) error { func (server *BgpServer) PeerDelete(peer config.Neighbor) error { ch := make(chan *GrpcResponse) server.GrpcReqCh <- &GrpcRequest{ - RequestType: REQ_DEL_NEIGHBOR, + RequestType: REQ_DELETE_NEIGHBOR, Data: &peer, ResponseCh: ch, } @@ -1445,15 +1445,8 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error { c = arg case *api.StopServerRequest: for k, _ := range server.neighborMap { - err := server.handleDeleteNeighborRequest(&GrpcRequest{ - Data: &api.DeleteNeighborRequest{ - Peer: &api.Peer{ - Conf: &api.PeerConf{ - NeighborAddress: k, - }, - }, - }, - }) + err := server.handleDeleteNeighbor(&config.Neighbor{Config: config.NeighborConfig{ + NeighborAddress: k}}, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED) if err != nil { return err } @@ -1937,13 +1930,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { } grpcReq.ResponseCh <- result close(grpcReq.ResponseCh) - case REQ_GRPC_DELETE_NEIGHBOR: - err := server.handleDeleteNeighborRequest(grpcReq) - grpcReq.ResponseCh <- &GrpcResponse{ - Data: &api.DeleteNeighborResponse{}, - ResponseErr: err, - } - close(grpcReq.ResponseCh) case REQ_ADD_NEIGHBOR: err := server.handleAddNeighbor(grpcReq.Data.(*config.Neighbor)) grpcReq.ResponseCh <- &GrpcResponse{ @@ -1951,9 +1937,10 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { ResponseErr: err, } close(grpcReq.ResponseCh) - case REQ_DEL_NEIGHBOR: - err := server.handleDelNeighbor(grpcReq.Data.(*config.Neighbor), bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED) + case REQ_DELETE_NEIGHBOR: + err := server.handleDeleteNeighbor(grpcReq.Data.(*config.Neighbor), bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED) grpcReq.ResponseCh <- &GrpcResponse{ + Data: &api.DeleteNeighborResponse{}, ResponseErr: err, } close(grpcReq.ResponseCh) @@ -2224,7 +2211,7 @@ func (server *BgpServer) handleAddNeighbor(c *config.Neighbor) error { return nil } -func (server *BgpServer) handleDelNeighbor(c *config.Neighbor, code, subcode uint8) error { +func (server *BgpServer) handleDeleteNeighbor(c *config.Neighbor, code, subcode uint8) error { addr := c.Config.NeighborAddress n, y := server.neighborMap[addr] if !y { @@ -2286,7 +2273,7 @@ func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) (bool, error) } else if original.Config.PeerAs != c.Config.PeerAs { sub = bgp.BGP_ERROR_SUB_PEER_DECONFIGURED } - if err := server.handleDelNeighbor(peer.fsm.pConf, bgp.BGP_ERROR_CEASE, sub); err != nil { + if err := server.handleDeleteNeighbor(peer.fsm.pConf, bgp.BGP_ERROR_CEASE, sub); err != nil { log.WithFields(log.Fields{ "Topic": "Peer", "Key": addr, @@ -2323,15 +2310,6 @@ func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) (bool, error) return policyUpdated, err } -func (server *BgpServer) handleDeleteNeighborRequest(grpcReq *GrpcRequest) error { - arg := grpcReq.Data.(*api.DeleteNeighborRequest) - return server.handleDelNeighbor(&config.Neighbor{ - Config: config.NeighborConfig{ - NeighborAddress: arg.Peer.Conf.NeighborAddress, - }, - }, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED) -} - func (server *BgpServer) handleGrpcAddDefinedSet(grpcReq *GrpcRequest) (*api.AddDefinedSetResponse, error) { arg := grpcReq.Data.(*api.AddDefinedSetRequest) set := arg.Set |