summaryrefslogtreecommitdiffhomepage
path: root/config/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/util.go')
-rw-r--r--config/util.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/config/util.go b/config/util.go
index a3606682..50d1b833 100644
--- a/config/util.go
+++ b/config/util.go
@@ -34,11 +34,23 @@ func IsEBGPPeer(g *Global, p *Neighbor) bool {
return p.NeighborConfig.PeerAs != g.GlobalConfig.As
}
+func (c AfiSafis) ToRfList() ([]bgp.RouteFamily, error) {
+ rfs := make([]bgp.RouteFamily, 0, len(c.AfiSafiList))
+ for _, rf := range c.AfiSafiList {
+ k, err := bgp.GetRouteFamily(rf.AfiSafiName)
+ if err != nil {
+ return nil, err
+ }
+ rfs = append(rfs, k)
+ }
+ return rfs, nil
+}
+
func CreateRfMap(p *Neighbor) map[bgp.RouteFamily]bool {
+ rfs, _ := p.AfiSafis.ToRfList()
rfMap := make(map[bgp.RouteFamily]bool)
- for _, rf := range p.AfiSafis.AfiSafiList {
- k, _ := bgp.GetRouteFamily(rf.AfiSafiName)
- rfMap[k] = true
+ for _, rf := range rfs {
+ rfMap[rf] = true
}
return rfMap
}