From 73342a9659cc086184418385813e0822eebfca5d Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Mon, 8 Apr 2013 10:03:25 +0930 Subject: [PATCH] Announce routes to secondary keyring entries --- overlay_advertise.c | 33 +++++++++++++++++++++------------ tests/routing | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/overlay_advertise.c b/overlay_advertise.c index 894b3ebd..cc345603 100644 --- a/overlay_advertise.c +++ b/overlay_advertise.c @@ -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); } } diff --git a/tests/routing b/tests/routing index 058480dc..b43f76bf 100755 --- a/tests/routing +++ b/tests/routing @@ -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