diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-15 18:25:50 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-15 18:26:32 +0900 |
commit | d6148c75a30d87c3f8c1d0f68725127e4c5f3a65 (patch) | |
tree | 42c7df8c6a11187f0d622baa9e0ea45ad6df0cd3 /server/server.go | |
parent | 1b386f627fb081f4e805a4d7b2f94a14b8790243 (diff) |
api: refactor afisafi api
remove unused fields
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 19 |
1 files changed, 13 insertions, 6 deletions
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() { |