summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table
diff options
context:
space:
mode:
authorHitoshi Irino <irino@sfc.wide.ad.jp>2019-03-17 20:47:05 +0900
committerHitoshi Irino <irino@sfc.wide.ad.jp>2019-03-17 20:47:05 +0900
commit276518c8269a2403bf79cdeba7c33b644c238214 (patch)
tree7bfe5d74ee577e6b0e08cf147904b7a35ef0ad8c /internal/pkg/table
parent6345fdd20a172fc2e568487c391246307b9cd757 (diff)
Deleteing goroutine for assignMplsLabel and moveing code relating MPLS L3VPN (introduced from PR osrg#1992, commit 3a79ad3) from table_manager.go to zclient.go
Diffstat (limited to 'internal/pkg/table')
-rw-r--r--internal/pkg/table/table_manager.go65
1 files changed, 3 insertions, 62 deletions
diff --git a/internal/pkg/table/table_manager.go b/internal/pkg/table/table_manager.go
index 9ee57a71..57533322 100644
--- a/internal/pkg/table/table_manager.go
+++ b/internal/pkg/table/table_manager.go
@@ -105,10 +105,9 @@ func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo, timestamp time.Time)
}
type TableManager struct {
- Tables map[bgp.RouteFamily]*Table
- Vrfs map[string]*Vrf
- rfList []bgp.RouteFamily
- mplsLabelMaps map[uint64]*Bitmap
+ Tables map[bgp.RouteFamily]*Table
+ Vrfs map[string]*Vrf
+ rfList []bgp.RouteFamily
}
func NewTableManager(rfList []bgp.RouteFamily) *TableManager {
@@ -123,63 +122,6 @@ func NewTableManager(rfList []bgp.RouteFamily) *TableManager {
return t
}
-func (manager *TableManager) EnableMplsLabelAllocation() error {
- if manager.mplsLabelMaps != nil {
- return fmt.Errorf("label allocation already enabled")
- }
- manager.mplsLabelMaps = make(map[uint64]*Bitmap)
- return nil
-}
-
-func (manager *TableManager) AllocateMplsLabelRange(start, end uint32) error {
- if manager.mplsLabelMaps == nil {
- return fmt.Errorf("label allocation not yet enabled")
- }
- log.WithFields(log.Fields{
- "Topic": "Vrf",
- "Start": start,
- "End": end,
- }).Debug("allocate new MPLS label range")
- startEnd := uint64(start)<<32 | uint64(end)
- manager.mplsLabelMaps[startEnd] = NewBitmap(int(end - start + 1))
- return nil
-}
-
-func (manager *TableManager) AssignMplsLabel() (uint32, error) {
- if manager.mplsLabelMaps == nil {
- return 0, nil
- }
- var label uint32
- for startEnd, bitmap := range manager.mplsLabelMaps {
- start := uint32(startEnd >> 32)
- end := uint32(startEnd & 0xffffffff)
- l, err := bitmap.FindandSetZeroBit()
- if err == nil && start+uint32(l) <= end {
- label = start + uint32(l)
- break
- }
- }
- if label == 0 {
- return 0, fmt.Errorf("could not assign new MPLS label; need to allocate new MPLS label range")
- }
- return label, nil
-}
-
-func (manager *TableManager) releaseMplsLabel(label uint32) {
- if manager.mplsLabelMaps == nil {
- return
- }
- for startEnd, bitmap := range manager.mplsLabelMaps {
- start := uint32(startEnd >> 32)
- end := uint32(startEnd & 0xffffffff)
- if start <= label && label <= end {
- bitmap.Unflag(uint(label - start))
- return
- }
- }
- //return
-}
-
func (manager *TableManager) GetRFlist() []bgp.RouteFamily {
return manager.rfList
}
@@ -231,7 +173,6 @@ func (manager *TableManager) DeleteVrf(name string) ([]*Path, error) {
"ExportRt": vrf.ExportRt,
"MplsLabel": vrf.MplsLabel,
}).Debugf("delete vrf")
- manager.releaseMplsLabel(vrf.MplsLabel)
delete(manager.Vrfs, name)
rtcTable := manager.Tables[bgp.RF_RTC_UC]
msgs = append(msgs, rtcTable.deleteRTCPathsByVrf(vrf, manager.Vrfs)...)