[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190703141614.GL20101@unicorn.suse.cz>
Date: Wed, 3 Jul 2019 16:16:14 +0200
From: Michal Kubecek <mkubecek@...e.cz>
To: netdev@...r.kernel.org
Cc: Jiri Pirko <jiri@...nulli.us>, David Miller <davem@...emloft.net>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
John Linville <linville@...driver.com>,
Stephen Hemminger <stephen@...workplumber.org>,
Johannes Berg <johannes@...solutions.net>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v6 07/15] ethtool: support for netlink
notifications
On Wed, Jul 03, 2019 at 03:33:52PM +0200, Jiri Pirko wrote:
> >+/* notifications */
> >+
> >+typedef void (*ethnl_notify_handler_t)(struct net_device *dev,
> >+ struct netlink_ext_ack *extack,
> >+ unsigned int cmd, u32 req_mask,
> >+ const void *data);
> >+
> >+static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
> >+};
> >+
> >+void ethtool_notify(struct net_device *dev, struct netlink_ext_ack *extack,
> >+ unsigned int cmd, u32 req_mask, const void *data)
>
> What's "req_mask" ?
It's infomask to interpret the same way as if it came from request
header (the notification triggered by a SET request or its ioctl
equivalent uses the same format as corresponding GET_REPLY message and
is created by the same code). But it could be called infomask, I have no
strong opinion about that.
> >+{
> >+ if (unlikely(!ethnl_ok))
> >+ return;
> >+ ASSERT_RTNL();
> >+
> >+ if (likely(cmd < ARRAY_SIZE(ethnl_notify_handlers) &&
> >+ ethnl_notify_handlers[cmd]))
>
> How it could be null?
Notification message types share the enum with other kernel messages:
/* message types - kernel to userspace */
enum {
ETHTOOL_MSG_KERNEL_NONE,
ETHTOOL_MSG_STRSET_GET_REPLY,
ETHTOOL_MSG_SETTINGS_GET_REPLY,
ETHTOOL_MSG_SETTINGS_NTF,
ETHTOOL_MSG_SETTINGS_SET_REPLY,
ETHTOOL_MSG_INFO_GET_REPLY,
ETHTOOL_MSG_PARAMS_GET_REPLY,
ETHTOOL_MSG_PARAMS_NTF,
ETHTOOL_MSG_NWAYRST_NTF,
ETHTOOL_MSG_PHYSID_NTF,
ETHTOOL_MSG_RESET_NTF,
ETHTOOL_MSG_RESET_ACT_REPLY,
ETHTOOL_MSG_RXFLOW_GET_REPLY,
ETHTOOL_MSG_RXFLOW_NTF,
ETHTOOL_MSG_RXFLOW_SET_REPLY,
/* add new constants above here */
__ETHTOOL_MSG_KERNEL_CNT,
ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1)
};
Only entries for *_NTF types are non-null in ethnl_notify_handlers[]:
static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
[ETHTOOL_MSG_SETTINGS_NTF] = ethnl_std_notify,
[ETHTOOL_MSG_PARAMS_NTF] = ethnl_std_notify,
[ETHTOOL_MSG_NWAYRST_NTF] = ethnl_nwayrst_notify,
[ETHTOOL_MSG_PHYSID_NTF] = ethnl_physid_notify,
[ETHTOOL_MSG_RESET_NTF] = ethnl_reset_notify,
[ETHTOOL_MSG_RXFLOW_NTF] = ethnl_rxflow_notify,
};
If the check above fails, it means that kernel code tried to send
a notification with type which does not exist or is not a notification,
i.e. a bug in kernel; that's why the WARN_ONCE.
Michal
> >+ ethnl_notify_handlers[cmd](dev, extack, cmd, req_mask, data);
> >+ else
> >+ WARN_ONCE(1, "notification %u not implemented (dev=%s, req_mask=0x%x)\n",
> >+ cmd, netdev_name(dev), req_mask);
> >+}
> >+EXPORT_SYMBOL(ethtool_notify);
Powered by blists - more mailing lists