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.
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260323095833.136266-1-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
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]);
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;
}
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,
};
static int pause_parse_request(struct ethnl_req_info *req_base,
+ const struct genl_info *info,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
};
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);
};
static int stats_parse_request(struct ethnl_req_info *req_base,
+ const struct genl_info *info,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
};
static int strset_parse_request(struct ethnl_req_info *req_base,
+ const struct genl_info *info,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
}
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);