lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] What is correct way to reinitialize IPv6 addresses?


From: Jan Breuer
Subject: [lwip-devel] What is correct way to reinitialize IPv6 addresses?
Date: Fri, 6 May 2016 13:07:27 +0200

Hello,
I have a problem with reinitialization of IPv6 addresses and I don't know if it is a bug or misuse.

I would like to implement network reconfiguration on the fly without restarting whole MCU.

Imagine two modes - autoconfiguration and static IP configuration.

After changing from one mode to another, I don't want old addresses to persist I do following steps

netif_set_down(netif);
foreach(ip6_addr) {
  netif_ip6_addr_set(netif, i, IP6_ADDR_ANY6);
  netif_ip6_addr_set_state(netif, i, IP6_ADDR_INVALID);
}
netif_create_ip6_linklocal_address(netif, 1);
netif->ip6_autoconfig_enabled = MODE;
netif_set_up(netif);

But after performing these steps twice with MODE=1, no autoconfiguration address is assigned after second run.

After some investigation I found, that there is missing something like nd6_cleanup_netif in netif_set_down

After implementing it and calling it from netif_set_down, it starts working.

Am I doing something wrong or it is a bug?

Best regards,
Jan Breuer

Example implementation of nd6_cleanup_netif:

void
nd6_cleanup_netif(struct netif * netif)
{
  u8_t i;
  s8_t router_index;
  for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) {
    if(prefix_list[i].netif == netif) {
      prefix_list[i].netif = NULL;
      prefix_list[i].flags = 0;
    }
  }
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if(neighbor_cache[i].netif == netif) {
      for (router_index = 0; router_index < LWIP_ND6_NUM_ROUTERS; router_index++) {
        if (default_router_list[router_index].neighbor_entry == &neighbor_cache[i]) {
          default_router_list[router_index].neighbor_entry = NULL;
          default_router_list[router_index].flags = 0;
        }
      }
      neighbor_cache[i].isrouter = 0;
      nd6_free_neighbor_cache_entry(i);
    }
  }
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]