Thread (21 messages) 21 messages, 3 authors, 2023-01-30

Re: [PATCH v3 4/4] vdpa: fix improper error message when adding vdpa dev

From: Jason Wang <hidden>
Date: 2022-10-24 08:43:38
Also in: lkml

On Sat, Oct 22, 2022 at 7:49 AM Si-Wei Liu [off-list ref] wrote:
In below example, before the fix, mtu attribute is supported
by the parent mgmtdev, but the error message showing "All
provided are not supported" is just misleading.

$ vdpa mgmtdev show
vdpasim_net:
  supported_classes net
  max_supported_vqs 3
  dev_features MTU MAC CTRL_VQ CTRL_MAC_ADDR ANY_LAYOUT VERSION_1 ACCESS_PLATFORM

$ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2
Error: vdpa: All provided attributes are not supported.
kernel answers: Operation not supported

After fix, the relevant error message will be like:

$ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2
Error: vdpa: Some provided attributes are not supported.
kernel answers: Operation not supported

$ vdpa dev add mgmtdev vdpasim_net name vdpasim0 max_vqp 2
Error: vdpa: All provided attributes are not supported.
kernel answers: Operation not supported

Signed-off-by: Si-Wei Liu <redacted>
Acked-by: Jason Wang <redacted>
quoted hunk ↗ jump to hunk
---
 drivers/vdpa/vdpa.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index bfb8f54..2638565 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -629,13 +629,20 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
                err = PTR_ERR(mdev);
                goto err;
        }
-       if ((config.mask & mdev->config_attr_mask) != config.mask) {
+       if (config.mask && (config.mask & mdev->config_attr_mask) == 0) {
                NL_SET_ERR_MSG_MOD(info->extack,
                                   "All provided attributes are not supported");
                err = -EOPNOTSUPP;
                goto err;
        }

+       if ((config.mask & mdev->config_attr_mask) != config.mask) {
+               NL_SET_ERR_MSG_MOD(info->extack,
+                                  "Some provided attributes are not supported");
+               err = -EOPNOTSUPP;
+               goto err;
+       }
+
        err = mdev->ops->dev_add(mdev, name, &config);
 err:
        up_write(&vdpa_dev_lock);
--
1.8.3.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help