[Networkmanager] Putting device administratively up/down
Thomas Haller
thaller at redhat.com
Thu May 18 11:14:23 UTC 2023
Hi,
On Thu, 2023-05-18 at 11:26 +0200, Petr Gotthard wrote:
> Hello,
>
> Ethernet interfaces can be put administratively down (ip link set
> eth0 down). Although the NetworkManager controls a large amount of
> interface parameters, it does not control the up/down status.
>
> When an interface is administratively down, the NetworkManager:
> - shows device status NM_DEVICE_STATE_UNAVAILABLE, and in GUI "Cable
> unplugged" (which does not reflect reality when the cable is plugged-
> in),
Kernel only exposes carrier state when the interface is up. Which is
the main reason why NetworkManager eagerly sets up all interfaces up.
So, if you set it down, it also appears to have the cable unplugged,
and UNAVAILABLE is sensible.
> - respects the status and does not bring the device/interface up
> even when there is a connection with auto-connect=true.
well, sure. The cable appears unplugged, and unless NM sets the
interface up, it wouldn't know better. There is also the thing that
DHCP/IPv6 configurations cannot work without cable. So maybe NM needs
to be smarter and optimistically assume that if an interface is "down",
that carrier would be present if it just set it up (and set it up).
However, NetworkManager did set the interface up earlier, it was
somebody else who set it down. So just setting it up again
automatically just overrides what somebody else did (for unknown
reasons).
You should however still be able to manually activate the profile,
which should NM cause to set the interface up, and then proceed.
> When an interface is up, the NetworkManager does not (seems to not)
> offer any mechanism to put it administratively down.
>
>
> This feels like setting the "up/down" status is out of scope of the
> NM. This makes sense when we say that NM is here to establish
> connections and not to control devices. (Although it can control
> other Ethernet parameters like speed/duplex). Is my understanding
> correct, or you might accept a patch implementing setting device
> up/down in one way or another?
It's certainly the point of NetworkManager to control devices,
including the up/down status. Except the current handling is relatively
simple (just set everything that is not "unmanaged" IFF_UP). It
probably should be improved, but it's not entirely trivial to imagine
how to do it.
But the real reason why NetworkManager does not handle up/down status
better, is because nobody made it better so far. ... well, that's not
fair. There is for example
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1478
so some people certainly were working on making it better (thanks), it
just didn't yet make it upstream and more work is necessary.
It would be most appreciated to follow up on
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1478
and on the related discussions.
Thomas
More information about the Networkmanager
mailing list