tap-linux: Get features once and use it many times
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
c444dfabfc
commit
1f149e721f
@ -52,14 +52,17 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
|||||||
memset(&ifr, 0, sizeof(ifr));
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
|
||||||
|
|
||||||
if (ioctl(fd, TUNGETFEATURES, &features) == 0 &&
|
if (ioctl(fd, TUNGETFEATURES, &features) == -1) {
|
||||||
features & IFF_ONE_QUEUE) {
|
error_report("warning: TUNGETFEATURES failed: %s", strerror(errno));
|
||||||
|
features = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features & IFF_ONE_QUEUE) {
|
||||||
ifr.ifr_flags |= IFF_ONE_QUEUE;
|
ifr.ifr_flags |= IFF_ONE_QUEUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*vnet_hdr) {
|
if (*vnet_hdr) {
|
||||||
if (ioctl(fd, TUNGETFEATURES, &features) == 0 &&
|
if (features & IFF_VNET_HDR) {
|
||||||
features & IFF_VNET_HDR) {
|
|
||||||
*vnet_hdr = 1;
|
*vnet_hdr = 1;
|
||||||
ifr.ifr_flags |= IFF_VNET_HDR;
|
ifr.ifr_flags |= IFF_VNET_HDR;
|
||||||
} else {
|
} else {
|
||||||
@ -82,8 +85,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mq_required) {
|
if (mq_required) {
|
||||||
if ((ioctl(fd, TUNGETFEATURES, &features) != 0) ||
|
if (!(features & IFF_MULTI_QUEUE)) {
|
||||||
!(features & IFF_MULTI_QUEUE)) {
|
|
||||||
error_report("multiqueue required, but no kernel "
|
error_report("multiqueue required, but no kernel "
|
||||||
"support for IFF_MULTI_QUEUE available");
|
"support for IFF_MULTI_QUEUE available");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user