diff options
author | Björn Töpel <bjorn.topel@intel.com> | 2018-09-07 10:18:48 +0200 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2018-09-25 13:16:19 -0700 |
commit | 3ab52af58fa481324bb7c839a2187c54c4af912b (patch) | |
tree | 23c7f5927c27ba3bbaabc241bf9b2ddd4d546a17 /drivers/net/ethernet/intel/i40e/i40e_ethtool.c | |
parent | 411dc16ff1775517ec91cdb64be7ee0daca44e22 (diff) | |
download | lwn-3ab52af58fa481324bb7c839a2187c54c4af912b.tar.gz lwn-3ab52af58fa481324bb7c839a2187c54c4af912b.zip |
i40e: disallow changing the number of descriptors when AF_XDP is on
When an AF_XDP UMEM is attached to any of the Rx rings, we disallow a
user to change the number of descriptors via e.g. "ethtool -G IFNAME".
Otherwise, the size of the stash/reuse queue can grow unbounded, which
would result in OOM or leaking userspace buffers.
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_ethtool.c')
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c index 87fe2e60602f..9f8464f80783 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c @@ -5,6 +5,7 @@ #include "i40e.h" #include "i40e_diag.h" +#include "i40e_txrx_common.h" /* ethtool statistics helpers */ @@ -1710,6 +1711,13 @@ static int i40e_set_ringparam(struct net_device *netdev, (new_rx_count == vsi->rx_rings[0]->count)) return 0; + /* If there is a AF_XDP UMEM attached to any of Rx rings, + * disallow changing the number of descriptors -- regardless + * if the netdev is running or not. + */ + if (i40e_xsk_any_rx_ring_enabled(vsi)) + return -EBUSY; + while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) { timeout--; if (!timeout) |