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 | |
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>
-rw-r--r-- | openswitch/openswitch.go | 4 | ||||
-rw-r--r-- | server/grpc_server.go | 8 | ||||
-rw-r--r-- | server/server.go | 38 |
3 files changed, 14 insertions, 36 deletions
diff --git a/openswitch/openswitch.go b/openswitch/openswitch.go index f1339123..f7206b91 100644 --- a/openswitch/openswitch.go +++ b/openswitch/openswitch.go @@ -320,13 +320,13 @@ func (m *OpsManager) handleBgpRouterUpdate(update ovsdb.TableUpdate) []*server.G newNeighMap := v.New.Fields["bgp_neighbors"].(ovsdb.OvsMap).GoMap for k, _ := range oldNeighMap { if _, ok := newNeighMap[k]; !ok { - reqs = append(reqs, server.NewGrpcRequest(server.REQ_GRPC_DELETE_NEIGHBOR, "", bgp.RouteFamily(0), &api.DeleteNeighborRequest{ + m.grpcServer.DeleteNeighbor(context.Background(), &api.DeleteNeighborRequest{ Peer: &api.Peer{ Conf: &api.PeerConf{ NeighborAddress: k.(string), }, }, - })) + }) } } } diff --git a/server/grpc_server.go b/server/grpc_server.go index 04b74858..e4de06f5 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -46,9 +46,7 @@ const ( REQ_NEIGHBOR_ENABLE REQ_NEIGHBOR_DISABLE REQ_ADD_NEIGHBOR - REQ_DEL_NEIGHBOR - // FIXME: we should merge - REQ_GRPC_DELETE_NEIGHBOR + REQ_DELETE_NEIGHBOR REQ_UPDATE_NEIGHBOR REQ_GLOBAL_RIB REQ_MONITOR_RIB @@ -655,7 +653,9 @@ func (s *Server) AddNeighbor(ctx context.Context, arg *api.AddNeighborRequest) ( } func (s *Server) DeleteNeighbor(ctx context.Context, arg *api.DeleteNeighborRequest) (*api.DeleteNeighborResponse, error) { - d, err := s.get(REQ_GRPC_DELETE_NEIGHBOR, arg) + d, err := s.get(REQ_DELETE_NEIGHBOR, &config.Neighbor{Config: config.NeighborConfig{ + NeighborAddress: arg.Peer.Conf.NeighborAddress, + }}) if err != nil { return nil, err } 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 |