X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fgraph.c;h=c100a933a6a1abbcde7e53b8ec9bf759caf1a996;hb=c45a3fd7319d03bd147448a017f5aaed3b46fdfe;hp=bf3e75c7f797326802e839d45de60e4ff0866996;hpb=3a149f7521dfff67e6a790c1a830afc649ae083e;p=tinc diff --git a/src/graph.c b/src/graph.c index bf3e75c7..c100a933 100644 --- a/src/graph.c +++ b/src/graph.c @@ -115,11 +115,13 @@ static void mst_kruskal(void) { } } +// Not putting it into header, the outside world doesn't need to know about it. +extern void sssp_bfs(void); + /* Implementation of a simple breadth-first search algorithm. Running time: O(E) */ - -static void sssp_bfs(void) { +void sssp_bfs(void) { list_t *todo_list = list_alloc(NULL); /* Clear visited status on nodes */ @@ -149,7 +151,7 @@ static void sssp_bfs(void) { abort(); } - for splay_each(edge_t, e, n->edge_tree) { /* "e" is the edge connected to "from" */ + for splay_each(edge_t, e, &n->edge_tree) { /* "e" is the edge connected to "from" */ if(!e->reverse || e->to == myself) { continue; } @@ -181,7 +183,7 @@ static void sssp_bfs(void) { // Only update nexthop if it doesn't increase the path length - if(!e->to->status.visited || (e->to->distance == n->distance + 1 && e->weight >= e->to->prevedge->weight)) { + if(!e->to->status.visited || (e->to->distance == n->distance + 1 && e->weight < e->to->prevedge->weight)) { e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; } @@ -307,7 +309,7 @@ static void check_reachability(void) { } void graph(void) { - subnet_cache_flush(); + subnet_cache_flush_tables(); sssp_bfs(); check_reachability(); mst_kruskal();