diff options
-rw-r--r-- | api/grpc_server.go | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go index 65ea21f9..f445ab3a 100644 --- a/api/grpc_server.go +++ b/api/grpc_server.go @@ -89,6 +89,12 @@ func (s *Server) Serve() error { } func NewPeerFromConfigStruct(pconf *config.Neighbor) *Peer { + var families []uint32 + for _, f := range pconf.AfiSafis { + if family, ok := bgp.AddressFamilyValueMap[string(f.Config.AfiSafiName)]; ok { + families = append(families, uint32(family)) + } + } prefixLimits := make([]*PrefixLimit, 0, len(pconf.AfiSafis)) for _, family := range pconf.AfiSafis { if c := family.PrefixLimit.Config; c.MaxPrefixes > 0 { @@ -117,6 +123,7 @@ func NewPeerFromConfigStruct(pconf *config.Neighbor) *Peer { localCap = append(localCap, c) } return &Peer{ + Families: families, Conf: &PeerConf{ NeighborAddress: pconf.Config.NeighborAddress, Id: s.RemoteRouterId, @@ -883,20 +890,6 @@ func NewNeighborFromAPIStruct(a *Peer) (*config.Neighbor, error) { } } } - 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{ - Config: config.AfiSafiConfig{ - AfiSafiName: config.AfiSafiType(name), - }, - } - pconf.AfiSafis = append(pconf.AfiSafis, cAfiSafi) - } - } if a.Transport != nil { pconf.Transport.Config.LocalAddress = a.Transport.LocalAddress pconf.Transport.Config.PassiveMode = a.Transport.PassiveMode |