|
|
|
|
@ -245,33 +245,36 @@ static void conn_probe_single_cb(int success, uint16_t rtt, void* arg,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void conn_probe_finish(struct conn_probe_ctx* ctx, int ok) { |
|
|
|
|
if (!ctx || !ctx->nq) return; |
|
|
|
|
struct NODE_CONNECTIVITY* c = &ctx->nq->connectivity; |
|
|
|
|
|
|
|
|
|
switch (ctx->addr_type) { |
|
|
|
|
case ADDR_TYPE_INTERFACE: |
|
|
|
|
c->interface_status = ok ? PROBE_RESULT_REACHABLE : (c->interface_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->interface_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->interface_min_rtt) c->interface_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->interface_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
case ADDR_TYPE_NAT: |
|
|
|
|
c->nat_status = ok ? PROBE_RESULT_REACHABLE : (c->nat_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->nat_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->nat_min_rtt) c->nat_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->nat_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
case ADDR_TYPE_REAL: |
|
|
|
|
c->real_status = ok ? PROBE_RESULT_REACHABLE : (c->real_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->real_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->real_min_rtt) c->real_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->real_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (!ctx) return; |
|
|
|
|
if (ctx->nq) { |
|
|
|
|
struct NODE_CONNECTIVITY* c = &ctx->nq->connectivity; |
|
|
|
|
if (c->probe_ctx == ctx) c->probe_ctx = NULL; |
|
|
|
|
|
|
|
|
|
switch (ctx->addr_type) { |
|
|
|
|
case ADDR_TYPE_INTERFACE: |
|
|
|
|
c->interface_status = ok ? PROBE_RESULT_REACHABLE : (c->interface_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->interface_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->interface_min_rtt) c->interface_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->interface_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
case ADDR_TYPE_NAT: |
|
|
|
|
c->nat_status = ok ? PROBE_RESULT_REACHABLE : (c->nat_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->nat_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->nat_min_rtt) c->nat_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->nat_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
case ADDR_TYPE_REAL: |
|
|
|
|
c->real_status = ok ? PROBE_RESULT_REACHABLE : (c->real_status == PROBE_RESULT_UNKNOWN ? PROBE_RESULT_UNREACHABLE : c->real_status); |
|
|
|
|
if (ok && ctx->best_across_sockets < c->real_min_rtt) c->real_min_rtt = ctx->best_across_sockets; |
|
|
|
|
c->real_probe_time = get_time_tb(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (c->pending_count > 0) c->pending_count--; |
|
|
|
|
if (c->pending_count == 0) { |
|
|
|
|
c->probe_status = PROBE_STATUS_DONE; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_BGP, "connectivity probe DONE for node %016llx: intf=%d nat=%d real=%d", |
|
|
|
|
(unsigned long long)ctx->nq->node.node_id, |
|
|
|
|
c->interface_status, c->nat_status, c->real_status); |
|
|
|
|
if (c->pending_count > 0) c->pending_count--; |
|
|
|
|
if (c->pending_count == 0) { |
|
|
|
|
c->probe_status = PROBE_STATUS_DONE; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_BGP, "connectivity probe DONE for node %016llx: intf=%d nat=%d real=%d", |
|
|
|
|
(unsigned long long)ctx->nq->node.node_id, |
|
|
|
|
c->interface_status, c->nat_status, c->real_status); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
u_free(ctx); |
|
|
|
|
@ -349,6 +352,7 @@ void route_connectivity_probe_node(struct UTUN_INSTANCE* instance, struct NODEIN
|
|
|
|
|
ctx->timeout_ms = CONN_PROBE_TIMEOUT_MS; |
|
|
|
|
ctx->best_across_sockets = 65535; |
|
|
|
|
|
|
|
|
|
nq->connectivity.probe_ctx = ctx; |
|
|
|
|
pend++; |
|
|
|
|
conn_probe_start_series(ctx); |
|
|
|
|
} |
|
|
|
|
@ -407,6 +411,7 @@ void route_connectivity_probe_node(struct UTUN_INSTANCE* instance, struct NODEIN
|
|
|
|
|
ctx->timeout_ms = CONN_PROBE_TIMEOUT_MS; |
|
|
|
|
ctx->best_across_sockets = 65535; |
|
|
|
|
|
|
|
|
|
nq->connectivity.probe_ctx = ctx; |
|
|
|
|
pend++; |
|
|
|
|
conn_probe_start_series(ctx); |
|
|
|
|
} |
|
|
|
|
@ -428,6 +433,10 @@ void route_connectivity_cancel_node(struct UTUN_INSTANCE* instance, struct NODEI
|
|
|
|
|
if (!instance || !nq) return; |
|
|
|
|
nq->connectivity.probe_status = PROBE_STATUS_NONE; |
|
|
|
|
nq->connectivity.pending_count = 0; |
|
|
|
|
if (nq->connectivity.probe_ctx) { |
|
|
|
|
((struct conn_probe_ctx*)nq->connectivity.probe_ctx)->nq = NULL; |
|
|
|
|
nq->connectivity.probe_ctx = NULL; |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_BGP, "connectivity probe cancelled for node %016llx", (unsigned long long)nq->node.node_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|