From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: "Wang, Xiao W" <xiao.w.wang@intel.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"Wang, Zhihong" <zhihong.wang@intel.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [PATCH] net/virtio-user: fix virtio net status management
Date: Tue, 28 Jul 2020 07:45:05 +0000 [thread overview]
Message-ID: <MN2PR11MB406332DCF308D1286E0160559C730@MN2PR11MB4063.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200728065212.16703-1-xiao.w.wang@intel.com>
> -----Original Message-----
> From: Wang, Xiao W <xiao.w.wang@intel.com>
> Sent: Tuesday, July 28, 2020 2:52 PM
> To: maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Wang, Zhihong <zhihong.wang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>; Wang, Xiao W <xiao.w.wang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH] net/virtio-user: fix virtio net status management
>
> Apart from the virtio status, there should be also a network related status for
> link status management, current implementation mixes up these two statuses.
>
> One issue caused by this mixup is when virtio-user running in server mode and
> vhost as a client connects to it, a RARP packet will be generated by virtio-user
> due to VIRTIO_NET_S_ANNOUNCE bit is detected in the "status"
> in interrupt handler.
>
> VIRTIO_NET_S_LINK_UP and VIRTIO_NET_S_ANNOUNCE should be managed by
> a separated field. This patch adds a "net_status" field for this purpose.
>
> Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver")
> Cc: stable@dpdk.org
>
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
> drivers/net/virtio/virtio_user/virtio_user_dev.h | 1 +
> drivers/net/virtio/virtio_user_ethdev.c | 10 +++++-----
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> index 56e638f8a..554174e81 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> @@ -44,6 +44,7 @@ struct virtio_user_dev {
> * (Vhost-user only)
> */
> uint8_t status;
> + uint16_t net_status;
> uint16_t port_id;
> uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
> char path[PATH_MAX];
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index e51425c4f..6003f6d50 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -205,7 +205,7 @@ virtio_user_read_dev_config(struct virtio_hw *hw,
> size_t offset,
> }
> r = recv(dev->vhostfd, buf, 128, MSG_PEEK);
> if (r == 0 || (r < 0 && errno != EAGAIN)) {
> - dev->status &= (~VIRTIO_NET_S_LINK_UP);
> + dev->net_status &= (~VIRTIO_NET_S_LINK_UP);
> PMD_DRV_LOG(ERR, "virtio-user port %u is
> down",
> hw->port_id);
>
> @@ -217,7 +217,7 @@ virtio_user_read_dev_config(struct virtio_hw *hw,
> size_t offset,
> virtio_user_delayed_handler,
> (void *)hw);
> } else {
> - dev->status |= VIRTIO_NET_S_LINK_UP;
> + dev->net_status |= VIRTIO_NET_S_LINK_UP;
> }
> if (fcntl(dev->vhostfd, F_SETFL,
> flags & ~O_NONBLOCK) == -1) {
> @@ -225,12 +225,12 @@ virtio_user_read_dev_config(struct virtio_hw *hw,
> size_t offset,
> return;
> }
> } else if (dev->is_server) {
> - dev->status &= (~VIRTIO_NET_S_LINK_UP);
> + dev->net_status &= (~VIRTIO_NET_S_LINK_UP);
> if (virtio_user_server_reconnect(dev) >= 0)
> - dev->status |= VIRTIO_NET_S_LINK_UP;
> + dev->net_status |= VIRTIO_NET_S_LINK_UP;
> }
>
> - *(uint16_t *)dst = dev->status;
> + *(uint16_t *)dst = dev->net_status;
> }
>
> if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
> --
> 2.15.1
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
next prev parent reply other threads:[~2020-07-28 7:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 6:52 Xiao Wang
2020-07-28 7:45 ` Xia, Chenbo [this message]
2020-07-28 13:59 ` Maxime Coquelin
2020-07-28 15:54 ` Maxime Coquelin
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=MN2PR11MB406332DCF308D1286E0160559C730@MN2PR11MB4063.namprd11.prod.outlook.com \
--to=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=xiao.w.wang@intel.com \
--cc=zhihong.wang@intel.com \
/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).