diff --git a/conf_schema.h b/conf_schema.h index f08e729b..0c8ea2a0 100644 --- a/conf_schema.h +++ b/conf_schema.h @@ -475,6 +475,7 @@ ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_t SUB_STRUCT(mdp_iftype, mdp,) ATOM(bool_t, send_broadcasts, 1, boolean,, "If false, don't send any broadcast packets") ATOM(bool_t, default_route, 0, boolean,, "If true, use this interface as a default route") +ATOM(bool_t, dont_route, 0, boolean,, "If true, do not advertise any links discovered on this interface") ATOM(bool_t, prefer_unicast, 1, boolean,, "If true, send data as unicast IP packets if available") ATOM(bool_t, debug, 0, boolean,, "If true, log details of every outgoing packet") ATOM(bool_t, point_to_point, 0, boolean,, "If true, assume there will only be two devices on this interface") diff --git a/overlay_interface.c b/overlay_interface.c index 452292c6..d60f6fe0 100644 --- a/overlay_interface.c +++ b/overlay_interface.c @@ -414,6 +414,7 @@ overlay_interface_init(const char *name, struct socket_address *addr, interface->port = ifconfig->port; interface->type = ifconfig->type; interface->send_broadcasts = ifconfig->send_broadcasts; + interface->dont_route = ifconfig->dont_route; interface->prefer_unicast = ifconfig->prefer_unicast; interface->default_route = ifconfig->default_route; interface->socket_type = ifconfig->socket_type; diff --git a/overlay_interface.h b/overlay_interface.h index 154a0c5e..ce3c3d00 100644 --- a/overlay_interface.h +++ b/overlay_interface.h @@ -105,6 +105,7 @@ typedef struct overlay_interface { int type; int socket_type; char send_broadcasts; + char dont_route; char prefer_unicast; /* Not necessarily the real MTU, but the largest frame size we are willing to TX. For radio links the actual maximum and the maximum that is likely to be delivered reliably are diff --git a/route_link.c b/route_link.c index e9b503da..f7d65d8e 100644 --- a/route_link.c +++ b/route_link.c @@ -557,14 +557,19 @@ static int append_link(struct subscriber *subscriber, void *context) if (subscriber->identity) keyring_send_unlock(subscriber); - if (state->next_update - 20 <= now){ - if (append_link_state(payload, 0, state->transmitter, subscriber, -1, - best_link?best_link->link_version:-1, -1, 0, best_link?best_link->drop_rate:32)){ - ALARM_STRUCT(link_send).alarm = now+5; - return 1; + if (best_link && best_link->destination && best_link->destination->interface->dont_route){ + // don't talk about links across interfaces with dont_route + state->next_update = TIME_MS_NEVER_WILL; + }else{ + if (state->next_update - 20 <= now){ + if (append_link_state(payload, 0, state->transmitter, subscriber, -1, + best_link?best_link->link_version:-1, -1, 0, best_link?best_link->drop_rate:32)){ + ALARM_STRUCT(link_send).alarm = now+5; + return 1; + } + // include information about this link every 5s + state->next_update = now + 5000; } - // include information about this link every 5s - state->next_update = now + 5000; } } @@ -895,9 +900,8 @@ static int link_send_neighbours() while (n){ neighbour_find_best_link(n); - if (n->next_neighbour_update <= now){ + if (n->next_neighbour_update <= now) send_neighbour_link(n); - } if (n->next_neighbour_update < ALARM_STRUCT(link_send).alarm) ALARM_STRUCT(link_send).alarm = n->next_neighbour_update; diff --git a/tests/directory_service b/tests/directory_service index 8bad5e9e..fd5412ef 100755 --- a/tests/directory_service +++ b/tests/directory_service @@ -105,6 +105,7 @@ configure_node() { set interfaces.0.file dummy1 \ set interfaces.0.socket_type file \ set interfaces.0.send_broadcasts 0 \ + set interfaces.0.dont_route 1 \ set interfaces.0.drop_broadcasts on \ set interfaces.0.default_route 1 \ set interfaces.0.dummy_address 10.0.${instance_number}.1 \ @@ -141,17 +142,24 @@ test_routing() { set_instance +B executeOk_servald route print assertStdoutGrep --matches=1 "^$SIDA:UNICAST:" + assertStdoutGrep --matches=0 "^$SIDC:" executeOk_servald dna lookup "$DIDC" assertStdoutLineCount '==' 3 assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$" set_instance +C executeOk_servald route print assertStdoutGrep --matches=1 "^$SIDA:UNICAST:" + assertStdoutGrep --matches=0 "^$SIDB:" executeOk_servald dna lookup "$DIDB" assertStdoutLineCount '==' 3 assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$" executeOk_servald mdp ping $SIDB 3 tfw_cat --stdout --stderr + executeOk_servald route print + tfw_cat --stdout + set_instance +B + executeOk_servald route print + tfw_cat --stdout assert_status_all_servald_servers running }