lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190215085315.GL25518@unicorn.suse.cz>
Date:   Fri, 15 Feb 2019 09:53:15 +0100
From:   Michal Kubecek <mkubecek@...e.cz>
To:     netdev@...r.kernel.org
Cc:     Jakub Kicinski <jakub.kicinski@...ronome.com>, davem@...emloft.net,
        jiri@...nulli.us, oss-drivers@...ronome.com, andrew@...n.ch
Subject: Re: [PATCH net-next 2/3] ethtool: add compat for flash update

On Thu, Feb 14, 2019 at 01:40:45PM -0800, Jakub Kicinski wrote:
> If driver does not support ethtool flash update operation
> call into devlink.
> 
> Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
> ---
...
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index bd507e13bb7b..d169b5426d3d 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -6435,6 +6435,36 @@ void devlink_compat_running_version(struct net_device *dev,
>  	mutex_unlock(&devlink_mutex);
>  }
>  
> +int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
> +{
> +	struct devlink_port *devlink_port;
> +	struct devlink *devlink;
> +
> +	mutex_lock(&devlink_mutex);
> +	list_for_each_entry(devlink, &devlink_list, list) {
> +		mutex_lock(&devlink->lock);
> +		list_for_each_entry(devlink_port, &devlink->port_list, list) {
> +			int ret = -EOPNOTSUPP;
> +
> +			if (devlink_port->type != DEVLINK_PORT_TYPE_ETH ||
> +			    devlink_port->type_dev != dev)
> +				continue;
> +
> +			mutex_unlock(&devlink_mutex);
> +			if (devlink->ops->flash_update)
> +				ret = devlink->ops->flash_update(devlink,
> +								 file_name,
> +								 NULL, NULL);
> +			mutex_unlock(&devlink->lock);
> +			return ret;
> +		}
> +		mutex_unlock(&devlink->lock);
> +	}
> +	mutex_unlock(&devlink_mutex);
> +
> +	return -EOPNOTSUPP;
> +}
> +
>  static int __init devlink_module_init(void)
>  {
>  	return genl_register_family(&devlink_nl_family);

We already have similar lookup in devlink_compat_running_version() (the
only difference seems to be that we keep holding devlink_mutex until the
end there) and it's likely the net_device -> devlink lookup will be
needed in more places in the future. How about having a helper for it?

I also wonder how does the lookup scale. But I don't have clear idea
how long the lists can become in real life and the ethtool operations
are not really time critical.

Michal Kubecek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ