Fix tap breakage on BSD hosts (no IFF_VNET_HDR)

net/tap-bsd.c was assuming IFF_VNET_HDR was always available, which
I think isn't true on any BSD.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Juergen Lock 2009-11-20 23:19:53 +01:00 committed by Blue Swirl
parent 22a2bdcbae
commit 39ca4c0832

View File

@ -59,6 +59,17 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
dev = devname(s.st_rdev, S_IFCHR);
pstrcpy(ifname, ifname_size, dev);
if (*vnet_hdr) {
/* BSD doesn't have IFF_VNET_HDR */
*vnet_hdr = 0;
if (vnet_hdr_required && !*vnet_hdr) {
qemu_error("vnet_hdr=1 requested, but no kernel "
"support for IFF_VNET_HDR available");
close(fd);
return -1;
}
}
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}