netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Karlsson <magnus.karlsson@intel.com>
To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org,
	daniel@iogearbox.net, netdev@vger.kernel.org
Subject: [PATCH bpf-next 0/2] xsk: fix bug when trying to use both copy and zero-copy mode
Date: Tue, 18 Sep 2018 12:12:16 +0200	[thread overview]
Message-ID: <1537265538-5882-1-git-send-email-magnus.karlsson@intel.com> (raw)

Previously, the xsk code did not record which umem was bound to a
specific queue id. This was not required if all drivers were zero-copy
enabled as this had to be recorded in the driver anyway. So if a user
tried to bind two umems to the same queue, the driver would say
no. But if copy-mode was first enabled and then zero-copy mode (or the
reverse order), we mistakenly enabled both of them on the same umem
leading to buggy behavior. The main culprit for this is that we did
not store the association of umem to queue id in the copy case and
only relied on the driver reporting this. As this relation was not
stored in the driver for copy mode (it does not rely on the AF_XDP
NDOs), this obviously could not work.

This patch fixes the problem by always recording the umem to queue id
relationship in the netdev_queue and netdev_rx_queue structs. This
way we always know what kind of umem has been bound to a queue id and
can act appropriately at bind time.

Patch 1: Introduces a umem reference in the netdev_rx_queue and
         netdev_queue structs.
Patch 2: Records which queue_id is bound to which umem and make sure
         that you cannot bind two different umems to the same queue_id.

I based this patch set on bpf-next commit 70e88c758a6b
("selftests/bpf: fix bpf_flow.c build")

Thanks: Magnus

Magnus Karlsson (2):
  net: add umem reference in netdev{_rx}_queue
  xsk: fix bug when trying to use both copy and zero-copy on one queue
    id

 include/linux/netdevice.h |  6 ++++
 net/xdp/xdp_umem.c        | 87 ++++++++++++++++++++++++++++++++++++++---------
 net/xdp/xdp_umem.h        |  2 +-
 3 files changed, 77 insertions(+), 18 deletions(-)

             reply	other threads:[~2018-09-18 15:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 10:12 Magnus Karlsson [this message]
2018-09-18 10:12 ` [PATCH bpf-next 1/2] net: add umem reference in netdev{_rx}_queue Magnus Karlsson
2018-09-18 10:12 ` [PATCH bpf-next 2/2] xsk: fix bug when trying to use both copy and zero-copy on one queue id Magnus Karlsson
2018-09-18 17:22   ` Y Song
2018-09-19  1:55     ` Jakub Kicinski
2018-09-19  7:18       ` Magnus Karlsson
2018-09-20  9:17         ` Magnus Karlsson
2018-09-20 14:41           ` Jakub Kicinski
2018-09-24  8:37             ` Magnus Karlsson
2018-09-19  7:14     ` Magnus Karlsson
2018-09-20  4:47       ` Y Song

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=1537265538-5882-1-git-send-email-magnus.karlsson@intel.com \
    --to=magnus.karlsson@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=daniel@iogearbox.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).