netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ethtool_set_features suggestion
@ 2011-06-24 18:20 Ben Greear
  2011-06-24 18:40 ` Ben Hutchings
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Greear @ 2011-06-24 18:20 UTC (permalink / raw)
  To: netdev

static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
{
	struct ethtool_sfeatures cmd;
	struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
	netdev_features_t wanted = 0, valid = 0;
	int i, ret = 0;

	if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
		return -EFAULT;
	useraddr += sizeof(cmd);

	if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
		return -EINVAL;

(This is from net-next, with Miroslaw's patches applied)

I was thinking that we should deal with whatever size is passed in.
That way, if we ever expand the kernel
feature-words size, an old user-space ethtool app would
still function OK.

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ethtool_set_features suggestion
  2011-06-24 18:20 ethtool_set_features suggestion Ben Greear
@ 2011-06-24 18:40 ` Ben Hutchings
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Hutchings @ 2011-06-24 18:40 UTC (permalink / raw)
  To: Ben Greear; +Cc: netdev

On Fri, 2011-06-24 at 11:20 -0700, Ben Greear wrote:
> static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
> {
> 	struct ethtool_sfeatures cmd;
> 	struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
> 	netdev_features_t wanted = 0, valid = 0;
> 	int i, ret = 0;
> 
> 	if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
> 		return -EFAULT;
> 	useraddr += sizeof(cmd);
> 
> 	if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
> 		return -EINVAL;
> 
> (This is from net-next, with Miroslaw's patches applied)
> 
> I was thinking that we should deal with whatever size is passed in.
> That way, if we ever expand the kernel
> feature-words size, an old user-space ethtool app would
> still function OK.

Userland should find out the correct size from ETHTOOL_GFEATURES.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-24 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 18:20 ethtool_set_features suggestion Ben Greear
2011-06-24 18:40 ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).