Make nd6_new_router() handle already existing routers (this is a special case for 2 netifs on the same subnet - e.g. wifi and cable) see bug #46506

This commit is contained in:
goldsimon 2016-12-15 09:25:44 +01:00
parent e3925cc359
commit da15132aa0

View File

@ -1493,6 +1493,7 @@ static s8_t
nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif)
{
s8_t router_index;
s8_t free_router_index;
s8_t neighbor_index;
/* Do we have a neighbor entry for this router? */
@ -1516,12 +1517,22 @@ nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif)
neighbor_cache[neighbor_index].isrouter = 1;
/* Look for empty entry. */
for (router_index = 0; router_index < LWIP_ND6_NUM_ROUTERS; router_index++) {
free_router_index = LWIP_ND6_NUM_ROUTERS;
for (router_index = LWIP_ND6_NUM_ROUTERS - 1; router_index >= 0; router_index--) {
/* check if router already exists (this is a special case for 2 netifs on the same subnet
- e.g. wifi and cable) */
if(default_router_list[router_index].neighbor_entry == &(neighbor_cache[neighbor_index])){
return router_index;
}
if (default_router_list[router_index].neighbor_entry == NULL) {
default_router_list[router_index].neighbor_entry = &(neighbor_cache[neighbor_index]);
return router_index;
/* remember lowest free index to create a new entry */
free_router_index = router_index;
}
}
if (free_router_index < LWIP_ND6_NUM_ROUTERS) {
default_router_list[free_router_index].neighbor_entry = &(neighbor_cache[neighbor_index]);
return free_router_index;
}
/* Could not create a router entry. */