From: Donald Hunter <donald.hunter@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch,
horms@kernel.org, maxime.chevallier@bootlin.com,
sdf@fomichev.me, jdamato@fastly.com, ecree.xilinx@gmail.com
Subject: Re: [PATCH net-next 2/9] net: ethtool: dynamically allocate full req size req
Date: Mon, 23 Jun 2025 13:01:10 +0100 [thread overview]
Message-ID: <m2a55yekft.fsf@gmail.com> (raw)
In-Reply-To: <20250621171944.2619249-3-kuba@kernel.org>
Jakub Kicinski <kuba@kernel.org> writes:
> In preparation for using req_info to carry parameters between
> SET and NTF allocate a full request into struct. Since the size
typo: into -> info
> depends on the subcommand we need to allocate it on the heap.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> net/ethtool/netlink.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> index 9de828df46cd..a9467b96f00c 100644
> --- a/net/ethtool/netlink.c
> +++ b/net/ethtool/netlink.c
> @@ -863,8 +863,8 @@ static int ethnl_default_done(struct netlink_callback *cb)
> static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
> {
> const struct ethnl_request_ops *ops;
> - struct ethnl_req_info req_info = {};
> const u8 cmd = info->genlhdr->cmd;
> + struct ethnl_req_info *req_info;
> struct net_device *dev;
> int ret;
>
> @@ -874,20 +874,24 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
> if (GENL_REQ_ATTR_CHECK(info, ops->hdr_attr))
> return -EINVAL;
>
> - ret = ethnl_parse_header_dev_get(&req_info, info->attrs[ops->hdr_attr],
> + req_info = kzalloc(ops->req_info_size, GFP_KERNEL);
> + if (!req_info)
> + return -ENOMEM;
> +
> + ret = ethnl_parse_header_dev_get(req_info, info->attrs[ops->hdr_attr],
> genl_info_net(info), info->extack,
> true);
> if (ret < 0)
> - return ret;
> + goto out_free_req;
>
> if (ops->set_validate) {
> - ret = ops->set_validate(&req_info, info);
> + ret = ops->set_validate(req_info, info);
> /* 0 means nothing to do */
> if (ret <= 0)
> goto out_dev;
> }
>
> - dev = req_info.dev;
> + dev = req_info->dev;
>
> rtnl_lock();
> netdev_lock_ops(dev);
> @@ -902,7 +906,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
> if (ret < 0)
> goto out_free_cfg;
>
> - ret = ops->set(&req_info, info);
> + ret = ops->set(req_info, info);
> if (ret < 0)
> goto out_ops;
>
> @@ -921,7 +925,9 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
> netdev_unlock_ops(dev);
> rtnl_unlock();
> out_dev:
> - ethnl_parse_header_dev_put(&req_info);
> + ethnl_parse_header_dev_put(req_info);
> +out_free_req:
> + kfree(req_info);
> return ret;
> }
next prev parent reply other threads:[~2025-06-23 12:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 17:19 [PATCH net-next 0/9] net: ethtool: rss: add notifications Jakub Kicinski
2025-06-21 17:19 ` [PATCH net-next 1/9] netlink: specs: add the multicast group name to spec Jakub Kicinski
2025-06-23 11:58 ` Donald Hunter
2025-06-21 17:19 ` [PATCH net-next 2/9] net: ethtool: dynamically allocate full req size req Jakub Kicinski
2025-06-23 12:01 ` Donald Hunter [this message]
2025-06-21 17:19 ` [PATCH net-next 3/9] net: ethtool: call .parse_request for SET handlers Jakub Kicinski
2025-06-21 17:19 ` [PATCH net-next 4/9] net: ethtool: remove the data argument from ethtool_notify() Jakub Kicinski
2025-06-21 17:19 ` [PATCH net-next 5/9] net: ethtool: copy req_info from SET to NTF Jakub Kicinski
2025-06-22 12:00 ` Maxime Chevallier
2025-06-23 14:37 ` Jakub Kicinski
2025-06-23 14:44 ` Maxime Chevallier
2025-06-21 17:19 ` [PATCH net-next 6/9] net: ethtool: rss: add notifications Jakub Kicinski
2025-06-21 21:06 ` kernel test robot
2025-06-21 17:19 ` [PATCH net-next 7/9] doc: ethtool: mark ETHTOOL_GRXFHINDIR as reimplemented Jakub Kicinski
2025-06-21 17:19 ` [PATCH net-next 8/9] selftests: drv-net: import things in lib one by one Jakub Kicinski
2025-06-21 17:19 ` [PATCH net-next 9/9] selftests: drv-net: test RSS Netlink notifications Jakub Kicinski
2025-06-23 17:24 ` [PATCH net-next 0/9] net: ethtool: rss: add notifications Jakub Kicinski
2025-06-23 20:10 ` patchwork-bot+netdevbpf
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=m2a55yekft.fsf@gmail.com \
--to=donald.hunter@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/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).