lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Link goes up, link goes down


From: Jakob Stoklund Olesen
Subject: [lwip-devel] Link goes up, link goes down
Date: Fri, 16 Jan 2009 09:05:37 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

I am implementing Zeroconf networking with lwIP. This means I have
enabled DHCP and AutoIP with LWIP_DHCP_AUTOIP_COOP=1.

This works quite well, but there are some small quirks.

In netif_set_link_up we have the following:

  if (netif->flags & NETIF_FLAG_ETHARP) {
    etharp_query(netif, &(netif->ip_addr), NULL);
  }

This sends a gratuitous ARP. That is the correct thing to do for a
manually configured IP address. If the address is obtained via DHCP or
AutoIP, we should first confirm that our IP address is still correct. We
could be connected to a completely different network, or somebody else
could be using our dynamic IP address by now.

I would like to add two function calls to netif_set_link_up (properly
#if'ed):

if (netif->autoip) {
  autoip_network_changed(netif)
}
if (netif->dhcp) {
  dhcp_network_changed(netif)
}

In autoip_network_changed:

if (using-autoip-address) {
  netif_set_down
  restart-autoip-probing
}

In dhcp_network_changed:

if (using-dhcp-address) {
  netif_set_down
  dhcp_reboot
} else {
  dhcp_discover
}


Furthermore the gratuitous ARP and IGMP membership announcements should
only be sent if the interface is up. (BTW, igmp_report_groups is not
called from netif_set_up() is that an omission?)

I think it would be best to preserve TCP connections across a small link
outage, so we should be careful not to change the IP address unless it
is necessary.

With this change a link outage would look as follows:

netif_set_link_down
...
netif_set_link_up ->
  netif_set_down
  dhcp_reboot
... [DHCP confirms address with DHCPREQUEST->DHCPACK]
dhcp_bind ->
  netif_set_ipaddr(same addr preserves TCP connections)
  netif_set_up

So when the link goes up, the interface goes down for a few seconds
until the IP address is confirmed.

The procedure for an AutoIP address is similar. We try preserve the old
AutoIP address, but we must probe it first.

Currently dhcp_reboot does not exist. It is almost identical to
dhcp_renew except the DHCPREQUEST is broadcast. If this happens on a
different network, the new DHCP server can quickly respond with DHCPNAK.

Some of the code in dhcp.c and autoip.c assumes that a down interface
has a zero IP address. I will have to fix that.


Regards,
/stoklund




reply via email to

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