summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 13:55:24 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 13:55:24 +0900
commitc0e81a21fb4c1c9f2f0c6597f0f8386288ee5b03 (patch)
tree5d66134179f5cd6aa469d9483f7164562096d2a4 /server/server.go
parente0e421bbca8f620fc40c98de7d8ae386a8f8a6ad (diff)
move gRPC-related code for REQ_NEIGHBOR to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go24
1 files changed, 15 insertions, 9 deletions
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 {