Prune routes from routers that are not in your peer graph

This commit is contained in:
Milos Gajdos 2019-10-10 15:25:54 +01:00
parent b2f99a27b7
commit f6931f3da7
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

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)
}
}
}
}
} }
} }
} }