route_bgp: find_conn_for_node prefers live links_up path, fallback to best any
This commit is contained in:
1 parent
80177c9b3e
commit
21da640ebe
1 file changed
+13
-4
+13
-4
@@ -495,14 +495,23 @@ struct ETCP_CONN* route_bgp_find_conn_for_node(struct ROUTE_BGP* bgp, uint64_t n
|
||||
struct NODEINFO_Q* nq = nodeinfo_find_by_id(bgp, node_id);
|
||||
if (!nq || !nq->paths || !nq->paths->head) return NULL;
|
||||
struct ll_entry* e = nq->paths->head;
|
||||
struct NODEINFO_PATH* best = NULL;
|
||||
uint8_t best_hops = 255;
|
||||
struct NODEINFO_PATH* best_live = NULL;
|
||||
uint8_t best_live_hops = 255;
|
||||
struct NODEINFO_PATH* best_any = NULL;
|
||||
uint8_t best_any_hops = 255;
|
||||
while (e) {
|
||||
struct NODEINFO_PATH* path = (struct NODEINFO_PATH*)e;
|
||||
if (path->conn && path->hop_count < best_hops) { best = path; best_hops = path->hop_count; }
|
||||
if (path->conn) {
|
||||
if (path->conn->links_up && path->hop_count < best_live_hops) { best_live = path; best_live_hops = path->hop_count; }
|
||||
if (path->hop_count < best_any_hops) { best_any = path; best_any_hops = path->hop_count; }
|
||||
}
|
||||
e = e->next;
|
||||
}
|
||||
return best ? best->conn : NULL;
|
||||
if (!best_live && best_any) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "find_conn_for_node %016llx: no live paths, fallback to best (hops=%d links_up=%d)",
|
||||
(unsigned long long)node_id, best_any_hops, best_any->conn->links_up);
|
||||
}
|
||||
return best_live ? best_live->conn : (best_any ? best_any->conn : NULL);
|
||||
}
|
||||
|
||||
int route_bgp_add_path(struct NODEINFO_Q* nq, struct ETCP_CONN* conn, uint64_t* hop_list, uint8_t hop_count) {
|
||||
|
||||
Reference in new issue
Block a user