i40e: fix XDP_REDIRECT/XDP xmit ring cleanup race
authorBjörn Töpel <bjorn.topel@intel.com>
Thu, 14 Feb 2019 13:03:02 +0000 (14:03 +0100)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 21 Feb 2019 19:07:49 +0000 (11:07 -0800)
commit59eb2a884f5380011179acc4662fc2cc2d850454
treee2d1a2c7fd0d379dfe6bf09a44e1ab3e7e1f648e
parent4a9b32f30f805ca596d76605903a48eab58e0b88
i40e: fix XDP_REDIRECT/XDP xmit ring cleanup race

When the driver clears the XDP xmit ring due to re-configuration or
teardown, in-progress ndo_xdp_xmit must be taken into consideration.

The ndo_xdp_xmit function is typically called from a NAPI context that
the driver does not control. Therefore, we must be careful not to
clear the XDP ring, while the call is on-going. This patch adds a
synchronize_rcu() to wait for napi(s) (preempt-disable regions and
softirqs), prior clearing the queue. Further, the __I40E_CONFIG_BUSY
flag is checked in the ndo_xdp_xmit implementation to avoid touching
the XDP xmit queue during re-configuration.

Fixes: d9314c474d4f ("i40e: add support for XDP_REDIRECT")
Fixes: 123cecd427b6 ("i40e: added queue pair disable/enable functions")
Reported-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c