FreeRTOS+TCP unexpected new DHCP address after update

When updating to a new version of FreeRTOS TCP, I noticed that my DHCP server (dhcpd on PFSense) gave out a new IP address to the device and treats is like a separate device from before when running an older FreeRTOS TCP for the purposes of its DHCP lease.

Digging into this, it appears that DHCP option 50 is now being sent as 0.0.0.0 even when there is no requested IP address configured, and this seems to cause dhcpd to hand out a different IP than before. This changed happened in pull request 268 in the FreeRTOS-Plus-TCP repository (can’t post link due to new user rule).

I think it would be helpful if either option 50 was not sent if the PreferredIPAddress is 0.0.0.0 or, barring that, there was a config option to remove sending option 50 altogether. This way there is a greater chance of having a DHCP server that gives somewhat sticky IPs (like dhcpd) keep giving the same IP out after I release a firmware update for devices running an older version of FreeRTOS TCP.

Any thoughts?

Hello @aah, thank you for reporting this.

I just looked up PR #268, and indeed it will send option 50 unconditionally.

( Normally after a few days new posters get the right to add URL’s in their posts. It is just a protection against spam )

Have you not considered using the option? Your devices can request their usual IP-address by setting it with vDHCPSetPreferredIPAddress(). That would be a more reliable method than relying on the DHCP server.

Another possibility is indeed to remove the option in case there is no preferred IP-address. I will think of an elegant way to change this behaviour and report back here.

Hi @htibosch,

I have considered using the option (and will potentially use it in the future - it does seem useful), however the issue remains that when upgrading firmware, the IP doesn’t remain consistent for certain DHCP servers that did have somewhat sticky behavior and get slightly confused with a blank option 50. So, I would get a new different IP assigned that would get persisted for use with vDHCPSetPreferredIPAddress() instead of the old address in that case since I would be running the new TCP stack.

There are definitely ways around this issue (such as patching FreeRTOS TCP temporarily), but if an official change is coming, I’ll wait for that.

Thanks for looking into this!

Hello @aah,

We are considering adding a configuration macro which allows the user to configure the stack to either send option 50 or ignore it.
I’ll keep you posted on what we decide on.

Thanks,
Aniruddha

As the library already has many macro’s, and as the Preferred-IP option only adds very little code, I propose to change the logic: only include option 50 in case vDHCPSetPreferredIPAddress() has been called to use a non-zero IP-address.
That will make it possible decide dynamically if Preferred-IP should be used or not.

Thanks for your work on this @htibosch! I see that there’s a pull request that you put out with a fix (IPv4/single: DHCP send option 50 only when a preferred IP-address is … by htibosch · Pull Request #518 · FreeRTOS/FreeRTOS-Plus-TCP · GitHub) and was wondering what the status of it is (it seems to be blocked due to code coverage?).