]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
i40e: always return all queue stat strings
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 17 May 2018 08:08:34 +0000 (01:08 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 22 May 2018 15:37:06 +0000 (08:37 -0700)
commitb8312365097ca854a03231bd58a284491aaa8ef7
treeff18b87106a817f0a3fa1f7a259f0076371250c9
parent9955d4940e33442b9b2f1f255a63aac21f8ec3c3
i40e: always return all queue 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 queue statistics to always return
every queue even if it's not currently in use.

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