buglwIP - A Lightweight TCP/IP stack - Bugs: bug #55380, dhcp_release_and_stop() clears the...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #55380: dhcp_release_and_stop() clears the assigned IP address - v2.1.2

Submitter:  Steve Strong <stevestrong>
Submitted:  Fri 04 Jan 2019 08:03:57 AM UTC
   
 
Category:  DHCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  Other

Jump to the original submission

Tue 26 Mar 2019 07:19:35 PM UTC, comment #12: 

Cherry picked to 2.1.x branch on 18.2.2019

Dirk Ziegelmeier <dziegel>
Group administrator
Fri 15 Feb 2019 07:21:57 AM UTC, comment #11: 

I just uploaded the patch I am using to fix this issue in lwIP 2.1.2.

R. Diez <rdiez>
Thu 14 Feb 2019 06:17:54 PM UTC, comment #10: 

It's fixed in master. It's not fixed in the 2.1.x branch, that' why it's still open, not closed.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 14 Feb 2019 07:10:51 AM UTC, comment #9: 

I wanted to check out the code changes, now that this bug has been marked as fixed, in order to patch my sources, but I could not find it below. Have you not pushed it yet?

http://git.savannah.nongnu.org/cgit/lwip.git/log/?h=STABLE-2_1_x

For other readers, the reason why this issue does need to be fixed is that dhcp_release_and_stop() unconditionally clears the interface's IP address, even if the address was not set by DHCP.

This breaks applications that want to use a fallback IP address if DHCP fails, but my still want to stop and restart DHCP in case a DHCP server does show up later on.

R. Diez <rdiez>
Thu 14 Feb 2019 05:37:33 AM UTC, comment #8: 

Since this is fixed in master by the ACD patch, let's fix it in the 2.1.x branch, too, without adding the acd patch.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 04 Jan 2019 10:02:17 AM UTC, comment #7: 

Without wanting to cause any further trouble, I just want to point out a (possible) small typo error in the debug message which I observed during debugging:
("dhcp_discover: deleting()ing\n")
see https://git.savannah.gnu.org/cgit/lwip.git/tree/src/core/ipv4/dhcp.c?id=c02fea096118930d866ee1572600c7c3c9d62e63#n1001
Please check.

Steve Strong <stevestrong>
Fri 04 Jan 2019 09:49:55 AM UTC, comment #6: 

Thank you a lot for your effort and explanation.
It seems to be inline with the main loop only example (https://www.nongnu.org/lwip/2_1_x/group__lwip__nosys.html) where DHCP is not stopped.

The upgrade from v1.4 to v2.x seems to require more change than expected. Sorry for causing any trouble.

Steve Strong <stevestrong>
Fri 04 Jan 2019 09:43:56 AM UTC, comment #5: 


> So just for my information: DHCP should be started, and not
> stopped nor released when a valid IP address has been assigned?


Yes. As long as you want to use the IP address assigned by the DHCP server, the client needs to be running. Note that this means the IP address can change once the lease has timed out. So your application should be prepared for taht.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 04 Jan 2019 09:41:48 AM UTC, comment #4: 

I mean the application.

So just for my information: DHCP should be started, and not stopped nor released when a valid IP address has been assigned?

Steve Strong <stevestrong>
Fri 04 Jan 2019 09:38:31 AM UTC, comment #3: 


> After all, maybe the old DHCP managing (start and stop) was wrong


Yes. You must not continue using an address assigned by DHCP without having the client running: you won't notice the lease timing out and you could end up in the IP address being reused by someone else.

> and that is why it has been changed? I could not find any issue
> related to this.


What kind of issue do you mean? I don't know your DHCP managing code...

> Also, I could not find anywhere a clear description how DHCP
> should be handled by the driver, it would be nice if you could
> post a link to that.


Which driver do you mean?

Simon Goldschmidt <goldsimon>
Group administrator
Fri 04 Jan 2019 09:35:38 AM UTC, comment #2: 

I think it has historical reasons.
In v1.4.1 the driver monitored the DHCP process and closed the DHCP when an IP has been assigned with dhcp_close(). This did not clear the IP address, because dhcp_release() was not called (DHCP was not released).

In the new version (commit: https://github.com/yarrick/lwip/commit/ec4f00179d0ef90e4903fd752e450ec23ebc3d34) the two old functions dhcp_release() and dhcp_stop() have been merged into the new function dhcp_release_and_stop() which now clears the IP address even when dhcp_close() is called.

After all, maybe the old DHCP managing (start and stop) was wrong and that is why it has been changed? I could not find any issue related to this.
Also, I could not find anywhere a clear description how DHCP should be handled by the driver, it would be nice if you could post a link to that.


Steve Strong <stevestrong>
Fri 04 Jan 2019 08:08:05 AM UTC, comment #1: 

I don't think I get it. Where's the bug here? dhcp_release_and_stop() is called to stop the DHCP client and to release the IP address that has been assigned via DHCP. Of course the IP address of the netif has to be cleared there.

Why do you call dhcp_release_and_stop() if you want to use the IP address assigned by DHCP?

Simon Goldschmidt <goldsimon>
Group administrator
Fri 04 Jan 2019 08:03:57 AM UTC, original submission:  

After the DHCP successfully acquires an IP address, it will delete it in the mentioned function, so that LwIP is not reachable under the assigned address anymore.

The line in question is this:
https://git.savannah.gnu.org/cgit/lwip.git/tree/src/core/ipv4/dhcp.c?id=c02fea096118930d866ee1572600c7c3c9d62e63#n1347

After commenting out (removing) this line, the tested HTTP server works as expected.

Also see:
http://lwip.100.n7.nabble.com/Problems-with-a-HTTP-server-etharp-c-v2-1-2-tc33715.html#a33717

Steve Strong <stevestrong>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #46270:  lwip-2.1.2-dhcp.patch added by rdiez (867B - text/x-patch - The patch I am using to fix lwIP 2.1.2.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dziegel (Posted a comment)
  • -email is unavailable- added by rdiez (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by stevestrong (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-26 dziegel Open/ClosedOpen Closed
    2019-02-15 rdiez Attached File- Added lwip-2.1.2-dhcp.patch, #46270
    2019-02-14 goldsimon StatusInvalid Fixed
        Assigned toNone goldsimon
        Open/ClosedClosed Open
    2019-01-04 goldsimon Open/ClosedOpen Closed
    2019-01-04 goldsimon StatusNone Invalid

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code