On 02/04/2016 01:21 PM, Michael S. Tsirkin wrote:
> On Wed, Feb 03, 2016 at 04:04:37AM +0100, Nikolay Aleksandrov wrote:
>> From: Nikolay Aleksandrov <niko...@cumulusnetworks.com>
[snip]
>>  struct padded_vnet_hdr {
>> @@ -1376,6 +1380,58 @@ static void virtnet_get_channels(struct net_device 
>> *dev,
>>      channels->other_count = 0;
>>  }
>>  
>> +/* Check if the user is trying to change anything besides speed/duplex */
>> +static bool virtnet_validate_ethtool_cmd(const struct ethtool_cmd *cmd)
>> +{
>> +    struct ethtool_cmd diff1 = *cmd;
>> +    struct ethtool_cmd diff2 = {};
>> +
>> +    /* advertising and cmd are usually set, ignore port because we set it */
> 
> We set it where?
If you're asking about advertising - ethtool sets it automatically when the
user tries to set both speed and duplex together.

> Instead of this, should not we set diff2.port to PORT_OTHER?
> 
Yes, that will validate it too.

>> +    ethtool_cmd_speed_set(&diff1, 0);
>> +    diff1.advertising = 0;
>> +    diff1.duplex = 0;
>> +    diff1.port = 0;
>> +    diff1.cmd = 0;
>> +
>> +    return !memcmp(&diff1, &diff2, sizeof(diff1));
>> +}
>> +
[snip]

Reply via email to