devlink: Modify reply of DEVLINK_CMD_HEALTH_REPORTER_GET
authorAya Levin <ayal@mellanox.com>
Thu, 21 Feb 2019 12:12:02 +0000 (14:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Feb 2019 18:38:51 +0000 (10:38 -0800)
Avoid sending attributes related to recovery:
DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD and
DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER in reply to
DEVLINK_CMD_HEALTH_REPORTER_GET for a reporter which didn't register a
recover operation.
These parameters can't be configured on a reporter that did not provide
a recover operation, thus not needed to return them.

Fixes: 7afe335a8bed ("devlink: Add health get command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c

index 5135997ecbe7c3d037d81fdfe9a6cbbd9c905e6e..4f31ddc883e7ae2fd30cb69c9232e1d86c807e2b 100644 (file)
@@ -4656,11 +4656,13 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg,
        if (nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT,
                              reporter->recovery_count, DEVLINK_ATTR_PAD))
                goto reporter_nest_cancel;
-       if (nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD,
+       if (reporter->ops->recover &&
+           nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD,
                              reporter->graceful_period,
                              DEVLINK_ATTR_PAD))
                goto reporter_nest_cancel;
-       if (nla_put_u8(msg, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER,
+       if (reporter->ops->recover &&
+           nla_put_u8(msg, DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER,
                       reporter->auto_recover))
                goto reporter_nest_cancel;
        if (reporter->dump_fmsg &&