diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-20 23:07:35 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-21 05:50:54 +0900 |
commit | bbc852d613b008921112007b32b9c1435086d0aa (patch) | |
tree | e212f37b5b2a6784b2625f137d11f8e99467b705 | |
parent | e61a344e69cdc156ec32eced0267976e90fcfb2b (diff) |
table: store the list of route family in TableManager
Will be used later to avoid generate the list of route family every
time.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/server.go | 8 | ||||
-rw-r--r-- | table/table_manager.go | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/server/server.go b/server/server.go index 936734c0..abb2c1fd 100644 --- a/server/server.go +++ b/server/server.go @@ -200,17 +200,15 @@ func (server *BgpServer) Serve() { } }(broadcastCh) - // FIXME - rfList := func(l []config.AfiSafi) []bgp.RouteFamily { + toRFlist := func(l []config.AfiSafi) []bgp.RouteFamily { rfList := []bgp.RouteFamily{} for _, rf := range l { k, _ := bgp.GetRouteFamily(rf.AfiSafiName) rfList = append(rfList, k) } return rfList - }(g.AfiSafis.AfiSafiList) - - server.globalRib = table.NewTableManager(GLOBAL_RIB_NAME, rfList, g.MplsLabelRange.MinLabel, g.MplsLabelRange.MaxLabel) + } + server.globalRib = table.NewTableManager(GLOBAL_RIB_NAME, toRFlist(g.AfiSafis.AfiSafiList), g.MplsLabelRange.MinLabel, g.MplsLabelRange.MaxLabel) listenerMap := make(map[string]*net.TCPListener) acceptCh := make(chan *net.TCPConn) l4, err1 := listenAndAccept("tcp4", server.listenPort, acceptCh) diff --git a/table/table_manager.go b/table/table_manager.go index 8ca127d6..acd23676 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -113,6 +113,7 @@ type TableManager struct { minLabel uint32 maxLabel uint32 nextLabel uint32 + rfList []bgp.RouteFamily importPolicies []*Policy defaultImportPolicy RouteType exportPolicies []*Policy @@ -127,6 +128,7 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily, minLabel, maxLabel minLabel: minLabel, maxLabel: maxLabel, nextLabel: minLabel, + rfList: rfList, } for _, rf := range rfList { t.Tables[rf] = NewTable(rf) @@ -134,6 +136,10 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily, minLabel, maxLabel return t } +func (manager *TableManager) GetRFlist() []bgp.RouteFamily { + return manager.rfList +} + func (manager *TableManager) GetPolicy(d PolicyDirection) []*Policy { switch d { case POLICY_DIRECTION_IMPORT: |