net/virtio: check protocol feature in user backend
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Tue, 29 Sep 2020 16:14:01 +0000 (18:14 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 21:16:56 +0000 (23:16 +0200)
When sending set status message, move protocol feature check
to vhost_user to be compatible with different backend types.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
drivers/net/virtio/virtio_user/vhost_user.c
drivers/net/virtio/virtio_user/virtio_user_dev.c

index 12b6c7d..ef290c3 100644 (file)
@@ -277,9 +277,13 @@ vhost_user_sock(struct virtio_user_dev *dev,
        msg.size = 0;
 
        switch (req) {
+       case VHOST_USER_GET_STATUS:
+               if (!(dev->protocol_features &
+                               (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
+                       return 0;
+               /* Fallthrough */
        case VHOST_USER_GET_FEATURES:
        case VHOST_USER_GET_PROTOCOL_FEATURES:
-       case VHOST_USER_GET_STATUS:
                need_reply = 1;
                break;
 
index b79a9f8..d7cd6b0 100644 (file)
@@ -788,9 +788,6 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)
        if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
                return 0;
 
-       if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
-               return 0;
-
        ret = dev->ops->send_request(dev, VHOST_USER_SET_STATUS, &arg);
        if (ret) {
                PMD_INIT_LOG(ERR, "VHOST_USER_SET_STATUS failed (%d): %s", ret,
@@ -811,9 +808,6 @@ virtio_user_update_status(struct virtio_user_dev *dev)
        if (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER)
                return 0;
 
-       if (!(dev->protocol_features & (1UL << VHOST_USER_PROTOCOL_F_STATUS)))
-               return 0;
-
        err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret);
        if (err) {
                PMD_INIT_LOG(ERR, "VHOST_USER_GET_STATUS failed (%d): %s", err,