net: ethtool: pass genl_info to the ethnl parse_request operation
Subsystems (3)
PATCH 1/1 net: ethtool: pass genl_info to the ethnl parse_request operation
The .parse_request() ethnl operation extracts the relevant attributes from the netlink request to populate the private req_info.
By passing genl_info as a parameter to this callback, we can use the GENL_REQ_ATTR_CHECK() macro to check for missing mandatory parameters.
This macro has the advantage of returning a better error explanation through the netlink_ext_ack struct.
Convert the eeprom ethnl code to this macro, as it's the only command yet that has mandatory request parameters.
--- net/ethtool/eeprom.c | 12 +++++++----- net/ethtool/netlink.c | 3 ++- net/ethtool/netlink.h | 1 + net/ethtool/pause.c | 1 + net/ethtool/rss.c | 4 +++- net/ethtool/stats.c | 1 + net/ethtool/strset.c | 1 + net/ethtool/tsinfo.c | 4 +++- 8 files changed, 19 insertions(+), 8 deletions(-)
net/ethtool/eeprom.c +7 -5
@@ -150,15 +150,17 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,return ret; } -static int eeprom_parse_request (struct ethnl_req_info *req_info,struct nlattr **tb, +static int eeprom_parse_request (struct ethnl_req_info *req_info, +const struct genl_info *info, +struct nlattr **tb,struct netlink_ext_ack *extack) {struct eeprom_req_info *request =MODULE_EEPROM_REQINFO (req_info); -if (!tb[ETHTOOL_A_MODULE_EEPROM_OFFSET ] || - !tb[ETHTOOL_A_MODULE_EEPROM_LENGTH ] || - !tb[ETHTOOL_A_MODULE_EEPROM_PAGE ] || - !tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS ]) +if (GENL_REQ_ATTR_CHECK (info,ETHTOOL_A_MODULE_EEPROM_OFFSET ) || +GENL_REQ_ATTR_CHECK (info,ETHTOOL_A_MODULE_EEPROM_LENGTH ) || +GENL_REQ_ATTR_CHECK (info,ETHTOOL_A_MODULE_EEPROM_PAGE ) || +GENL_REQ_ATTR_CHECK (info,ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS ))return -EINVAL ; request->i2c_address =nla_get_u8 (tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS ]);
net/ethtool/netlink.c +2 -1
@@ -462,7 +462,8 @@ static int ethnl_default_parse(struct ethnl_req_info *req_info,return ret;if (request_ops->parse_request) { - ret = request_ops->parse_request (req_info, tb, info->extack); + ret = request_ops->parse_request (req_info, info, tb, + info->extack);if (ret <0 ) goto err_dev; }
net/ethtool/netlink.h +1 -0
@@ -396,6 +396,7 @@ struct ethnl_request_ops {u8 set_ntf_cmd;int (*parse_request)(struct ethnl_req_info *req_info, +const struct genl_info *info,struct nlattr **tb,struct netlink_ext_ack *extack); int (*prepare_data)(const struct ethnl_req_info *req_info,
net/ethtool/pause.c +1 -0
@@ -28,6 +28,7 @@ const struct nla_policy ethnl_pause_get_policy[] = { };static int pause_parse_request (struct ethnl_req_info *req_base, +const struct genl_info *info,struct nlattr **tb,struct netlink_ext_ack *extack) {
net/ethtool/rss.c +3 -1
@@ -66,7 +66,9 @@ const struct nla_policy ethnl_rss_get_policy[] = { };static int -rss_parse_request (struct ethnl_req_info *req_info,struct nlattr **tb, +rss_parse_request (struct ethnl_req_info *req_info, +const struct genl_info *info, +struct nlattr **tb,struct netlink_ext_ack *extack) {struct rss_req_info *request =RSS_REQINFO (req_info);
net/ethtool/stats.c +1 -0
@@ -99,6 +99,7 @@ const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1] = { };static int stats_parse_request (struct ethnl_req_info *req_base, +const struct genl_info *info,struct nlattr **tb,struct netlink_ext_ack *extack) {
net/ethtool/strset.c +1 -0
@@ -190,6 +190,7 @@ static const struct nla_policy strset_stringsets_policy[] = { };static int strset_parse_request (struct ethnl_req_info *req_base, +const struct genl_info *info,struct nlattr **tb,struct netlink_ext_ack *extack) {
net/ethtool/tsinfo.c +3 -1
@@ -70,7 +70,9 @@ int ts_parse_hwtst_provider(const struct nlattr *nest, }static int -tsinfo_parse_request (struct ethnl_req_info *req_base,struct nlattr **tb, +tsinfo_parse_request (struct ethnl_req_info *req_base, +const struct genl_info *info, +struct nlattr **tb,struct netlink_ext_ack *extack) {struct tsinfo_req_info *req =TSINFO_REQINFO (req_base);
Signature · 1 line
2.49.0
Quoted 7 lines · On Mon, 23 Mar 2026 10:58:32 +0100 Maxime Chevallier wrote:
The .parse_request() ethnl operation extracts the relevant attributes from the netlink request to populate the private
req_info.By passing
genl_infoas a parameter to this callback, we can use theGENL_REQ_ATTR_CHECK()macro to check for missing mandatory parameters.
Quoted 5 lines
This macro has the advantage of returning a better error explanation through the
netlink_ext_ackstruct.Convert the eeprom ethnl code to this macro, as it's the only command yet that has mandatory request parameters.
Thanks1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 23 Mar 2026 10:58:32 +0100 you wrote:
The .parse_request() ethnl operation extracts the relevant attributes from the netlink request to populate the private
req_info.By passing
genl_infoas a parameter to this callback, we can use theGENL_REQ_ATTR_CHECK()macro to check for missing mandatory parameters.[...]
Here is the summary with links:
- [net-next] net: ethtool: pass genl_info to the ethnl parse_request operation
https://git.kernel.org/netdev/net-next/c/10171b938330
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html