X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fgraph.c;h=8f20ec7d79ad0fbbe5d2e389314eb33aa67a664e;hb=c32fcdfc1dde289c52bc359b7b6c5f8c30186e58;hp=396e35a3e68d2e9373a6dde4a753402ad7d4228f;hpb=57991e264202ad83e2c1b663777b358bf5573652;p=tinc diff --git a/src/graph.c b/src/graph.c index 396e35a3..8f20ec7d 100644 --- a/src/graph.c +++ b/src/graph.c @@ -176,9 +176,13 @@ static void sssp_bfs(void) { && (e->to->distance != n->distance + 1 || e->weight >= e->to->prevedge->weight)) continue; + // 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)) + e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; + e->to->status.visited = true; e->to->status.indirect = indirect; - e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; e->to->prevedge = e; e->to->via = indirect ? n->via : e->to; e->to->options = e->options;