devlink: allow to fillup eswitch attrs even if mode_get op does not exist
authorJiri Pirko <jiri@mellanox.com>
Thu, 9 Feb 2017 14:54:36 +0000 (15:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 10 Feb 2017 19:43:00 +0000 (14:43 -0500)
Even when mode_get op is not present, other eswitch attrs need to be
filled-up.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c

index 7f88cc879d434ba5083cc0a78a2829369966ad0e..e9c1e6acfb6d196d4373dcc36bcf76577952dd32 100644 (file)
@@ -1410,12 +1410,14 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
        if (err)
                goto nla_put_failure;
 
-       err = ops->eswitch_mode_get(devlink, &mode);
-       if (err)
-               goto nla_put_failure;
-       err = nla_put_u16(msg, DEVLINK_ATTR_ESWITCH_MODE, mode);
-       if (err)
-               goto nla_put_failure;
+       if (ops->eswitch_mode_get) {
+               err = ops->eswitch_mode_get(devlink, &mode);
+               if (err)
+                       goto nla_put_failure;
+               err = nla_put_u16(msg, DEVLINK_ATTR_ESWITCH_MODE, mode);
+               if (err)
+                       goto nla_put_failure;
+       }
 
        if (ops->eswitch_inline_mode_get) {
                err = ops->eswitch_inline_mode_get(devlink, &inline_mode);
@@ -1443,7 +1445,7 @@ static int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb,
        struct sk_buff *msg;
        int err;
 
-       if (!ops || !ops->eswitch_mode_get)
+       if (!ops)
                return -EOPNOTSUPP;
 
        msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);