Re: [RFC v2 1/1] net: Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool.

Ben Hutchings
2014-03-24T18:55:17Z

[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]

On Mon, 2014-03-24 at 00:57 -0400, Sucheta Chakraborty wrote:
[...]
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
[...]
> + case IFLA_VF_RATE: {
> + struct ifla_vf_rate *ivt;
> + struct ifla_vf_info ivf;
> ivt = nla_data(vf);
> err = -EOPNOTSUPP;
> - if (ops->ndo_set_vf_tx_rate)
> - err = ops->ndo_set_vf_tx_rate(dev, ivt->vf,
> - ivt->rate);
> + if ((ivt->min_tx_rate == -1 ||
> + ivt->max_tx_rate == -1) &&
> + ops->ndo_get_vf_config)
> + err = ops->ndo_get_vf_config(dev, ivt->vf,
> + &ivf);
> + else
> + err = 0;
> + if (err)
> + break;
> + if (ivt->min_tx_rate == -1)
> + ivt->min_tx_rate = ivf.min_tx_rate;
> + if (ivt->max_tx_rate == -1)
> + ivt->max_tx_rate = ivf.max_tx_rate;
[...]

This is modifying the the content of the netlink skb, which I think is
not allowed. I think you need to use local variables for this instead.

Also, this special-casing of -1 isn't documented anywhere. Is it even
necessary? If userland needs to set just one limit, it can read the
existing limits and set both.

Ben.

--
Ben Hutchings
Everything should be made as simple as possible, but not simpler.
- Albert Einstein

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]