Merge pull request #837 from milosgajdos83/prune-dead-router-peers

Prune routes from routers that are not in your peer graph
This commit is contained in:
Asim Aslam 2019-10-10 16:12:56 +01:00 committed by GitHub
commit 1be6ec9b3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -497,6 +497,25 @@ func (n *network) prune() {
log.Debugf("Network failed pruning peer %s routes: %v", id, err) 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)
}
}
}
}
} }
} }
} }