I would like to detect whether a network interface is "physical" or "virtual", where "physical" means that the interface has hardware attached, even if that "hardware" is virtualized by a hypervisor. "Virtual" then means that it's one of the Linux kernel elements, such as bridges, veths, macvlans, et cetera.
I'm aware that by using
/sys/class/net/[nif]/... I can follow the device link and thus differentiate between (virtual) physical and "real" (sic!) virtual network interfaces, based on the device path containing the "virtual" sub directory or not. However, when dealing with network namespaces, this requires a properly remounted
sysfs in order to be able to see the correct
/sys/class/net/... entries. So a simpler method relying solely on RTNETLINK data might be more suitable.
When using RTNETLINK to discover the available network interfaces is there some property/attribute which allows me to differentiate without the need to check