summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-12-15 18:25:50 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-12-15 18:26:32 +0900
commitd6148c75a30d87c3f8c1d0f68725127e4c5f3a65 (patch)
tree42c7df8c6a11187f0d622baa9e0ea45ad6df0cd3 /server
parent1b386f627fb081f4e805a4d7b2f94a14b8790243 (diff)
api: refactor afisafi api
remove unused fields Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/grpc_server.go10
-rw-r--r--server/server.go19
2 files changed, 18 insertions, 11 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index bc0dae4b..85652c75 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -154,7 +154,7 @@ func (s *Server) MonitorBestChanged(arg *api.Arguments, stream api.GobgpApi_Moni
return fmt.Errorf("unsupported resource type: %v", arg.Resource)
}
- req := NewGrpcRequest(reqType, "", bgp.RouteFamily(arg.Rf), nil)
+ req := NewGrpcRequest(reqType, "", bgp.RouteFamily(arg.Family), nil)
s.bgpServerCh <- req
return handleMultipleResponses(req, func(res *GrpcResponse) error {
@@ -174,7 +174,7 @@ func (s *Server) MonitorPeerState(arg *api.Arguments, stream api.GobgpApi_Monito
func (s *Server) neighbor(reqType int, arg *api.Arguments) (*api.Error, error) {
none := &api.Error{}
- req := NewGrpcRequest(reqType, arg.Name, bgp.RouteFamily(arg.Rf), nil)
+ req := NewGrpcRequest(reqType, arg.Name, bgp.RouteFamily(arg.Family), nil)
s.bgpServerCh <- req
res := <-req.ResponseCh
@@ -253,7 +253,7 @@ func (s *Server) GetMrt(arg *api.MrtArguments, stream api.GobgpApi_GetMrtServer)
default:
return fmt.Errorf("unsupported resource type: %v", arg.Resource)
}
- req := NewGrpcRequest(reqType, arg.NeighborAddress, bgp.RouteFamily(arg.Rf), arg.Interval)
+ req := NewGrpcRequest(reqType, arg.NeighborAddress, bgp.RouteFamily(arg.Family), arg.Interval)
s.bgpServerCh <- req
return handleMultipleResponses(req, func(res *GrpcResponse) error {
return stream.Send(res.Data.(*api.MrtMessage))
@@ -269,7 +269,7 @@ func (s *Server) ModRPKI(ctx context.Context, arg *api.ModRpkiArguments) (*api.E
}
func (s *Server) GetRPKI(arg *api.Arguments, stream api.GobgpApi_GetRPKIServer) error {
- req := NewGrpcRequest(REQ_RPKI, "", bgp.RouteFamily(arg.Rf), nil)
+ req := NewGrpcRequest(REQ_RPKI, "", bgp.RouteFamily(arg.Family), nil)
s.bgpServerCh <- req
return handleMultipleResponses(req, func(res *GrpcResponse) error {
@@ -278,7 +278,7 @@ func (s *Server) GetRPKI(arg *api.Arguments, stream api.GobgpApi_GetRPKIServer)
}
func (s *Server) GetROA(arg *api.Arguments, stream api.GobgpApi_GetROAServer) error {
- req := NewGrpcRequest(REQ_ROA, arg.Name, bgp.RouteFamily(arg.Rf), nil)
+ req := NewGrpcRequest(REQ_ROA, arg.Name, bgp.RouteFamily(arg.Family), nil)
s.bgpServerCh <- req
return handleMultipleResponses(req, func(res *GrpcResponse) error {
diff --git a/server/server.go b/server/server.go
index 081717fc..8b12b367 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1865,7 +1865,7 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S
log.Infof("Peer %s is added", addr)
}
SetTcpMD5SigSockopts(listener(net.ParseIP(addr)), addr, arg.Peer.Conf.AuthPassword)
- apitoConfig := func(a *api.Peer) config.Neighbor {
+ apitoConfig := func(a *api.Peer) (config.Neighbor, error) {
var pconf config.Neighbor
if a.Conf != nil {
pconf.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
@@ -1924,9 +1924,13 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S
}
}
}
- if a.Afisafis != nil {
- for _, afisafi := range a.Afisafis.Afisafi {
- cAfiSafi := config.AfiSafi{AfiSafiName: afisafi.Name}
+ if a.Families != nil {
+ for _, family := range a.Families {
+ name, ok := bgp.AddressFamilyNameMap[bgp.RouteFamily(family)]
+ if !ok {
+ return pconf, fmt.Errorf("invalid address family: %d", family)
+ }
+ cAfiSafi := config.AfiSafi{AfiSafiName: name}
pconf.AfiSafis.AfiSafiList = append(pconf.AfiSafis.AfiSafiList, cAfiSafi)
}
} else {
@@ -1942,9 +1946,12 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S
pconf.Transport.TransportConfig.LocalAddress = net.ParseIP(a.Transport.LocalAddress)
pconf.Transport.TransportConfig.PassiveMode = a.Transport.PassiveMode
}
- return pconf
+ return pconf, nil
+ }
+ configneigh, err := apitoConfig(arg.Peer)
+ if err != nil {
+ return nil, err
}
- configneigh := apitoConfig(arg.Peer)
peer := NewPeer(server.bgpConfig.Global, configneigh, server.globalRib, server.policy)
server.setPolicyByConfig(peer.ID(), configneigh.ApplyPolicy)
if peer.isRouteServerClient() {