[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190115101217.GC2290@nanopsycho>
Date: Tue, 15 Jan 2019 11:12:17 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org,
oss-drivers@...ronome.com
Subject: Re: [RFC net-next 2/6] devlink: add version reporting API
Tue, Jan 15, 2019 at 01:50:04AM CET, jakub.kicinski@...ronome.com wrote:
[...]
>@@ -3701,6 +3732,40 @@ static int devlink_nl_cmd_info_get_dumpit(struct sk_buff *msg,
> return msg->len;
> }
>
>+int devlink_versions_report(struct sk_buff *skb, enum devlink_attr attr,
>+ const char *version_name, const char *version_value)
Hmm, so this is a helper to construct the msg. I think it would be good
to have this somehow separated from the netlink. Meaning a separate enum
just for fixed/running/stored and perhaps a "context structure" which
you can use just as a pointer with layout invisible for the driver
(containing skb). Passing skb itself is a bit confusing and gives the
driver opportunity to put in some weird crap. Better to disallow it by
the api design.
>+{
>+ struct nlattr *nest;
>+ int err;
>+
>+ if (attr < DEVLINK_ATTR_INFO_VERSIONS_FIXED ||
>+ attr > DEVLINK_ATTR_INFO_VERSIONS_STORED)
>+ return -EINVAL;
>+
>+ nest = nla_nest_start(skb, attr);
>+ if (!nest)
>+ return -EMSGSIZE;
>+
>+ err = nla_put_string(skb, DEVLINK_ATTR_INFO_VERSIONS_NAME,
>+ version_name);
>+ if (err)
>+ goto nla_put_failure;
>+
>+ err = nla_put_string(skb, DEVLINK_ATTR_INFO_VERSIONS_VALUE,
>+ version_value);
>+ if (err)
>+ goto nla_put_failure;
>+
>+ nla_nest_end(skb, nest);
>+
>+ return 0;
>+
>+nla_put_failure:
>+ nla_nest_cancel(skb, nest);
>+ return err;
>+}
>+EXPORT_SYMBOL_GPL(devlink_versions_report);
>+
> static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
> [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING },
> [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING },
>--
>2.19.2
>
Powered by blists - more mailing lists