From: Adrian Moreno Date: Mon, 26 Oct 2020 16:39:26 +0000 (+0100) Subject: net/virtio-user: do not assume features are negotiated X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0fa6d4c406892efa58a656ea0860f8422c3bf0e2;p=dpdk.git net/virtio-user: do not assume features are negotiated According to the virtio spec, ACK and DRIVER status bits should be set before feature negotiation. However, until the protocol features are negotiated, the driver does not know if the device actually supports those vhost-user messages. Therefore, until FEATURES_OK is set, the GET/SET_STATUS messages should not be sent. Fixes: 57912824615f ("net/virtio-user: support vhost status setting") Cc: stable@dpdk.org Reviewed-by: Maxime Coquelin Signed-off-by: Adrian Moreno --- diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index ef290c357b..450d77e921 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -278,8 +278,9 @@ vhost_user_sock(struct virtio_user_dev *dev, switch (req) { case VHOST_USER_GET_STATUS: - if (!(dev->protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) + if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) || + (!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))) return 0; /* Fallthrough */ case VHOST_USER_GET_FEATURES: @@ -288,8 +289,9 @@ vhost_user_sock(struct virtio_user_dev *dev, break; case VHOST_USER_SET_STATUS: - if (!(dev->protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_STATUS))) + if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) || + (!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))) return 0; if (has_reply_ack)