From: Jason Wang <jasowang@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] tap-linux: Open ipvtap and macvtap
Date: Wed, 9 Oct 2024 15:41:06 +0800 [thread overview]
Message-ID: <CACGkMEvmEsFdLRgF9CLQCEo0jt3dX8wAPLjRC2pNb4ofD8dLNQ@mail.gmail.com> (raw)
In-Reply-To: <20241008-macvtap-v1-1-2032caa25b6d@daynix.com>
On Tue, Oct 8, 2024 at 2:52 PM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> 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.
>
Management layers usually pass these fds via SCM_RIGHTS. Is this for
testing purposes? (Note that we can use something like -netdev
tap,fd=10 10<>/dev/tap0).
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.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 1226d5fda2d9..22ec2f45d2b7 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));
Any reason tuntap were tried after the macvtap/ipvtap?
> + 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;
>
> ---
> base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
> change-id: 20241008-macvtap-b152e5abb457
>
> Best regards,
> --
> Akihiko Odaki <akihiko.odaki@daynix.com>
Thanks
>
next prev parent reply other threads:[~2024-10-09 7:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 6:52 [PATCH] tap-linux: Open ipvtap and macvtap Akihiko Odaki
2024-10-09 7:41 ` Jason Wang [this message]
2024-10-12 9:05 ` Akihiko Odaki
2024-10-18 8:10 ` Jason Wang
2024-10-22 4:59 ` Akihiko Odaki
2025-01-11 5:42 ` Akihiko Odaki
2025-01-13 2:59 ` Jason Wang
2025-01-15 5:16 ` Akihiko Odaki
2025-01-16 1:17 ` Jason Wang
2025-01-16 5:26 ` Akihiko Odaki
2025-01-20 0:38 ` Jason Wang
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=CACGkMEvmEsFdLRgF9CLQCEo0jt3dX8wAPLjRC2pNb4ofD8dLNQ@mail.gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).