You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Fotis Panagiotopoulos <f....@gmail.com> on 2022/10/10 15:32:37 UTC

DHCP renewal problem.

Hello everyone,

While I am still tracking down various issues regarding networking with
NuttX, I observed something interesting within the DHCP client code.

When dhcpc_request is called, the current IP address is set to INADDR_ANY.
This is in file dhcpc.c, line 714.

This sounds normal for the initial request. But what about when renewing
the lease?
In this case the system already has a perfectly valid IP address.

Setting the interface back to INADDR_ANY, even temporarily, can cause
problems to other tasks than may be using the same NIC simultaneously.
If another task tries any communication during the DHCP renewal, it fails.
I don't think that there is an actual need for it to fail.

Also, I believe that setting the address to INADDR_ANY does not benefit
DHCP, as it is not using the current IP address in any way (it broadcasts
only).

I am very tempted to remove this from the DHCP client.
Unless I am missing something?

Re: DHCP renewal problem.

Posted by Nathan Hartman <ha...@gmail.com>.
On Mon, Oct 10, 2022 at 11:32 AM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hello everyone,
>
> While I am still tracking down various issues regarding networking with
> NuttX, I observed something interesting within the DHCP client code.
>
> When dhcpc_request is called, the current IP address is set to INADDR_ANY.
> This is in file dhcpc.c, line 714.
>
> This sounds normal for the initial request. But what about when renewing
> the lease?
> In this case the system already has a perfectly valid IP address.
>
> Setting the interface back to INADDR_ANY, even temporarily, can cause
> problems to other tasks than may be using the same NIC simultaneously.
> If another task tries any communication during the DHCP renewal, it fails.
> I don't think that there is an actual need for it to fail.
>
> Also, I believe that setting the address to INADDR_ANY does not benefit
> DHCP, as it is not using the current IP address in any way (it broadcasts
> only).
>
> I am very tempted to remove this from the DHCP client.
> Unless I am missing something?
>

Hmm, I have not looked at the code yet, but based on your description, that
sounds incorrect.

I think that for DHCP renewal, we should keep the IP address which is
already being used, unless the DHCP server tells us to change it.

Nathan