Prune routes from routers that are not in your peer graph
This commit is contained in:
parent
b2f99a27b7
commit
f6931f3da7
@ -497,6 +497,25 @@ func (n *network) prune() {
|
||||
log.Debugf("Network failed pruning peer %s routes: %v", id, err)
|
||||
}
|
||||
}
|
||||
// get a list of all routes
|
||||
routes, err := n.options.Router.Table().List()
|
||||
if err != nil {
|
||||
log.Debugf("Network failed listing routes: %v", err)
|
||||
continue
|
||||
}
|
||||
// collect all the router IDs in the routing table
|
||||
routers := make(map[string]bool)
|
||||
for _, route := range routes {
|
||||
if _, ok := routers[route.Router]; !ok {
|
||||
routers[route.Router] = true
|
||||
// if the router is NOT in our peer graph, delete all routes originated by it
|
||||
if peerNode := n.node.GetPeerNode(route.Router); peerNode == nil {
|
||||
if err := n.pruneRoutes(router.QueryRouter(route.Router)); err != nil {
|
||||
log.Debugf("Network failed deleting routes by %s: %v", route.Router, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user