From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, johannes@sipsolutions.net,
Vladimir Oltean <vladimir.oltean@nxp.com>,
gal@nvidia.com, tariqt@nvidia.com, lucien.xin@gmail.com,
f.fainelli@gmail.com, andrew@lunn.ch, simon.horman@corigine.com,
linux@rempel-privat.de, mkubecek@suse.cz
Subject: Re: [PATCH net-next v2 10/10] ethtool: netlink: always pass genl_info to .prepare_data
Date: Fri, 11 Aug 2023 08:42:45 +0200 [thread overview]
Message-ID: <ZNXYZRNJkAqw686J@nanopsycho> (raw)
In-Reply-To: <20230810233845.2318049-11-kuba@kernel.org>
Fri, Aug 11, 2023 at 01:38:45AM CEST, kuba@kernel.org wrote:
[...]
>diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
>index f7b3171a0aad..3bbd5afb7b31 100644
>--- a/net/ethtool/netlink.c
>+++ b/net/ethtool/netlink.c
>@@ -444,12 +444,12 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
>
> static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev,
> const struct ethnl_dump_ctx *ctx,
>- struct netlink_callback *cb)
>+ const struct genl_info *info)
> {
> void *ehdr;
> int ret;
>
>- ehdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
>+ ehdr = genlmsg_put(skb, info->snd_portid, info->snd_seq,
> ðtool_genl_family, NLM_F_MULTI,
> ctx->ops->reply_cmd);
> if (!ehdr)
>@@ -457,7 +457,7 @@ static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev,
>
> ethnl_init_reply_data(ctx->reply_data, ctx->ops, dev);
> rtnl_lock();
>- ret = ctx->ops->prepare_data(ctx->req_info, ctx->reply_data, NULL);
>+ ret = ctx->ops->prepare_data(ctx->req_info, ctx->reply_data, info);
> rtnl_unlock();
> if (ret < 0)
> goto out;
>@@ -495,7 +495,7 @@ static int ethnl_default_dumpit(struct sk_buff *skb,
> dev_hold(dev);
> rtnl_unlock();
>
>- ret = ethnl_default_dump_one(skb, dev, ctx, cb);
>+ ret = ethnl_default_dump_one(skb, dev, ctx, genl_info_dump(cb));
>
> rtnl_lock();
> dev_put(dev);
>@@ -647,11 +647,14 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> struct ethnl_reply_data *reply_data;
> const struct ethnl_request_ops *ops;
> struct ethnl_req_info *req_info;
>+ struct genl_info info;
> struct sk_buff *skb;
> void *reply_payload;
> int reply_len;
> int ret;
>
>+ genl_info_init_ntf(&info, ðtool_genl_family, cmd);
>+
> if (WARN_ONCE(cmd > ETHTOOL_MSG_KERNEL_MAX ||
> !ethnl_default_notify_ops[cmd],
> "unexpected notification type %u\n", cmd))
>@@ -670,7 +673,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
> req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
>
> ethnl_init_reply_data(reply_data, ops, dev);
>- ret = ops->prepare_data(req_info, reply_data, NULL);
>+ ret = ops->prepare_data(req_info, reply_data, &info);
> if (ret < 0)
> goto err_cleanup;
> ret = ops->reply_size(req_info, reply_data);
[...]
>@@ -24,7 +24,7 @@ const struct nla_policy ethnl_wol_get_policy[] = {
>
> static int wol_prepare_data(const struct ethnl_req_info *req_base,
> struct ethnl_reply_data *reply_base,
>- struct genl_info *info)
>+ const struct genl_info *info)
> {
> struct wol_reply_data *data = WOL_REPDATA(reply_base);
> struct net_device *dev = reply_base->dev;
>@@ -39,7 +39,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base,
> dev->ethtool_ops->get_wol(dev, &data->wol);
> ethnl_ops_complete(dev);
> /* do not include password in notifications */
>- data->show_sopass = info && (data->wol.supported & WAKE_MAGICSECURE);
>+ data->show_sopass = genl_info_is_ntf(info) &&
>+ (data->wol.supported & WAKE_MAGICSECURE);
I believe that you are missing "!" here:
data->show_sopass = !genl_info_is_ntf(info) &&
(data->wol.supported & WAKE_MAGICSECURE);
But, you are changing the output for dumpit if I'm not mistaken.
ethnl_default_dump_one() currently calls this with info==NULL too, not
only ethnl_default_notify().
Anyway, the genl_info_is_ntf() itself seems a bit odd to me. The only
user is here and I doubt there ever going to be any other. This
conditional per-op attr fill seems a bit odd.
Can't you handle this in side ethtool somehow? IDK :/
>
> return 0;
> }
>--
>2.41.0
>
next prev parent reply other threads:[~2023-08-11 6:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 23:38 [PATCH net-next v2 00/10] genetlink: provide struct genl_info to dumps Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 01/10] genetlink: push conditional locking into dumpit/done Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 02/10] genetlink: make genl_info->nlhdr const Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 03/10] genetlink: remove userhdr from struct genl_info Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 04/10] genetlink: add struct genl_info to struct genl_dumpit_info Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 05/10] genetlink: use attrs from struct genl_info Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 06/10] genetlink: add a family pointer to " Jakub Kicinski
2023-08-11 6:28 ` Jiri Pirko
2023-08-10 23:38 ` [PATCH net-next v2 07/10] genetlink: add genlmsg_iput() API Jakub Kicinski
2023-08-11 6:44 ` Jiri Pirko
2023-08-10 23:38 ` [PATCH net-next v2 08/10] netdev-genl: use struct genl_info for reply construction Jakub Kicinski
2023-08-11 6:44 ` Jiri Pirko
2023-08-10 23:38 ` [PATCH net-next v2 09/10] ethtool: netlink: simplify arguments to ethnl_default_parse() Jakub Kicinski
2023-08-10 23:38 ` [PATCH net-next v2 10/10] ethtool: netlink: always pass genl_info to .prepare_data Jakub Kicinski
2023-08-11 6:42 ` Jiri Pirko [this message]
2023-08-11 7:13 ` Michal Kubecek
2023-08-11 7:29 ` Jiri Pirko
2023-08-11 22:24 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZNXYZRNJkAqw686J@nanopsycho \
--to=jiri@resnulli.us \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=gal@nvidia.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux@rempel-privat.de \
--cc=lucien.xin@gmail.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.com \
--cc=tariqt@nvidia.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).