summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/grpc_server.go10
-rw-r--r--server/server.go24
2 files changed, 16 insertions, 18 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index c6486eac..cd5d6a4e 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -138,14 +138,6 @@ func (s *Server) Serve() error {
}
func (s *Server) GetNeighbor(ctx context.Context, arg *api.GetNeighborRequest) (*api.GetNeighborResponse, error) {
- var rf bgp.RouteFamily
- req := NewGrpcRequest(REQ_NEIGHBOR, "", rf, nil)
- s.bgpServerCh <- req
- res := <-req.ResponseCh
- if res.Err() != nil {
- return nil, res.Err()
- }
-
toApi := func(pconf *config.Neighbor) *api.Peer {
prefixLimits := make([]*api.PrefixLimit, 0, len(pconf.AfiSafis))
for _, family := range pconf.AfiSafis {
@@ -229,7 +221,7 @@ func (s *Server) GetNeighbor(ctx context.Context, arg *api.GetNeighborRequest) (
}
p := []*api.Peer{}
- for _, e := range res.Data.([]*config.Neighbor) {
+ for _, e := range s.bgpServer.GetNeighbor() {
p = append(p, toApi(e))
}
return &api.GetNeighborResponse{Peers: p}, nil
diff --git a/server/server.go b/server/server.go
index 75031f30..35b2388b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1460,15 +1460,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
Data: dsts,
}
close(grpcReq.ResponseCh)
- case REQ_NEIGHBOR:
- l := make([]*config.Neighbor, 0)
- for _, peer := range server.neighborMap {
- l = append(l, peer.ToConfig())
- }
- grpcReq.ResponseCh <- &GrpcResponse{
- Data: l,
- }
- close(grpcReq.ResponseCh)
case REQ_ADJ_RIB_IN, REQ_ADJ_RIB_OUT:
arg := grpcReq.Data.(*api.GetRibRequest)
@@ -1732,6 +1723,21 @@ ERROR:
return
}
+func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) {
+ ch := make(chan struct{})
+ defer func() { <-ch }()
+
+ s.mgmtCh <- func() {
+ defer close(ch)
+
+ l = make([]*config.Neighbor, 0, len(s.neighborMap))
+ for _, peer := range s.neighborMap {
+ l = append(l, peer.ToConfig())
+ }
+ }
+ return l
+}
+
func (server *BgpServer) addNeighbor(c *config.Neighbor) error {
addr := c.Config.NeighborAddress
if _, y := server.neighborMap[addr]; y {