Skip to content

Improved is_up alternative #124

@Coi-l

Description

@Coi-l

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions