All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
	alexandr.lobakin@intel.com,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Subject: [PATCH bpf-next v4 6/8] ice: xsk: avoid potential dead AF_XDP Tx processing
Date: Mon, 24 Jan 2022 17:55:45 +0100	[thread overview]
Message-ID: <20220124165547.74412-7-maciej.fijalkowski@intel.com> (raw)
In-Reply-To: <20220124165547.74412-1-maciej.fijalkowski@intel.com>

Commit 9610bd988df9 ("ice: optimize XDP_TX workloads") introduced
@next_dd and @next_rs to ice_tx_ring struct. Currently, their state is
not restored in ice_clean_tx_ring(), which was not causing any troubles
as the XDP rings are gone after we're done with XDP prog on interface.

For upcoming usage of mentioned fields in AF_XDP, this might expose us
to a potential dead Tx side. Scenario would look like following (based
on xdpsock):

- two xdpsock instances are spawned in Tx mode
- one of them is killed
- XDP prog is kept on interface due to the other xdpsock still running
  * this means that XDP rings stayed in place
- xdpsock is launched again on same queue id that was terminated on
- @next_dd and @next_rs setting is bogus, therefore transmit side is
  broken

To protect us from the above, restore the initial @next_rs and @next_dd
values when cleaning the Tx ring.

Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index e661d0e45b9b..73f60493209d 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -173,6 +173,8 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
 
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
+	tx_ring->next_dd = ICE_RING_QUARTER(tx_ring) - 1;
+	tx_ring->next_rs = ICE_RING_QUARTER(tx_ring) - 1;
 
 	if (!tx_ring->netdev)
 		return;
-- 
2.33.1


  parent reply	other threads:[~2022-01-24 16:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 16:55 [PATCH v4 bpf-next 0/8] xsk: Intel driver improvements Maciej Fijalkowski
2022-01-24 16:55 ` [PATCH bpf-next v4 1/8] ice: remove likely for napi_complete_done Maciej Fijalkowski
2022-01-25  8:59   ` Magnus Karlsson
2022-01-24 16:55 ` [PATCH bpf-next v4 2/8] ice: xsk: force rings to be sized to power of 2 Maciej Fijalkowski
2022-01-25  9:06   ` Magnus Karlsson
2022-01-25 11:23   ` Alexander Lobakin
2022-01-25 11:28     ` Maciej Fijalkowski
2022-01-25 11:42       ` Alexander Lobakin
2022-01-25 11:49         ` Maciej Fijalkowski
2022-01-25 12:00           ` Alexander Lobakin
2022-01-25 15:01             ` Maciej Fijalkowski
2022-01-25 15:24               ` Alexander Lobakin
2022-01-24 16:55 ` [PATCH bpf-next v4 3/8] ice: xsk: handle SW XDP ring wrap and bump tail more often Maciej Fijalkowski
2022-01-24 16:55 ` [PATCH bpf-next v4 4/8] ice: make Tx threshold dependent on ring length Maciej Fijalkowski
2022-01-25  9:09   ` Magnus Karlsson
2022-01-24 16:55 ` [PATCH bpf-next v4 5/8] i40e: xsk: move tmp desc array from driver to pool Maciej Fijalkowski
2022-01-24 16:55 ` Maciej Fijalkowski [this message]
2022-01-24 16:55 ` [PATCH bpf-next v4 7/8] ice: xsk: improve AF_XDP ZC Tx and use batching API Maciej Fijalkowski
2022-01-25  9:32   ` Magnus Karlsson
2022-01-25 11:23     ` Maciej Fijalkowski
2022-01-24 16:55 ` [PATCH bpf-next v4 8/8] ice: xsk: borrow xdp_tx_active logic from i40e Maciej Fijalkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220124165547.74412-7-maciej.fijalkowski@intel.com \
    --to=maciej.fijalkowski@intel.com \
    --cc=alexandr.lobakin@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.