From 2682343deac42e6384f915dd5a1cde0154508019 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 27 Aug 2019 15:46:32 +0900 Subject: 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 --- internal/pkg/table/adj.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'internal/pkg/table/adj.go') diff --git a/internal/pkg/table/adj.go b/internal/pkg/table/adj.go index acb2c07b..d434c938 100644 --- a/internal/pkg/table/adj.go +++ b/internal/pkg/table/adj.go @@ -53,6 +53,7 @@ func (adj *AdjRib) Update(pathList []*Path) { adj.accepted[rf]-- } } + path.SetDropped(true) } else { if found { if old.IsAsLooped() && !path.IsAsLooped() { @@ -111,7 +112,9 @@ func (adj *AdjRib) Drop(rfList []bgp.RouteFamily) []*Path { for _, rf := range rfList { if _, ok := adj.table[rf]; ok { for _, p := range adj.table[rf] { - l = append(l, p.Clone(true)) + w := p.Clone(true) + w.SetDropped(true) + l = append(l, w) } adj.table[rf] = make(map[string]*Path) adj.accepted[rf] = 0 @@ -130,7 +133,9 @@ func (adj *AdjRib) DropStale(rfList []bgp.RouteFamily) []*Path { if !p.IsAsLooped() { adj.accepted[rf]-- } - pathList = append(pathList, p.Clone(true)) + w := p.Clone(true) + w.SetDropped(true) + pathList = append(pathList, w) } } } -- cgit v1.2.3