lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] DHCP renewing/ rebinding and on going connexions


From: Jonathan Larmour
Subject: Re: [lwip-users] DHCP renewing/ rebinding and on going connexions
Date: Sat, 03 Jan 2009 21:28:46 +0000
User-agent: Mozilla Thunderbird 1.0.8-1.1.fc3.4.legacy (X11/20060515)

PELISSIER Christophe wrote:
Hi all,

i am using lwip V1.2 on a blackfin CPU. the lwip port has been made by
Analog Device. I have not a long experience in lwip use. Looking at the
DHCP client, i was wondering how on going connection are managed during
an IP address change.

For example, during the IP renewing phase if the client receives a
DHCPNAK (or never receives a DHCPACK), it should stop using its current
IP address. The RFC2131adds on page 41 that it "MUST immediately stop
any other network processing and requests network initialization
parameters...".

In the current dhcp code, i have seen that in such cases a dhcp_release
is performed. This shutdown the NETIF flags but for my understanding
nothing is done for the connexions currently in use.

I believe lwIP behaves correctly here. Because the netif is set down, ip_route() will never match it. And ip_route() is always used before sending normal packets. lwIP doesn't have the complexity of a proper route cache and rightly so really. There is some small-scale support for "hardware hints" to save on ARP lookups which also saves the netif lookup, but ip_route is still called first in those cases too as far as I know.

If you can find somewhere where ip_route is not called before calling ip_output_if, then that might be an issue. Note that anything that results from an incoming packet on a netif is ok because ip_input() does not accept packets from interfaces which are marked down, apart from some special cases like DHCP and IGMP.

Do i miss something? Is shutting down on going connection not required?
That is the behaviour of opened sockets in such cases? If shutting down
is required, does this action have to be performed by the stack? By the
application level? If this action is related to application level, is
there any call-back mechanism available to inform the application when
these events are raised?

In the same way, RFC2131 says page 41, during a renewing phase,  "if
the client is given a new network address, it MUST NOT continue using
the previous network address and SHOULD notify le local users of the
problem".

For the MUST NOT bit, again lwIP should be ok.

For the notification of local users, there is a netif status callback in lwIP 1.3 (NOT 1.2) you can use - enable LWIP_NETIF_STATUS_CALLBACK in lwipopts.h, and include/lwip/netif.h which has netif_set_status_callback(). netif_set_up() calls this callback, and that in turn is called when an interface is brought up or changes IP by DHCP. Of course you don't see the netif using the abstract sockets API, so you have to break the layering abstractions a bit here.

There is no official way in the sockets API to be informed of course. The word SHOULD is of course vital here. It's (obviously) not required. In fact it's a bit tricky to deal with: consider the case with multiple netifs, where the local socket is bound to 0.0.0.0 (i.e. any interface). For connection-less sockets it may still be possible to use another interface. That's why ip_route() is called of course. If packets genuinely can't be routed when there's something to be sent, then in lwIP, ERR_RTE is returned, which will be translated to EHOSTUNREACH for sockets API users. So it's not necessarily correct to go around shutting down sockets which had been using an interface which has now gone down or changed IP.

Alternatively for connection-oriented sockets and you try to send data[1] or have KEEPALIVEs on, all you can do is wait for the connection to eventually time out. That's not necessarily a big deal. After all, all you would probably want to do when informed the netif has changed IP is to shutdown() or close() any associated sockets anyway.

Hope this helps,

Jifl

[1] As per the other message I sent to the list, for some reason I can't find where retransmits do this, so if they don't at present, you may have to rely solely on KEEPALIVEs.
--
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["The best things in life aren't things."]------      Opinions==mine




reply via email to

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