i40e: always return VEB stat strings
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 17 May 2018 08:08:33 +0000 (01:08 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 22 May 2018 15:37:06 +0000 (08:37 -0700)
commit9955d4940e33442b9b2f1f255a63aac21f8ec3c3
tree73b963ac4bee4c45bddc1cc49a60709bddfe39d1
parentbdf2752305af1f8c2c2422ae2b292194cf33f5e9
i40e: always return VEB stat strings

The ethtool API for obtaining device statistics is not intended to allow
runtime changes in the number of statistics reported. It may *appear*
this way, as there is an ability to request the number of stats using
ethtool_get_set_count(). However, it is expected that this must always
return the same value for invocations of the same device.

If we don't satisfy this contract, and allow the number of stats to
change during run time, we could cause invalid memory accesses or report
the stat strings incorrectly. This is because the API for obtaining
stats is to (1) get the size, (2) get the strings and finally (3) get
the stats. Since these are each separate ethtool op commands, it is not
possible to maintain consistency by holding the RTNL lock over the whole
operation. This results in the potential for a race condition to occur
where the size changed between any of the 3 calls.

Avoid this issue by requiring that we always return the same value for
a given device. We can check any values which remain constant for the
life of the device, but must not report different sizes depending on
runtime attributes.

This patch specifically fixes the VEB statistics strings to always be
reported. Other issues will be fixed in future patches.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ethtool.c