• R
    util: improve virNetDevTapGetRealDeviceName · 3b90d0dc
    Roman Bogorodskiy 提交于
    virNetDevTapGetRealDeviceName() is used on FreeBSD because interface
    names (such as one sees in output of tools like ifconfig(8)) might not
    match their /dev entity names, and for bhyve we need the latter.
    
    Current implementation is not very efficient because in order to find
    /dev name, it goes through all /dev/tap* entries and tries to issue
    TAPGIFNAME ioctl on it. Not only this is slow, but also there's a bug in
    this implementation when more than one NIC is passed to a VM: once we
    find the tap interface we're looking for, we set its state to UP because
    opening it for issuing ioctl sets it DOWN, even if it was UP before.
    When we have more than 1 NIC for a VM, we have only last one UP because
    others remain DOWN after unsuccessful attempts to match interface name.
    
    New implementation just uses sysctl(3), so it should be faster and
    won't make interfaces go down to get name.
    Signed-off-by: NRoman Bogorodskiy <bogorodskiy@gmail.com>
    Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
    3b90d0dc
virnetdevtap.c 25.2 KB