Skip to contentSkip to conversation

ethtool_set_features suggestion

DISCUSSION Ben Greear 2 participants 2 messages Jun 24, 2011

Subsystems (2)
lore
Share & tools
lore

Ben Greear

author
#0 lore raw

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

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#1 lore raw
Quoted 14 lines · Ben Greear

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;
Quoted 6 lines

(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.

Signature · 3 lines
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.