Comment 16 for bug 1912844

Revision history for this message
Frode Nordahl (fnordahl) wrote :

Those subprocess calls do indeed add up to be expensive quite quickly, and when I think of it it may actually not be a consistent way of determining if a interface belongs to Open vSwitch in all its configurations. Open vSwitch supports multiple datapath types, and depending on which one you use the interface may or may not be owned by the openvswitch driver.

However, this brings me to something we might use as a consistent cross-distro way of determining whether Open vSwitch is there and has bridges configured.

When Open vSwitch registers a datapath it also creates a virtual port for it, and we could possibly look for that to determine whether Open vSwitch is installed and actually has useful configuration.

The 'system' datapath is the kernel datapath as provided by the openvswitch kernel module, the 'netdev' datapath is used for alternative datapaths such as the Open vSwitch userspace implementation, DPDK, AF_XDP etc.

Example:
# ovs-vsctl show
5ef28194-7376-40f6-9306-1a21b0624079
    Bridge br1
        datapath_type: system
        Port br1
            Interface br1
                type: internal
    Bridge br0
        datapath_type: netdev
        Port br0
            Interface br0
                type: internal
    ovs_version: "2.13.1"

# ls -l /sys/class/net/ovs-*
lrwxrwxrwx 1 root root 0 Feb 4 05:33 /sys/class/net/ovs-netdev -> ../../devices/virtual/net/ovs-netdev
lrwxrwxrwx 1 root root 0 Feb 4 06:06 /sys/class/net/ovs-system -> ../../devices/virtual/net/ovs-system