From ed30b51fe62deb7d96602768391caeea88b1165d Mon Sep 17 00:00:00 2001 From: Oliver Herms Date: Tue, 3 Mar 2020 16:15:19 +0100 Subject: [PATCH] Fix route withdraw when using BGP add path TX --- routingtable/adjRIBOut/adj_rib_out.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/routingtable/adjRIBOut/adj_rib_out.go b/routingtable/adjRIBOut/adj_rib_out.go index fa362fdf..bec06450 100644 --- a/routingtable/adjRIBOut/adj_rib_out.go +++ b/routingtable/adjRIBOut/adj_rib_out.go @@ -185,18 +185,20 @@ func (a *AdjRIBOut) removePath(pfx *bnet.Prefix, p *route.Path) bool { sentPath := p if a.addPathTX { - for _, sentPath := range r.Paths() { - if sentPath.Select(p) != 0 { - continue + for _, sp := range r.Paths() { + if sp.Select(p) == 0 { + a.rt.RemovePath(pfx, sp) + + _, err := a.pathIDManager.releasePath(p) + if err != nil { + log.Warningf("Unable to release path for prefix %s: %v", pfx.String(), err) + return true + } + + sentPath = sp + break } - a.rt.RemovePath(pfx, sentPath) - - _, err := a.pathIDManager.releasePath(p) - if err != nil { - log.Warningf("Unable to release path for prefix %s: %v", pfx.String(), err) - return true - } } if sentPath == p {