DHCP and Ethernet disconnection

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

DHCP and Ethernet disconnection

Giuseppe Modugno
I designed a network adapter board with Ethernet interface and lwip
TCP/IP stack, with DHCP client enabled. It works well.

What happens if I disconnect the Ethernet cable from one network and
connect it to a second network where is a different DHCP server? Mainly
if the first network works on different address range (for example,
192.168.1.x and 192.168.2.x with 255.255.255.0 netmask).

I tried and it appears lwip/DHCP client doesn't trigger a new DHCP
request and continue working with the first IP address... so it doesn't
work on the second network.


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

Re: DHCP and Ethernet disconnection

Sylvain Rochet
Hi Giuseppe,

On Tue, Dec 10, 2019 at 11:18:12AM +0100, Giuseppe Modugno wrote:

> I designed a network adapter board with Ethernet interface and lwip TCP/IP
> stack, with DHCP client enabled. It works well.
>
> What happens if I disconnect the Ethernet cable from one network and connect
> it to a second network where is a different DHCP server? Mainly if the first
> network works on different address range (for example, 192.168.1.x and
> 192.168.2.x with 255.255.255.0 netmask).
>
> I tried and it appears lwip/DHCP client doesn't trigger a new DHCP request
> and continue working with the first IP address... so it doesn't work on the
> second network.
It does, but you will have to tell lwIP that network changed if you
don't want to wait for the next lease update.

See netif_set_link_down() / netif_set_link_up() to retrigger DHCP start.

Sylvain

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

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DHCP and Ethernet disconnection

vinu
Hi  Giuseppe,

You have to enable your  PHY interrupt and on interrupt , read the PHY registers and verify that the physical link is down. Then intimate the stack that link has gone down using the  netif_set_link_down. Then can dhcp_network_changed().

regards, 
Vinu Gopalakrishnan
Sr. Software Engineer
Gadgeon Smart Systems
m:+91-9526481318

 www.linkedin.com/in/vinu-gopalakrishnan


On Tue, Dec 10, 2019 at 4:07 PM Sylvain Rochet <[hidden email]> wrote:
Hi Giuseppe,

On Tue, Dec 10, 2019 at 11:18:12AM +0100, Giuseppe Modugno wrote:
> I designed a network adapter board with Ethernet interface and lwip TCP/IP
> stack, with DHCP client enabled. It works well.
>
> What happens if I disconnect the Ethernet cable from one network and connect
> it to a second network where is a different DHCP server? Mainly if the first
> network works on different address range (for example, 192.168.1.x and
> 192.168.2.x with 255.255.255.0 netmask).
>
> I tried and it appears lwip/DHCP client doesn't trigger a new DHCP request
> and continue working with the first IP address... so it doesn't work on the
> second network.

It does, but you will have to tell lwIP that network changed if you
don't want to wait for the next lease update.

See netif_set_link_down() / netif_set_link_up() to retrigger DHCP start.

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

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

Re: DHCP and Ethernet disconnection

Sylvain Rochet
Hi,

On Tue, Dec 10, 2019 at 04:13:33PM +0530, Vinu Gopalakrishnan wrote:
> Hi  Giuseppe,
>
> You have to enable your  PHY interrupt and on interrupt , read the PHY
> registers and verify that the physical link is down. Then intimate the
> stack that link has gone down using the  netif_set_link_down. Then can
> dhcp_network_changed().

This is confusing, never call netif_set_link_*() from interrupt context,
those calls are not thread nor interrupt safe.

You can either use PHY interrupt then signal your main loop in some way
to call netif_set_link_*(), or periodically poll the PHY status in the
main loop.

OS users should use the netifapi API: netif_set_link_*().

Sylvain

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

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DHCP and Ethernet disconnection

vinu
Yes. That is correct. I didn't mean to call them in interrupt context anyway.

Thanks,
Vinu Gopalakrishnan
Sr. Software Engineer
Gadgeon Smart Systems
m:+91-9526481318

 www.linkedin.com/in/vinu-gopalakrishnan


On Tue, Dec 10, 2019 at 4:25 PM Sylvain Rochet <[hidden email]> wrote:
Hi,

On Tue, Dec 10, 2019 at 04:13:33PM +0530, Vinu Gopalakrishnan wrote:
> Hi  Giuseppe,
>
> You have to enable your  PHY interrupt and on interrupt , read the PHY
> registers and verify that the physical link is down. Then intimate the
> stack that link has gone down using the  netif_set_link_down. Then can
> dhcp_network_changed().

This is confusing, never call netif_set_link_*() from interrupt context,
those calls are not thread nor interrupt safe.

You can either use PHY interrupt then signal your main loop in some way
to call netif_set_link_*(), or periodically poll the PHY status in the
main loop.

OS users should use the netifapi API: netif_set_link_*().

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

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

Re: DHCP and Ethernet disconnection

Jens Nielsen-2
In reply to this post by Sylvain Rochet

On 2019-12-10 11:54, Sylvain Rochet wrote:
> OS users should use the netifapi API: netif_set_link_*().

to clarify, that is netifapi_netif_set_link_*()   ;)

//Jens

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