From: Jason Wang <jasowang@redhat.com>
To: "Andrey Ryabinin" <arbn@yandex-team.com>,
qemu-devel@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>, yc-core@yandex-team.ru
Subject: Re: [PATCH 2/2] tap: initialize TAPState->enabled according to the actual state of queue
Date: Tue, 28 Jun 2022 12:15:41 +0800 [thread overview]
Message-ID: <a607ebc5-e518-7b0d-722c-1bebcb18bb41@redhat.com> (raw)
In-Reply-To: <20220614112144.25324-1-arbn@yandex-team.com>
在 2022/6/14 19:21, Andrey Ryabinin 写道:
> Currently TAPState->enabled initialized as true. If fd was passed to qemu
> in a disabled state it will cause an assert at the attempt to detach queue
> in virtio_net_set_queues():
>
> virtio_net_set_queues() :
> r = peer_detach() -> tap_disable():
> if (s->enabled == 0) {
> return 0;
> } else {
> //Will return an error.
> ret = tap_fd_disable(s->fd);
> ...
> return ret;
> assert(!r);
>
> Initialize ->enabled according to the actual state of fd to fix this.
>
> Signed-off-by: Andrey Ryabinin <arbn@yandex-team.com>
> ---
> net/tap-bsd.c | 5 +++++
> net/tap-linux.c | 12 ++++++++++++
> net/tap-solaris.c | 5 +++++
> net/tap.c | 2 +-
> net/tap_int.h | 1 +
> 5 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index 005ce05c6e0..8c21f058c8c 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -217,6 +217,11 @@ int tap_probe_vnet_hdr_len(int fd, int len)
> return 0;
> }
>
> +bool tap_probe_enabled(int fd)
> +{
> + return true;
> +}
> +
> void tap_fd_set_vnet_hdr_len(int fd, int len)
> {
> }
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index 304ff45071d..6078ba03af6 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -193,6 +193,18 @@ int tap_probe_vnet_hdr_len(int fd, int len)
> return 1;
> }
>
> +bool tap_probe_enabled(int fd)
> +{
> + struct ifreq ifr;
> +
> + if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
> + error_report("TUNGETIFF ioctl() failed: %s",
> + strerror(errno));
> + return false;
> + }
> + return !(ifr.ifr_flags & IFF_DETACH_QUEUE);
Is it better to check IFF_MULT_QUEUE before this to unbreak the old host?
Thanks
> +}
> +
> void tap_fd_set_vnet_hdr_len(int fd, int len)
> {
> if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
> diff --git a/net/tap-solaris.c b/net/tap-solaris.c
> index a44f8805c23..ccaa3334882 100644
> --- a/net/tap-solaris.c
> +++ b/net/tap-solaris.c
> @@ -221,6 +221,11 @@ int tap_probe_vnet_hdr_len(int fd, int len)
> return 0;
> }
>
> +bool tap_probe_enabled(int fd)
> +{
> + return true;
> +}
> +
> void tap_fd_set_vnet_hdr_len(int fd, int len)
> {
> }
> diff --git a/net/tap.c b/net/tap.c
> index b3ddfd4a74b..799f8ec7c76 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -399,7 +399,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
> s->host_vnet_hdr_len = vnet_hdr ? sizeof(struct virtio_net_hdr) : 0;
> s->using_vnet_hdr = false;
> s->has_ufo = tap_probe_has_ufo(s->fd);
> - s->enabled = true;
> + s->enabled = tap_probe_enabled(s->fd);
> tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
> /*
> * Make sure host header length is set correctly in tap:
> diff --git a/net/tap_int.h b/net/tap_int.h
> index 547f8a5a28f..b8fc3dfbfa7 100644
> --- a/net/tap_int.h
> +++ b/net/tap_int.h
> @@ -37,6 +37,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp);
> int tap_probe_vnet_hdr(int fd, Error **errp);
> int tap_probe_vnet_hdr_len(int fd, int len);
> int tap_probe_has_ufo(int fd);
> +bool tap_probe_enabled(int fd);
> void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo);
> void tap_fd_set_vnet_hdr_len(int fd, int len);
> int tap_fd_set_vnet_le(int fd, int vnet_is_le);
next prev parent reply other threads:[~2022-06-28 4:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 11:18 [PATCH 0/2] Make local migration with TAP network device possible Andrey Ryabinin
2022-06-14 11:18 ` [PATCH 1/2] chardev: don't set O_NONBLOCK on SCM_RIGHTS file descriptors Andrey Ryabinin
2022-06-15 13:12 ` Stefan Hajnoczi
2022-06-24 11:00 ` Andrey Ryabinin
2022-06-24 11:34 ` Daniel P. Berrangé
2022-06-14 11:21 ` [PATCH 2/2] tap: initialize TAPState->enabled according to the actual state of queue Andrey Ryabinin
2022-06-28 4:15 ` Jason Wang [this message]
2022-06-14 11:32 ` [PATCH 0/2] Make local migration with TAP network device possible Daniel P. Berrangé
2022-06-15 13:10 ` Stefan Hajnoczi
2022-06-24 10:53 ` Andrey Ryabinin
2022-06-24 11:45 ` 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=a607ebc5-e518-7b0d-722c-1bebcb18bb41@redhat.com \
--to=jasowang@redhat.com \
--cc=arbn@yandex-team.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@redhat.com \
--cc=yc-core@yandex-team.ru \
/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.