lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] bind with link down


From: Sylvain Rochet
Subject: Re: [lwip-users] bind with link down
Date: Fri, 3 Apr 2020 01:28:07 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

rHi Massimiliano,

On Fri, Apr 03, 2020 at 12:40:43AM +0200, Massimiliano Cialdi wrote:
> On Thu, Apr 2, 2020 at 11:25 PM Sylvain Rochet <address@hidden> wrote:
> > "ip link set <if> up/down" is interface administrative state.
> >
> > Link state is whether the cable is plugged or unplugged, i.e. "ethtool"
> > for linux equivalent.
> This answer confuses me.
> 
> I tried: on linux the link state and the admin state *are* related to
> each other.

I don't agree, administrative state is always UP in your example:


> with the cable connected both ip and ethtool report the states up
> max@jarvis:~$ ip link show enx0050b6e9a99e && ethtool enx0050b6e9a99e | tail 
> -n2
> 5: enx0050b6e9a99e: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
                                           ^^ ^^^^^^^^
                         administrative state    link state


> fq_codel state UP mode DEFAULT group default qlen 1000
>     link/ether 00:50:b6:e9:a9:9e brd ff:ff:ff:ff:ff:ff
> Cannot get wake-on-lan settings: Operation not permitted
>                    drv probe link
>     Link detected: yes
> 
> and even with the cable disconnected they both say down:
> max@jarvis:~$ ip link show enx0050b6e9a99e && ethtool enx0050b6e9a99e | tail 
> -n2
> 5: enx0050b6e9a99e: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc
                       ^^^^^^^^^^                     ^^
                        link state          administrative state


> fq_codel state DOWN mode DEFAULT group default qlen 1000
>     link/ether 00:50:b6:e9:a9:9e brd ff:ff:ff:ff:ff:ff
> Cannot get wake-on-lan settings: Operation not permitted
>                    drv probe link
>     Link detected: no
> 
> but you said:
> > "Admin state" is "netif_set_up()".
> >
> > > How should the admin state be affected by the link state?
> > Not at all. Just call "netif_set_link_up()" or down when you found out a
> > state change. Leave "netif_set_up()" as it is.
> From this I understand that the links state and admin state are not
> related. I may have (and you say so) links down but admin state up.
> Tell me if I understand correctly.

They are not related at all.

netif_set_up() and netif_set_down() is a software switch telling the 
lwIP stack if you want the interface to be active or silent. If you 
don't need to disable an interface at runtime (with only one interface, 
you never need that!), you only have to call netif_set_up() once at 
init.

netif_set_link_up() and netif_set_link_down() may be called when cable 
is plugged or unplugged. Calling netif_set_link_down() then 
netif_set_link_up() is optional and only meant to speed up DHCP recover, 
IPv6 discovery, or such. If you don't care about speeding up things on 
cable connection you only have to call netif_set_link_up() once at init.


> So I find myself forced to ask you the question again: on linux how
> can I have admin state up and link down?

You only have to unplug the cable to do so :-)


> the last thing: you say that "ip link set <if> up/down" is interface
> administrative state.
> But if I force down the "admin state" with the cable connected, both
> ip and ethtool tell me the link is down. And once again, that seems
> contrary to what you say (link and admin state are not related).

This is because Linux power down the network interface when you set it 
administratively down, effectively removing the carrier signal.
 

Sylvain

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]