I have reservations about introducing a call to an external program in this codepath; I believe we'd have to call it for every interface (that wasn't excluded via some earlier check), and subprocess calls are much more expensive than reading files. Via local testing with timeit: is_vlan takes ~48.3 usec per loop, a subp of `udevadm info ...` takes ~2.48 msec per loop. This isn't too substantial in most systems, but in systems with more interfaces (or slower `udevadm`?), it could become something of an issue.
I suspect, however, that we can find a way of gating this check on the presence of OVS somehow: if openvswitch-switch is not installed, for example, then there's no reason to check `udevadm info`: the given interface will never be OVS-managed.
What's a reliable, cross-distro way of checking if a system might have OVS-managed interfaces?
I can confirm that udev does report the VLAN as OVS-managed:
# udevadm info /sys/class/ net/ovs- br.100 virtual/ net/ovs- br.100 /devices/ virtual/ net/ovs- br.100 ovs-br. 100 D=4703175 NAMING_ SCHEME= v245 DRIVER= openvswitch LINK_FILE= /usr/lib/ systemd/ network/ 99-default. link ALIAS=/ sys/subsystem/ net/devices/ ovs-br. 100
P: /devices/
L: 0
E: DEVPATH=
E: INTERFACE=
E: IFINDEX=5
E: SUBSYSTEM=net
E: USEC_INITIALIZE
E: ID_MM_CANDIDATE=1
E: ID_NET_
E: ID_NET_
E: ID_NET_
E: SYSTEMD_
E: TAGS=:systemd:
so this is a feasible approach, at least.
I have reservations about introducing a call to an external program in this codepath; I believe we'd have to call it for every interface (that wasn't excluded via some earlier check), and subprocess calls are much more expensive than reading files. Via local testing with timeit: is_vlan takes ~48.3 usec per loop, a subp of `udevadm info ...` takes ~2.48 msec per loop. This isn't too substantial in most systems, but in systems with more interfaces (or slower `udevadm`?), it could become something of an issue.
I suspect, however, that we can find a way of gating this check on the presence of OVS somehow: if openvswitch-switch is not installed, for example, then there's no reason to check `udevadm info`: the given interface will never be OVS-managed.
What's a reliable, cross-distro way of checking if a system might have OVS-managed interfaces?