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

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
URL:
  <https://savannah.nongnu.org/bugs/?55380>

                 Summary: dhcp_release_and_stop() clears the assigned IP
address - v2.1.2
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: stevestrong
            Submitted on: Fri 04 Jan 2019 08:03:57 AM UTC
                Category: DHCP
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: Other

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Update of bug #55380 (project lwip):

                  Status:                    None => Invalid                

    _______________________________________________________

Follow-up 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?

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #2, bug #55380 (project lwip):

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.



    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Update of bug #55380 (project lwip):

             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up 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?

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #4, bug #55380 (project lwip):

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?


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #5, bug #55380 (project lwip):

> 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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #6, bug #55380 (project lwip):

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.


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #7, bug #55380 (project lwip):

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.


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Update of bug #55380 (project lwip):

                  Status:                 Invalid => Fixed                  
             Assigned to:                    None => goldsimon              
             Open/Closed:                  Closed => Open                  

    _______________________________________________________

Follow-up 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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #9, bug #55380 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #10, bug #55380 (project lwip):

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

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Additional Item Attachment, bug #55380 (project lwip):

File name: lwip-2.1.2-dhcp.patch          Size:0 KB
    <https://savannah.nongnu.org/file/lwip-2.1.2-dhcp.patch?file_id=46270>



    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Follow-up Comment #11, bug #55380 (project lwip):

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

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

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

Wilfred
Update of bug #55380 (project lwip):

             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #12:

Cherry picked to 2.1.x branch on 18.2.2019

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?55380>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel