Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 200859
b: refs/heads/master
c: bf98843
h: refs/heads/master
i:
  200857: 13e8d3e
  200855: 11ee90a
v: v3
  • Loading branch information
Ben Hutchings authored and David S. Miller committed Jun 29, 2010
1 parent 84a31f8 commit d6c7937
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: db048b69037e7fa6a7d9e95a1271a50dc08ae233
refs/heads/master: bf988435bd5b53529f4408a8efb1f433f6ddfda9
2 changes: 2 additions & 0 deletions trunk/include/linux/ethtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ struct ethtool_rxnfc {
__u32 flow_type;
/* The rx flow hash value or the rule DB size */
__u64 data;
/* The following fields are not valid and must not be used for
* the ETHTOOL_{G,X}RXFH commands. */
struct ethtool_rx_flow_spec fs;
__u32 rule_cnt;
__u32 rule_locs[0];
Expand Down
36 changes: 27 additions & 9 deletions trunk/net/core/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,31 +318,49 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
}

static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
void __user *useraddr)
u32 cmd, void __user *useraddr)
{
struct ethtool_rxnfc cmd;
struct ethtool_rxnfc info;
size_t info_size = sizeof(info);

if (!dev->ethtool_ops->set_rxnfc)
return -EOPNOTSUPP;

if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
/* struct ethtool_rxnfc was originally defined for
* ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
* members. User-space might still be using that
* definition. */
if (cmd == ETHTOOL_SRXFH)
info_size = (offsetof(struct ethtool_rxnfc, data) +
sizeof(info.data));

if (copy_from_user(&info, useraddr, info_size))
return -EFAULT;

return dev->ethtool_ops->set_rxnfc(dev, &cmd);
return dev->ethtool_ops->set_rxnfc(dev, &info);
}

static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
void __user *useraddr)
u32 cmd, void __user *useraddr)
{
struct ethtool_rxnfc info;
size_t info_size = sizeof(info);
const struct ethtool_ops *ops = dev->ethtool_ops;
int ret;
void *rule_buf = NULL;

if (!ops->get_rxnfc)
return -EOPNOTSUPP;

if (copy_from_user(&info, useraddr, sizeof(info)))
/* struct ethtool_rxnfc was originally defined for
* ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
* members. User-space might still be using that
* definition. */
if (cmd == ETHTOOL_GRXFH)
info_size = (offsetof(struct ethtool_rxnfc, data) +
sizeof(info.data));

if (copy_from_user(&info, useraddr, info_size))
return -EFAULT;

if (info.cmd == ETHTOOL_GRXCLSRLALL) {
Expand All @@ -360,7 +378,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
goto err_out;

ret = -EFAULT;
if (copy_to_user(useraddr, &info, sizeof(info)))
if (copy_to_user(useraddr, &info, info_size))
goto err_out;

if (rule_buf) {
Expand Down Expand Up @@ -1517,12 +1535,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_GRXCLSRLCNT:
case ETHTOOL_GRXCLSRULE:
case ETHTOOL_GRXCLSRLALL:
rc = ethtool_get_rxnfc(dev, useraddr);
rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
break;
case ETHTOOL_SRXFH:
case ETHTOOL_SRXCLSRLDEL:
case ETHTOOL_SRXCLSRLINS:
rc = ethtool_set_rxnfc(dev, useraddr);
rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
break;
case ETHTOOL_GGRO:
rc = ethtool_get_gro(dev, useraddr);
Expand Down

0 comments on commit d6c7937

Please sign in to comment.