]> git.droids-corp.org - dpdk.git/blobdiff - drivers/net/virtio/virtio_user/vhost_user.c
net/virtio-user: fix advertising of protocol features
[dpdk.git] / drivers / net / virtio / virtio_user / vhost_user.c
index ef290c357b008a4131bb9917d712163a38beb962..706266a216d9d7e61c8d544c542916fd1be30062 100644 (file)
@@ -278,9 +278,10 @@ 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)))
-                       return 0;
+               if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) ||
+                   (!(dev->protocol_features &
+                               (1ULL << VHOST_USER_PROTOCOL_F_STATUS))))
+                       return -ENOTSUP;
                /* Fallthrough */
        case VHOST_USER_GET_FEATURES:
        case VHOST_USER_GET_PROTOCOL_FEATURES:
@@ -288,14 +289,19 @@ vhost_user_sock(struct virtio_user_dev *dev,
                break;
 
        case VHOST_USER_SET_STATUS:
-               if (!(dev->protocol_features &
-                               (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))
-                       return 0;
+               if (!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK) ||
+                   (!(dev->protocol_features &
+                               (1ULL << VHOST_USER_PROTOCOL_F_STATUS))))
+                       return -ENOTSUP;
 
                if (has_reply_ack)
                        msg.flags |= VHOST_USER_NEED_REPLY_MASK;
                /* Fallthrough */
        case VHOST_USER_SET_FEATURES:
+               msg.payload.u64 = *((__u64 *)arg) |
+                       1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+               msg.size = sizeof(m.payload.u64);
+               break;
        case VHOST_USER_SET_PROTOCOL_FEATURES:
        case VHOST_USER_SET_LOG_BASE:
                msg.payload.u64 = *((__u64 *)arg);