提交 93a7320e 编写于 作者: L Luiz Capitulino 提交者: Stefan Hajnoczi

net: tap-linux: Fix unhelpful error message

I'm getting:

    could not configure /dev/net/tun (tap%d): Operation not permitted

When the ioctl() fails, ifr.ifr_name will most likely not be overwritten.
So we better only use it when ifname contains a string.
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 ff74c5a9
......@@ -73,7 +73,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (ret != 0) {
error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name);
if (ifname[0] != '\0') {
error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name);
} else {
error_report("could not configure %s: %m", PATH_NET_TUN);
}
close(fd);
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册