summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/table.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2019-08-27 15:46:32 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-08-27 15:46:32 +0900
commit2682343deac42e6384f915dd5a1cde0154508019 (patch)
tree9fa12cbda7b714109ebb3f43ea55aa222ae40c2e /internal/pkg/table/table.go
parent8e348d6f184db9cd802cb81bf7b4a9dbb338fb74 (diff)
fix duplicated local path id bug
Fix a bug that the same path id is assigned to two paths. The bug happens in the following way: 1. a new path is assigned to a local path id. 2. an import policy dropping the path from the master rib is added and execute softreset in. 3. the path still exists in the adj but doesn't in the master. the path id was freed (marked as unused). 5. a new path with the same prefix comes from another peer. The same id is assigned to the new path. 6 deleted the policy and execute softreset in. 7 there are two paths in the master with the same path id. This path guarantees that only when a path is removed in the adj, the id for path is freed. Note that this doesn't fatten Path strcuture, which should be avoided for any reason. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'internal/pkg/table/table.go')
-rw-r--r--internal/pkg/table/table.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/pkg/table/table.go b/internal/pkg/table/table.go
index c7e505cc..9a9bdd8b 100644
--- a/internal/pkg/table/table.go
+++ b/internal/pkg/table/table.go
@@ -17,6 +17,7 @@ package table
import (
"fmt"
+ "math/bits"
"net"
"strings"
"unsafe"
@@ -118,6 +119,13 @@ func (t *Table) deleteRTCPathsByVrf(vrf *Vrf, vrfs map[string]*Vrf) []*Path {
}
func (t *Table) deleteDest(dest *Destination) {
+ count := 0
+ for _, v := range dest.localIdMap.bitmap {
+ count += bits.OnesCount64(v)
+ }
+ if len(dest.localIdMap.bitmap) != 0 && count != 1 {
+ return
+ }
destinations := t.GetDestinations()
delete(destinations, t.tableKey(dest.GetNlri()))
if len(destinations) == 0 {