Skip to content

Commit 0a18231

Browse files
author
Mika Tervonen
committed
Change ARO routes to be direct route instead of on-link
This will make the routing logic to consider other routes if the direct ARO route is not working. If the link recovers it should start using it.
1 parent 7fb321e commit 0a18231

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,20 @@ buffer_t *nd_dar_parse(buffer_t *buf, protocol_interface_info_entry_t *cur_inter
839839
#ifdef HAVE_6LOWPAN_ROUTER
840840
static void nd_update_registration(protocol_interface_info_entry_t *cur_interface, ipv6_neighbour_t *neigh, const aro_t *aro)
841841
{
842+
uint8_t ll64[16];
843+
844+
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
845+
memcpy(&ll64[8], aro->eui64, 8);
846+
ll64[8] ^= 2;
847+
848+
842849
/* We are about to send an ARO response - update our Neighbour Cache accordingly */
843850
if (aro->status == ARO_SUCCESS && aro->lifetime != 0) {
844851
neigh->type = IP_NEIGHBOUR_REGISTERED;
845852
neigh->lifetime = aro->lifetime * UINT32_C(60);
846853
ipv6_neighbour_set_state(&cur_interface->ipv6_neighbour_cache, neigh, IP_NEIGHBOUR_STALE);
847854
/* Register with 2 seconds off the lifetime - don't want the NCE to expire before the route */
848-
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, NULL, ROUTE_ARO, neigh->lifetime - 2, 0);
855+
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, ll64, ROUTE_ARO, neigh->lifetime - 2, 0);
849856

850857
/* We need to know peer is a host before publishing - this needs MLE. Not yet established
851858
* what to do without MLE - might need special external/non-external prioritisation at root.
@@ -864,19 +871,24 @@ static void nd_update_registration(protocol_interface_info_entry_t *cur_interfac
864871
neigh->type = IP_NEIGHBOUR_TENTATIVE;
865872
neigh->lifetime = 2;
866873
ipv6_neighbour_set_state(&cur_interface->ipv6_neighbour_cache, neigh, IP_NEIGHBOUR_STALE);
867-
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, NULL, ROUTE_ARO, 4, 0);
874+
ipv6_route_add(neigh->ip_address, 128, cur_interface->id, ll64, ROUTE_ARO, 4, 0);
868875
rpl_control_unpublish_address(protocol_6lowpan_rpl_domain, neigh->ip_address);
869876
}
870877
}
871878

872879
void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address)
873880
{
881+
uint8_t ll64[16];
882+
883+
memcpy(ll64, ADDR_LINK_LOCAL_PREFIX, 8);
874884

875885
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cur_interface->ipv6_neighbour_cache.list) {
876886
if ((cur->type == IP_NEIGHBOUR_REGISTERED
877887
|| cur->type == IP_NEIGHBOUR_TENTATIVE)
878888
&& ipv6_neighbour_ll_addr_match(cur, ll_type, ll_address)) {
879-
ipv6_route_delete(cur->ip_address, 128, cur_interface->id, NULL,
889+
memcpy(&ll64[8], ipv6_neighbour_eui64(&cur_interface->ipv6_neighbour_cache, cur), 8);
890+
ll64[8] ^= 2;
891+
ipv6_route_delete(cur->ip_address, 128, cur_interface->id,ll64,
880892
ROUTE_ARO);
881893
ipv6_neighbour_entry_remove(&cur_interface->ipv6_neighbour_cache,
882894
cur);

0 commit comments

Comments
 (0)