Skip to content

Commit 3073947

Browse files
committed
net: ethtool: copy req_info from SET to NTF
Copy information parsed for SET with .req_parse to NTF handling and therefore the GET-equivalent that it ends up executing. This way if the SET was on a sub-object (like RSS context) the notification will also be appropriately scoped. Also copy the phy_index, Maxime suggests this will help PLCA commands generate accurate notifications as well. Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/20250623231720.3124717-6-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f9dc3e5 commit 3073947

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

net/ethtool/netlink.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
911911
swap(dev->cfg, dev->cfg_pending);
912912
if (!ret)
913913
goto out_ops;
914-
ethtool_notify(dev, ops->set_ntf_cmd);
914+
ethnl_notify(dev, ops->set_ntf_cmd, req_info);
915915

916916
ret = 0;
917917
out_ops:
@@ -950,7 +950,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
950950

951951
/* default notification handler */
952952
static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
953-
const void *data)
953+
const struct ethnl_req_info *orig_req_info)
954954
{
955955
struct ethnl_reply_data *reply_data;
956956
const struct ethnl_request_ops *ops;
@@ -979,6 +979,11 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
979979

980980
req_info->dev = dev;
981981
req_info->flags |= ETHTOOL_FLAG_COMPACT_BITSETS;
982+
if (orig_req_info) {
983+
req_info->phy_index = orig_req_info->phy_index;
984+
memcpy(&req_info[1], &orig_req_info[1],
985+
ops->req_info_size - sizeof(*req_info));
986+
}
982987

983988
netdev_ops_assert_locked(dev);
984989

@@ -1029,7 +1034,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
10291034
/* notifications */
10301035

10311036
typedef void (*ethnl_notify_handler_t)(struct net_device *dev, unsigned int cmd,
1032-
const void *data);
1037+
const struct ethnl_req_info *req_info);
10331038

10341039
static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
10351040
[ETHTOOL_MSG_LINKINFO_NTF] = ethnl_default_notify,
@@ -1049,15 +1054,16 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
10491054
[ETHTOOL_MSG_MM_NTF] = ethnl_default_notify,
10501055
};
10511056

1052-
void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data)
1057+
void ethnl_notify(struct net_device *dev, unsigned int cmd,
1058+
const struct ethnl_req_info *req_info)
10531059
{
10541060
if (unlikely(!ethnl_ok))
10551061
return;
10561062
ASSERT_RTNL();
10571063

10581064
if (likely(cmd < ARRAY_SIZE(ethnl_notify_handlers) &&
10591065
ethnl_notify_handlers[cmd]))
1060-
ethnl_notify_handlers[cmd](dev, cmd, data);
1066+
ethnl_notify_handlers[cmd](dev, cmd, req_info);
10611067
else
10621068
WARN_ONCE(1, "notification %u not implemented (dev=%s)\n",
10631069
cmd, netdev_name(dev));

net/ethtool/netlink.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ void *ethnl_dump_put(struct sk_buff *skb, struct netlink_callback *cb, u8 cmd);
2323
void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
2424
void *ethnl_unicast_put(struct sk_buff *skb, u32 portid, u32 seq, u8 cmd);
2525
int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
26-
void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data);
26+
void ethnl_notify(struct net_device *dev, unsigned int cmd,
27+
const struct ethnl_req_info *req_info);
2728

2829
/**
2930
* ethnl_strz_size() - calculate attribute length for fixed size string
@@ -338,6 +339,8 @@ int ethnl_sock_priv_set(struct sk_buff *skb, struct net_device *dev, u32 portid,
338339
* header is already filled on entry, the rest up to @repdata_offset
339340
* is zero initialized. This callback should only modify type specific
340341
* request info by parsed attributes from request message.
342+
* Called for both GET and SET. Information parsed for SET will
343+
* be conveyed to the req_info used during NTF generation.
341344
* @prepare_data:
342345
* Retrieve and prepare data needed to compose a reply message. Calls to
343346
* ethtool_ops handlers are limited to this callback. Common reply data

0 commit comments

Comments
 (0)