OSDN Git Service

i40e: Fix permission check for VF MAC filters
authorFilip Sadowski <filip.sadowski@intel.com>
Thu, 8 Mar 2018 22:52:07 +0000 (14:52 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 14 Mar 2018 19:23:11 +0000 (12:23 -0700)
commit03ce7b1d23498c97bc530a1296852af0cdd2fe77
tree995ace79b59902bdc0e1446c4194f2e0068c2f94
parent2972b00797588b5cfdd8369612cca8415a4e9e73
i40e: Fix permission check for VF MAC filters

When VF requests adding of MAC filters the checking is done against number
of already present MAC filters not adding them at the same time. It makes
it possible to add a bunch of filters at once possibly exceeding
acceptable limit of I40E_VC_MAX_MAC_ADDR_PER_VF filters.

This happens because when checking vf->num_mac, we do not check how many
filters are being requested at once. Modify the check function to ensure
that it knows how many filters are being requested. This allows the
check to ensure that the total number of filters in a single request
does not cause us to go over the limit.

Additionally, move the check to within the lock to ensure that the
vf->num_mac is checked while holding the lock to maintain consistency.
We could have simply moved the call to i40e_vf_check_permission to
within the loop, but this could cause a request to be non-atomic, and
add some but not all the addresses, while reporting an error code. We
want to avoid this behavior so that users are not confused about which
filters have or have not been added.

Signed-off-by: Filip Sadowski <filip.sadowski@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_virtchnl_pf.c