212
static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr)
212
static int ethtool_set_rxnfc(struct net_device *dev, u32 cmd,
213
void __user *useraddr)
214
struct ethtool_rxnfc cmd;
215
struct ethtool_rxnfc info;
216
size_t info_size = sizeof(info);
216
218
if (!dev->ethtool_ops->set_rxnfc)
217
219
return -EOPNOTSUPP;
219
if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
221
/* struct ethtool_rxnfc was originally defined for
222
* ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
223
* members. User-space might still be using that
225
if (cmd == ETHTOOL_SRXFH)
226
info_size = (offsetof(struct ethtool_rxnfc, data) +
229
if (copy_from_user(&info, useraddr, info_size))
222
return dev->ethtool_ops->set_rxnfc(dev, &cmd);
232
return dev->ethtool_ops->set_rxnfc(dev, &info);
225
static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
235
static int ethtool_get_rxnfc(struct net_device *dev, u32 cmd,
236
void __user *useraddr)
227
238
struct ethtool_rxnfc info;
239
size_t info_size = sizeof(info);
228
240
const struct ethtool_ops *ops = dev->ethtool_ops;
230
242
void *rule_buf = NULL;
232
244
if (!ops->get_rxnfc)
233
245
return -EOPNOTSUPP;
235
if (copy_from_user(&info, useraddr, sizeof(info)))
247
/* struct ethtool_rxnfc was originally defined for
248
* ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
249
* members. User-space might still be using that
251
if (cmd == ETHTOOL_GRXFH)
252
info_size = (offsetof(struct ethtool_rxnfc, data) +
255
if (copy_from_user(&info, useraddr, info_size))
238
258
if (info.cmd == ETHTOOL_GRXCLSRLALL) {
239
259
if (info.rule_cnt > 0) {
240
rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
260
rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
1087
1107
case ETHTOOL_GRXCLSRLCNT:
1088
1108
case ETHTOOL_GRXCLSRULE:
1089
1109
case ETHTOOL_GRXCLSRLALL:
1090
rc = ethtool_get_rxnfc(dev, useraddr);
1110
rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1092
1112
case ETHTOOL_SRXFH:
1093
1113
case ETHTOOL_SRXCLSRLDEL:
1094
1114
case ETHTOOL_SRXCLSRLINS:
1095
rc = ethtool_set_rxnfc(dev, useraddr);
1115
rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1097
1117
case ETHTOOL_GGRO:
1098
1118
rc = ethtool_get_gro(dev, useraddr);