Re: [PATCH net-next v5 08/22] ethtool: support for netlink notifications
From: Jiri Pirko <jiri@resnulli.us>
Date: 2019-03-27 10:43:23
Also in:
lkml
Wed, Mar 27, 2019 at 10:59:50AM CET, mkubecek@suse.cz wrote:
On Wed, Mar 27, 2019 at 10:38:43AM +0100, Jiri Pirko wrote:quoted
Tue, Mar 26, 2019 at 07:17:20PM CET, mkubecek@suse.cz wrote:quoted
On Tue, Mar 26, 2019 at 05:34:00PM +0100, Jiri Pirko wrote:quoted
Mon, Mar 25, 2019 at 06:08:18PM CET, mkubecek@suse.cz wrote:quoted
+void ethtool_notify(struct net_device *dev, struct netlink_ext_ack *extack, + unsigned int cmd, u32 req_mask, const void *data) +{ + if (unlikely(!ethnl_ok))Why do you need this?If genetlink family registration fails, ethtool_notify() can be still called from other code (e.g. the ethtool ioctl interface). In such case, better bail out right away than fail somewhere later (probably after preparing the message which can't be sent anyway).Again, haven't seen this in any other gen netlink implementation. Why do they not need it?Do they have notifications triggered from other code by directly calling a function (i.e. not through e.g. a netdev notifier)?
Okay, got it.
An alternative to a flag would be using a RCU pointer for this function (initialized to null and set once the family is registered) which is what e.g. netfilter is doing with its hooks but that would mean that each external notification would use an indirect call.
It's slow path, I don't think this kind of overhead is of any issue. Sounds good.
quoted
quoted
quoted
quoted
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index b8a6cd3dc3e3..5f2299548915 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h@@ -11,6 +11,8 @@#define ETHNL_SET_ERRMSG(info, msg) \ do { if (info) GENL_SET_ERR_MSG(info, msg); } while (0) +extern u32 ethnl_bcast_seq;Why do you need to have this in header? Second, it is not used by anything. Please don't introduce variables that are not used. Introduce them only in patch where you use it.It's the same as with ethtool_genl_family. I'll make it static as well until it's used in some other file.Not only static. You should remove it as you are not using it in this patch at all.OK Michal