Skip to content

Commit

Permalink
Make uip-ds6-route use neighbor table. Instead of storing a global li…
Browse files Browse the repository at this point in the history
…st of routing entries that contain both the next hop and the destination, we have a separate list of reachable destination for each neighbor in the global table.
  • Loading branch information
simonduq committed Aug 19, 2013
1 parent ec609b4 commit 09d26f8
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 87 deletions.
11 changes: 9 additions & 2 deletions core/net/rpl/rpl-icmp6.c
Expand Up @@ -243,6 +243,13 @@ dio_input(void)
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
} else {
PRINTF("RPL: Out of Memory, dropping DIO from ");
PRINT6ADDR(&from);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("\n");
return;
}
} else {
PRINTF("RPL: Neighbor already in neighbor cache\n");
Expand Down Expand Up @@ -657,11 +664,11 @@ dao_input(void)

if(lifetime == RPL_ZERO_LIFETIME) {
/* No-Path DAO received; invoke the route purging routine. */
if(rep != NULL && rep->state.saved_lifetime == 0 && rep->length == prefixlen && uip_ipaddr_cmp(&rep->nexthop, &dao_sender_addr)) {
if(rep != NULL && rep->state.nopath_received == 0 && rep->length == prefixlen && uip_ipaddr_cmp(&rep->nexthop, &dao_sender_addr)) {
PRINTF("RPL: Setting expiration timer for prefix ");
PRINT6ADDR(&prefix);
PRINTF("\n");
rep->state.saved_lifetime = rep->state.lifetime;
rep->state.nopath_received = 1;
rep->state.lifetime = DAO_EXPIRATION_TIMEOUT;
}
return;
Expand Down
41 changes: 16 additions & 25 deletions core/net/rpl/rpl.c
Expand Up @@ -67,7 +67,7 @@ rpl_purge_routes(void)
rpl_dag_t *dag;

/* First pass, decrement lifetime */
r = uip_ds6_route_list_head();
r = uip_ds6_route_head();

while(r != NULL) {
if(r->state.lifetime >= 1) {
Expand All @@ -78,19 +78,19 @@ rpl_purge_routes(void)
*/
r->state.lifetime--;
}
r = list_item_next(r);
r = uip_ds6_route_next(r);
}

/* Second pass, remove dead routes */
r = uip_ds6_route_list_head();
r = uip_ds6_route_head();

while(r != NULL) {
if(r->state.lifetime < 1) {
/* Routes with lifetime == 1 have only just been decremented from 2 to 1,
* thus we want to keep them. Hence < and not <= */
uip_ipaddr_copy(&prefix, &r->ipaddr);
uip_ds6_route_rm(r);
r = uip_ds6_route_list_head();
r = uip_ds6_route_head();
PRINTF("No more routes to ");
PRINT6ADDR(&prefix);
dag = default_instance->current_dag;
Expand All @@ -103,7 +103,7 @@ rpl_purge_routes(void)
}
PRINTF("\n");
} else {
r = list_item_next(r);
r = uip_ds6_route_next(r);
}
}
}
Expand All @@ -113,14 +113,14 @@ rpl_remove_routes(rpl_dag_t *dag)
{
uip_ds6_route_t *r;

r = uip_ds6_route_list_head();
r = uip_ds6_route_head();

while(r != NULL) {
if(r->state.dag == dag) {
uip_ds6_route_rm(r);
r = uip_ds6_route_list_head();
r = uip_ds6_route_head();
} else {
r = list_item_next(r);
r = uip_ds6_route_next(r);
}
}
}
Expand All @@ -130,15 +130,15 @@ rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag)
{
uip_ds6_route_t *r;

r = uip_ds6_route_list_head();
r = uip_ds6_route_head();

while(r != NULL) {
if(uip_ipaddr_cmp(&r->nexthop, nexthop) &&
if(uip_ipaddr_cmp(uip_ds6_route_nexthop(r), nexthop) &&
r->state.dag == dag) {
uip_ds6_route_rm(r);
r = uip_ds6_route_list_head();
r = uip_ds6_route_head();
} else {
r = list_item_next(r);
r = uip_ds6_route_next(r);
}
}
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
Expand All @@ -150,20 +150,11 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
{
uip_ds6_route_t *rep;

rep = uip_ds6_route_lookup(prefix);
if(rep == NULL) {
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop, 0)) == NULL) {
PRINTF("RPL: No space for more route entries\n");
return NULL;
}
} else {
PRINTF("RPL: Updated the next hop for prefix ");
PRINT6ADDR(prefix);
PRINTF(" to ");
PRINT6ADDR(next_hop);
PRINTF("\n");
uip_ipaddr_copy(&rep->nexthop, next_hop);
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop)) == NULL) {
PRINTF("RPL: No space for more route entries\n");
return NULL;
}

rep->state.dag = dag;
rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime);
rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
Expand Down
2 changes: 1 addition & 1 deletion core/net/tcpip.c
Expand Up @@ -587,7 +587,7 @@ tcpip_ipv6_output(void)
return;
}
} else {
nexthop = &locrt->nexthop;
nexthop = uip_ds6_route_nexthop(locrt);
}
if(nexthop != NULL) {
PRINTF("tcpip_ipv6_output: next hop ");
Expand Down

0 comments on commit 09d26f8

Please sign in to comment.