]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: improve virNetDevTapGetRealDeviceName
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sun, 8 Apr 2018 15:30:29 +0000 (19:30 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 24 Apr 2018 17:08:19 +0000 (21:08 +0400)
commit3b90d0dc1a705d3194b23105a203004fdec49b46
tree3afc557ac6a3708bdb3129a94557608628e9c28c
parent5cca0cb6a0be68dcbb7c2c8930863ff09fa898f8
util: improve virNetDevTapGetRealDeviceName

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: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevtap.c