Skip to content
Snippets Groups Projects
Unverified Commit 146342ba authored by Daniel Czerwonk's avatar Daniel Czerwonk Committed by GitHub
Browse files

Merge pull request #81 from BarbarossaTM/unfuck/AddPath

AdjRIBOut: Don't add PathIdentifier without AddPath capabilities and don't add path twice.
parents 3d25ad5d c915fc9b
No related branches found
No related tags found
No related merge requests found
......@@ -69,19 +69,21 @@ func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error {
a.mu.Lock()
defer a.mu.Unlock()
if !a.neighbor.CapAddPathRX {
// AddPathRX capable neighbor
if a.neighbor.CapAddPathRX {
pathID, err := a.pathIDManager.addPath(p)
if err != nil {
return fmt.Errorf("Unable to get path ID: %v", err)
}
p.BGPPath.PathIdentifier = pathID
a.rt.AddPath(pfx, p)
} else {
// rt.ReplacePath will add this path to the rt in any case, so no rt.AddPath here!
oldPaths := a.rt.ReplacePath(pfx, p)
a.removePathsFromClients(pfx, oldPaths)
}
pathID, err := a.pathIDManager.addPath(p)
if err != nil {
return fmt.Errorf("Unable to get path ID: %v", err)
}
p.BGPPath.PathIdentifier = pathID
a.rt.AddPath(pfx, p)
for _, client := range a.ClientManager.Clients() {
err := client.AddPath(pfx, p)
if err != nil {
......@@ -166,3 +168,17 @@ func (a *AdjRIBOut) Print() string {
return ret
}
// Dump all routes present in this AdjRIBOut
func (a *AdjRIBOut) Dump() string {
a.mu.RLock()
defer a.mu.RUnlock()
ret := fmt.Sprintf("DUMPING ADJ-RIB-OUT:\n")
routes := a.rt.Dump()
for _, r := range routes {
ret += fmt.Sprintf("%s\n", r.Print())
}
return ret
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment