X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fgraph.c;h=8f20ec7d79ad0fbbe5d2e389314eb33aa67a664e;hb=c32fcdfc1dde289c52bc359b7b6c5f8c30186e58;hp=b4c01bb5ef8b2ec36e660ffd05ec0428c82c18fc;hpb=2eba7933053d7d21bf82e647978ee90abe98dc3a;p=tinc diff --git a/src/graph.c b/src/graph.c index b4c01bb5..8f20ec7d 100644 --- a/src/graph.c +++ b/src/graph.c @@ -53,8 +53,8 @@ #include "names.h" #include "netutl.h" #include "node.h" -#include "process.h" #include "protocol.h" +#include "script.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" @@ -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;