From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>,
Jason Wang <jasowang@redhat.com>
Subject: [PULL 5/5] tap-linux: Open ipvtap and macvtap
Date: Mon, 10 Mar 2025 20:22:40 +0800 [thread overview]
Message-ID: <20250310122240.2908-6-jasowang@redhat.com> (raw)
In-Reply-To: <20250310122240.2908-1-jasowang@redhat.com>
From: Akihiko Odaki <akihiko.odaki@daynix.com>
ipvtap and macvtap create a file for each interface unlike tuntap, which
creates one file shared by all interfaces. Try to open a file dedicated
to the interface first for ipvtap and macvtap.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
net/tap-linux.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 1226d5fda2..22ec2f45d2 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -45,10 +45,21 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
int len = sizeof(struct virtio_net_hdr);
unsigned int features;
- fd = RETRY_ON_EINTR(open(PATH_NET_TUN, O_RDWR));
+
+ ret = if_nametoindex(ifname);
+ if (ret) {
+ g_autofree char *file = g_strdup_printf("/dev/tap%d", ret);
+ fd = open(file, O_RDWR);
+ } else {
+ fd = -1;
+ }
+
if (fd < 0) {
- error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN);
- return -1;
+ fd = RETRY_ON_EINTR(open(PATH_NET_TUN, O_RDWR));
+ if (fd < 0) {
+ error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN);
+ return -1;
+ }
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
--
2.42.0
next prev parent reply other threads:[~2025-03-10 12:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 12:22 [PULL 0/5] Net patches Jason Wang
2025-03-10 12:22 ` [PULL 1/5] net: parameterize the removing client from nc list Jason Wang
2025-03-10 12:22 ` [PULL 2/5] net: move backend cleanup to NIC cleanup Jason Wang
2025-08-19 16:13 ` David Woodhouse
2025-08-20 2:34 ` Jason Wang
2025-08-20 6:46 ` David Woodhouse
2025-08-20 7:14 ` Eugenio Perez Martin
2025-08-20 12:22 ` Jonah Palmer
2025-08-20 18:06 ` David Woodhouse
2025-03-10 12:22 ` [PULL 3/5] util/iov: Do not assert offset is in iov Jason Wang
2025-03-10 12:22 ` [PULL 4/5] Revert "hw/net/net_tx_pkt: Fix overrun in update_sctp_checksum()" Jason Wang
2025-03-10 12:22 ` Jason Wang [this message]
2025-03-11 5:03 ` [PULL 0/5] Net patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250310122240.2908-6-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.