Swap between broadcast & unicast links as they become available

This commit is contained in:
Jeremy Lakeman 2013-05-31 11:32:13 +09:30
parent d15c336c10
commit b1f384cd63
3 changed files with 32 additions and 4 deletions

View File

@ -255,7 +255,11 @@ overlay_mdp_service_probe(overlay_mdp_frame *mdp)
peer->address.sin_family = AF_INET;
peer->address.sin_addr = probe.addr.sin_addr;
peer->address.sin_port = probe.addr.sin_port;
set_reachable(peer, REACHABLE_UNICAST | (peer->reachable & REACHABLE_DIRECT));
int r=REACHABLE_UNICAST;
// Don't turn assumed|broadcast into unicast|broadcast
if (!(peer->reachable & REACHABLE_ASSUMED))
r |= (peer->reachable & REACHABLE_DIRECT);
set_reachable(peer, r);
RETURN(0);
OUT();
}

View File

@ -350,7 +350,7 @@ next:
subscriber->last_probe=0;
bzero(&subscriber->address, sizeof subscriber->address);
}
reachable = REACHABLE_BROADCAST | (subscriber->reachable & REACHABLE_UNICAST);
reachable = REACHABLE_BROADCAST | (reachable & REACHABLE_UNICAST);
next_hop = NULL;
subscriber->interface = interface;
} else {
@ -505,7 +505,6 @@ static void free_neighbour(struct neighbour **neighbour_ptr){
n->root=NULL;
*neighbour_ptr = n->_next;
free(n);
route_version++;
}
static void clean_neighbours(time_ms_t now)
@ -527,6 +526,10 @@ static void clean_neighbours(time_ms_t now)
list = &link->_next;
}
}
// when all links to a neighbour that we are routing through expire, force a routing calculation update
struct link_state *state = get_link_state(n->subscriber);
if (state->next_hop == n->subscriber && (n->neighbour_link_timeout < now || !n->links) && state->route_version == route_version)
route_version++;
if (!n->links){
free_neighbour(n_ptr);
}else{
@ -698,7 +701,8 @@ static void link_send(struct sched_ent *alarm)
if (neighbours){
alarm->deadline = alarm->alarm;
schedule(alarm);
}
}else
alarm->alarm=0;
}
static void update_alarm(time_ms_t limit){

View File

@ -358,6 +358,26 @@ test_offline() {
wait_until --timeout=30 instance_offline +C
}
doc_lose_neighbours="Lose and regain neighbours"
setup_lose_neighbours() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B +C create_single_identity
foreach_instance +A +B add_interface 1
foreach_instance +B +C add_interface 2
foreach_instance +A +B +C start_routing_instance
}
test_lose_neighbours() {
wait_until path_exists +A +B +C
wait_until path_exists +C +B +A
stop_servald_server +B
foreach_instance +A +C \
wait_until --timeout=30 instance_offline +B
start_servald_server +B
wait_until path_exists +A +B +C
wait_until path_exists +C +B +A
}
setup_multi_interface() {
setup_servald
assert_no_servald_processes