Skip to content
Snippets Groups Projects
Commit f3f2d1b8 authored by Maximilian Wilhelm's avatar Maximilian Wilhelm
Browse files

Remove all path for a prefix from an AddPath capabale neighbor if a path with...

Remove all path for a prefix from an AddPath capabale neighbor if a path with NO_EXPORT/NO_ADVERTISE shows up.

Signed-off-by: default avatarMaximilian Wilhelm <max@sdn.clinic>
parent ee160eb1
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,9 @@ func (a *AdjRIBOut) RouteCount() int64 { ...@@ -47,6 +47,9 @@ func (a *AdjRIBOut) RouteCount() int64 {
// AddPath adds path p to prefix `pfx` // AddPath adds path p to prefix `pfx`
func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error { func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error {
if !routingtable.ShouldPropagateUpdate(pfx, p, a.neighbor) { if !routingtable.ShouldPropagateUpdate(pfx, p, a.neighbor) {
if a.neighbor.CapAddPathRX {
a.removePathsForPrefix(pfx)
}
return nil return nil
} }
...@@ -55,6 +58,7 @@ func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error { ...@@ -55,6 +58,7 @@ func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error {
return nil return nil
} }
// If the neighbor is an eBGP peer and not a Route Server client modify ASPath and Next Hop
p = p.Copy() p = p.Copy()
if !a.neighbor.IBGP && !a.neighbor.RouteServerClient { if !a.neighbor.IBGP && !a.neighbor.RouteServerClient {
p.BGPPath.Prepend(a.neighbor.LocalASN, 1) p.BGPPath.Prepend(a.neighbor.LocalASN, 1)
...@@ -130,6 +134,25 @@ func (a *AdjRIBOut) RemovePath(pfx bnet.Prefix, p *route.Path) bool { ...@@ -130,6 +134,25 @@ func (a *AdjRIBOut) RemovePath(pfx bnet.Prefix, p *route.Path) bool {
return true return true
} }
func (a *AdjRIBOut) removePathsForPrefix(pfx bnet.Prefix) bool {
// We were called before a.AddPath() had a lock, so we need to lock here and release it
// after the get to prevent a dead lock as RemovePath() will acquire a lock itself!
a.mu.Lock()
r := a.rt.Get(pfx)
a.mu.Unlock()
// If no path with this prefix is present, we're done
if r == nil {
return false
}
for _, path := range r.Paths() {
a.RemovePath(pfx, path)
}
return true
}
func (a *AdjRIBOut) isOwnPath(p *route.Path) bool { func (a *AdjRIBOut) isOwnPath(p *route.Path) bool {
if p.Type != a.neighbor.Type { if p.Type != a.neighbor.Type {
return false return false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment