summaryrefslogtreecommitdiffhomepage
path: root/config/util.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-12-02 16:01:47 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-02 16:02:21 +0900
commita36c84c510bd7cde344e6cbabd043153e4a0196c (patch)
treec9a529ea365def97af86cd5aba6d315aed6671ab /config/util.go
parentb83d3cc802cdaa69b8c77b6db54aa8fe4e472ba7 (diff)
make adj-rib implementation more clear and efficient
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
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
}