Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

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>

authored by

Maxime Chevallier and committed by
Jakub Kicinski
10171b93 b1c803d5

+19 -8
+7 -5
net/ethtool/eeprom.c
··· 150 150 return ret; 151 151 } 152 152 153 - static int eeprom_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb, 153 + static int eeprom_parse_request(struct ethnl_req_info *req_info, 154 + const struct genl_info *info, 155 + struct nlattr **tb, 154 156 struct netlink_ext_ack *extack) 155 157 { 156 158 struct eeprom_req_info *request = MODULE_EEPROM_REQINFO(req_info); 157 159 158 - if (!tb[ETHTOOL_A_MODULE_EEPROM_OFFSET] || 159 - !tb[ETHTOOL_A_MODULE_EEPROM_LENGTH] || 160 - !tb[ETHTOOL_A_MODULE_EEPROM_PAGE] || 161 - !tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS]) 160 + if (GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_MODULE_EEPROM_OFFSET) || 161 + GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_MODULE_EEPROM_LENGTH) || 162 + GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_MODULE_EEPROM_PAGE) || 163 + GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS)) 162 164 return -EINVAL; 163 165 164 166 request->i2c_address = nla_get_u8(tb[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS]);
+2 -1
net/ethtool/netlink.c
··· 462 462 return ret; 463 463 464 464 if (request_ops->parse_request) { 465 - ret = request_ops->parse_request(req_info, tb, info->extack); 465 + ret = request_ops->parse_request(req_info, info, tb, 466 + info->extack); 466 467 if (ret < 0) 467 468 goto err_dev; 468 469 }
+1
net/ethtool/netlink.h
··· 396 396 u8 set_ntf_cmd; 397 397 398 398 int (*parse_request)(struct ethnl_req_info *req_info, 399 + const struct genl_info *info, 399 400 struct nlattr **tb, 400 401 struct netlink_ext_ack *extack); 401 402 int (*prepare_data)(const struct ethnl_req_info *req_info,
+1
net/ethtool/pause.c
··· 28 28 }; 29 29 30 30 static int pause_parse_request(struct ethnl_req_info *req_base, 31 + const struct genl_info *info, 31 32 struct nlattr **tb, 32 33 struct netlink_ext_ack *extack) 33 34 {
+3 -1
net/ethtool/rss.c
··· 66 66 }; 67 67 68 68 static int 69 - rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb, 69 + rss_parse_request(struct ethnl_req_info *req_info, 70 + const struct genl_info *info, 71 + struct nlattr **tb, 70 72 struct netlink_ext_ack *extack) 71 73 { 72 74 struct rss_req_info *request = RSS_REQINFO(req_info);
+1
net/ethtool/stats.c
··· 99 99 }; 100 100 101 101 static int stats_parse_request(struct ethnl_req_info *req_base, 102 + const struct genl_info *info, 102 103 struct nlattr **tb, 103 104 struct netlink_ext_ack *extack) 104 105 {
+1
net/ethtool/strset.c
··· 190 190 }; 191 191 192 192 static int strset_parse_request(struct ethnl_req_info *req_base, 193 + const struct genl_info *info, 193 194 struct nlattr **tb, 194 195 struct netlink_ext_ack *extack) 195 196 {
+3 -1
net/ethtool/tsinfo.c
··· 70 70 } 71 71 72 72 static int 73 - tsinfo_parse_request(struct ethnl_req_info *req_base, struct nlattr **tb, 73 + tsinfo_parse_request(struct ethnl_req_info *req_base, 74 + const struct genl_info *info, 75 + struct nlattr **tb, 74 76 struct netlink_ext_ack *extack) 75 77 { 76 78 struct tsinfo_req_info *req = TSINFO_REQINFO(req_base);