-
Notifications
You must be signed in to change notification settings - Fork 23
Description
For linux
The is_up function corresponds to the SIOCSIFFLAGS IFF_UP [0]. While this is technically correct it does not really tell if the interface is usable or not. IFF_UP can be set manually on any interface.
To actually know if the interface is usable or not you need more detail. The iproute2 command ip uses netlink and IFLA_OPERSTATE to determine the state you get when you use the ip a command [1].
With netdev today, you can sort of get away with it by AND-ing the is_up and is_running results but I am unsure if this is actually as accurate as the IFLA_OPERSTATE or if there are corner cases where this is not valid.
I think it would be nice if the library provided a convenience function for this, perhaps even using the same states as ip.
[0] https://www.man7.org/linux/man-pages/man7/netdevice.7.html
[1] https://superuser.com/questions/1365825/how-does-iproute2s-ip-link-show-determine-link-state