summaryrefslogtreecommitdiffhomepage
path: root/table/destination.go
diff options
context:
space:
mode:
Diffstat (limited to 'table/destination.go')
-rw-r--r--table/destination.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/table/destination.go b/table/destination.go
index 15d80e1d..9a26b4d3 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -147,16 +147,21 @@ type Destination struct {
newPathList paths
oldKnownPathList paths
RadixKey string
- localIdMap Bitmap
+ localIdMap *Bitmap
}
-func NewDestination(nlri bgp.AddrPrefixInterface, known ...*Path) *Destination {
+func NewDestination(nlri bgp.AddrPrefixInterface, mapSize int, known ...*Path) *Destination {
d := &Destination{
routeFamily: bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI()),
nlri: nlri,
knownPathList: known,
withdrawList: make([]*Path, 0),
newPathList: make([]*Path, 0),
+ localIdMap: NewBitmap(mapSize),
+ }
+ // the id zero means id is not allocated yet.
+ if mapSize != 0 {
+ d.localIdMap.Flag(0)
}
switch d.routeFamily {
case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC, bgp.RF_IPv4_MPLS, bgp.RF_IPv6_MPLS:
@@ -345,7 +350,12 @@ func (dest *Destination) Calculate() *Destination {
for _, path := range dest.knownPathList {
if path.GetNlri().PathLocalIdentifier() == 0 {
- path.GetNlri().SetPathLocalIdentifier(uint32(dest.localIdMap.FindandSetZeroBit()))
+ id, err := dest.localIdMap.FindandSetZeroBit()
+ if err != nil {
+ dest.localIdMap.Expand()
+ id, _ = dest.localIdMap.FindandSetZeroBit()
+ }
+ path.GetNlri().SetPathLocalIdentifier(uint32(id))
}
}
// Clear new paths as we copied them.
@@ -1022,7 +1032,7 @@ func (old *Destination) Select(option ...DestinationSelectOption) *Destination {
}
}
}
- new := NewDestination(old.nlri)
+ new := NewDestination(old.nlri, 0)
for _, path := range paths {
p := path.Clone(path.IsWithdraw)
p.Filter("", path.Filtered(id))