From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: Jianfeng Tan <jianfeng.tan@intel.com>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>
Subject: [dpdk-dev] [PATCH] net/virtio-user: fix cannot get initialized
Date: Fri, 7 Apr 2017 07:57:40 +0000 [thread overview]
Message-ID: <1491551860-15005-1-git-send-email-jianfeng.tan@intel.com> (raw)
After the introduction of vhost MTU, VIRTIO_NET_F_MTU is enabled
by default. However, virtio-user vtpci does not support to get
MTU from device yet, i.e., vtpci_read_dev_config(MTU) fails.
Plus, struct virtio_net_config is defined as a uninitialized
variable, and could be different values in
virtio_negotiate_features() and virtio_init_device().
In some cases, it passes the check in virtio_negotiate_features()
but fails the check in virtio_init_device(). As a result,
virtio-user canno be initialized.
To fix it, (1) accessing uninitialized variable is not a good
practice, so initialize it as zero; (2) explicitly disable MTU
feature in virtio-user.
Fixes: 49d26d9e3f47 ("net/virtio: support MTU feature")
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 4 ++--
drivers/net/virtio/virtio_user/virtio_user_dev.c | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 78cb3e8..4c43784 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1163,7 +1163,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)
/* If supported, ensure MTU value is valid before acknowledging it. */
if (host_features & req_features & (1ULL << VIRTIO_NET_F_MTU)) {
- struct virtio_net_config config;
+ struct virtio_net_config config = {0};
vtpci_read_dev_config(hw,
offsetof(struct virtio_net_config, mtu),
@@ -1332,7 +1332,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
{
struct virtio_hw *hw = eth_dev->data->dev_private;
struct virtio_net_config *config;
- struct virtio_net_config local_config;
+ struct virtio_net_config local_config = {0};
struct rte_pci_device *pci_dev = NULL;
int ret;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 6871cd4..529b3d7 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -362,6 +362,12 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
/* The backend will not report this feature, we add it explicitly */
dev->device_features |= (1ull << VIRTIO_NET_F_STATUS);
+ /* TODO: VIRTIO_NET_F_MTU is for QEMU to advertise MTU to both frontend
+ * and backend driver. For virtio-user, disable it for now, until we
+ * have a parameter to specify the MTU.
+ */
+ dev->device_features &= ~(1ull << VIRTIO_NET_F_MTU);
+
return 0;
}
--
2.7.4
next reply other threads:[~2017-04-07 7:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-07 7:57 Jianfeng Tan [this message]
2017-04-13 1:58 ` Yuanhan Liu
2017-04-13 2:18 ` Tan, Jianfeng
2017-04-13 2:21 ` Yuanhan Liu
2017-04-13 7:37 ` Tan, Jianfeng
2017-04-13 2:36 ` Yuanhan Liu
2017-04-13 7:39 ` Tan, Jianfeng
2017-04-13 10:11 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
2017-04-14 4:24 ` Yuanhan Liu
2017-04-14 4:35 ` Tan, Jianfeng
2017-04-14 5:37 ` Yuanhan Liu
2017-04-14 5:55 ` Tan, Jianfeng
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=1491551860-15005-1-git-send-email-jianfeng.tan@intel.com \
--to=jianfeng.tan@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=yuanhan.liu@linux.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).