Announce routes to secondary keyring entries

This commit is contained in:
Jeremy Lakeman 2013-04-08 10:03:25 +09:30
parent 2c379fadb1
commit 73342a9659
2 changed files with 46 additions and 12 deletions

View File

@ -65,27 +65,36 @@ struct advertisement_state{
struct subscriber *next_advertisement;
};
int advertise(struct advertisement_state *state, struct subscriber *subscriber, char score, char gateways){
// never send the full sid in an advertisement
subscriber->send_full=0;
if (overlay_address_append(NULL,state->payload,subscriber) ||
ob_append_byte(state->payload,score) ||
ob_append_byte(state->payload,gateways)){
// stop if we run out of space, remember where we should start next time.
state->next_advertisement=subscriber;
ob_rewind(state->payload);
return 1;
}
ob_checkpoint(state->payload);
return 0;
}
int add_advertisement(struct subscriber *subscriber, void *context){
struct advertisement_state *state=context;
if (subscriber->reachable==REACHABLE_SELF && subscriber != my_subscriber)
return advertise(state, subscriber, 255, 1);
if (subscriber->node){
overlay_node *n=subscriber->node;
if ((subscriber->reachable&REACHABLE) && (!(subscriber->reachable&REACHABLE_ASSUMED))
&& n->best_link_score>0 && n->observations[n->best_observation].gateways_en_route < 64){
// never send the full sid in an advertisement
subscriber->send_full=0;
if (overlay_address_append(NULL,state->payload,subscriber) ||
ob_append_byte(state->payload,n->best_link_score -1) ||
ob_append_byte(state->payload,n->observations[n->best_observation].gateways_en_route +1)){
// stop if we run out of space, remember where we should start next time.
state->next_advertisement=subscriber;
ob_rewind(state->payload);
return 1;
}
ob_checkpoint(state->payload);
return advertise(state, subscriber, n->best_link_score -1,
n->observations[n->best_observation].gateways_en_route +1);
}
}

View File

@ -78,6 +78,31 @@ test_single_link() {
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST UNICAST :"
}
doc_multiple_ids="Route between multiple identities"
setup_multiple_ids() {
setup_servald
assert_no_servald_processes
foreach_instance +A +B create_identities 2
foreach_instance +A +B add_interface 1
foreach_instance +A +B start_routing_instance
}
test_multiple_ids() {
foreach_instance +A +B \
wait_until has_seen_instances +A +B
set_instance +A
executeOk_servald mdp ping $SIDB2 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDB1:BROADCAST UNICAST :dummy.*:0*"
assertStdoutGrep --matches=1 "^$SIDB2:INDIRECT ::$SIDB1"
set_instance +B
executeOk_servald mdp ping $SIDA2 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDA1:BROADCAST UNICAST :dummy.*:0*"
assertStdoutGrep --matches=1 "^$SIDA2:INDIRECT ::$SIDA1"
}
doc_single_mdp="Use single MDP per packet encapsulation"
setup_single_mdp() {
setup_servald