summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/grpc_server.go6
-rw-r--r--server/server.go41
2 files changed, 22 insertions, 25 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 61a80f77..8ad5c3c8 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -1740,11 +1740,7 @@ func (s *Server) StartServer(ctx context.Context, arg *api.StartServerRequest) (
}
func (s *Server) StopServer(ctx context.Context, arg *api.StopServerRequest) (*api.StopServerResponse, error) {
- d, err := s.get(REQ_STOP_SERVER, arg)
- if err != nil {
- return nil, err
- }
- return d.(*api.StopServerResponse), err
+ return &api.StopServerResponse{}, s.bgpServer.Stop()
}
type GrpcRequest struct {
diff --git a/server/server.go b/server/server.go
index dc8ab200..6b15527a 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1317,19 +1317,6 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
c = &b.Global
case *config.Global:
c = arg
- case *api.StopServerRequest:
- for k, _ := range server.neighborMap {
- err := server.deleteNeighbor(&config.Neighbor{Config: config.NeighborConfig{
- NeighborAddress: k}}, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED)
- if err != nil {
- return err
- }
- }
- for _, l := range server.listeners {
- l.Close()
- }
- server.bgpConfig.Global = config.Global{}
- return nil
}
if server.bgpConfig.Global.Config.As != 0 {
@@ -1362,6 +1349,27 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
return nil
}
+func (s *BgpServer) Stop() (err error) {
+ ch := make(chan struct{})
+ defer func() { <-ch }()
+
+ s.mgmtCh <- func() {
+ defer close(ch)
+
+ for k, _ := range s.neighborMap {
+ if err = s.deleteNeighbor(&config.Neighbor{Config: config.NeighborConfig{
+ NeighborAddress: k}}, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED); err != nil {
+ return
+ }
+ }
+ for _, l := range s.listeners {
+ l.Close()
+ }
+ s.bgpConfig.Global = config.Global{}
+ }
+ return nil
+}
+
func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
logOp := func(addr string, action string) {
log.WithFields(log.Fields{
@@ -1406,13 +1414,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
Data: &api.StartServerResponse{},
}
close(grpcReq.ResponseCh)
- case REQ_STOP_SERVER:
- err := server.handleModConfig(grpcReq)
- grpcReq.ResponseCh <- &GrpcResponse{
- ResponseErr: err,
- Data: &api.StopServerResponse{},
- }
- close(grpcReq.ResponseCh)
case REQ_GLOBAL_RIB, REQ_LOCAL_RIB:
arg := grpcReq.Data.(*api.GetRibRequest)
rib := server.globalRib