Netdev List
 help / color / mirror / Atom feed
From: Magnus Karlsson <magnus.karlsson@intel.com>
To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@fb.com,
	daniel@iogearbox.net, netdev@vger.kernel.org
Cc: qi.z.zhang@intel.com, pavel@fastnetmon.com
Subject: [PATCH bpf 2/4] xsk: frame could be completed more than once in SKB path
Date: Wed, 27 Jun 2018 16:02:14 +0200	[thread overview]
Message-ID: <1530108136-4984-3-git-send-email-magnus.karlsson@intel.com> (raw)
In-Reply-To: <1530108136-4984-1-git-send-email-magnus.karlsson@intel.com>

Fixed a bug in which a frame could be completed more than once
when an error was returned from dev_direct_xmit(). The code
erroneously retried sending the message leading to multiple
calls to the SKB destructor and therefore multiple completions
of the same buffer to user space.

The error code in this case has been changed from EAGAIN to EBUSY
in order to tell user space that the sending of the packet failed
and the buffer has been return to user space through the completion
queue.

Fixes: 35fcde7f8deb ("xsk: support for Tx")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Reported-by: Pavel Odintsov <pavel@fastnetmon.com>
---
 net/xdp/xsk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 3b3410ada097..d482f727f4c2 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -268,15 +268,15 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
 		skb->destructor = xsk_destruct_skb;
 
 		err = dev_direct_xmit(skb, xs->queue_id);
+		xskq_discard_desc(xs->tx);
 		/* Ignore NET_XMIT_CN as packet might have been sent */
 		if (err == NET_XMIT_DROP || err == NETDEV_TX_BUSY) {
-			err = -EAGAIN;
-			/* SKB consumed by dev_direct_xmit() */
+			/* SKB completed but not sent */
+			err = -EBUSY;
 			goto out;
 		}
 
 		sent_frame = true;
-		xskq_discard_desc(xs->tx);
 	}
 
 out:
-- 
2.7.4

  parent reply	other threads:[~2018-06-27 14:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 14:02 [PATCH bpf 0/4] Bug fixes to the SKB TX path of AF_XDP Magnus Karlsson
2018-06-27 14:02 ` [PATCH bpf 1/4] xsk: fix potential lost completion message in SKB path Magnus Karlsson
2018-06-28 17:10   ` Song Liu
2018-06-27 14:02 ` Magnus Karlsson [this message]
2018-06-27 18:19   ` [PATCH bpf 2/4] xsk: frame could be completed more than once " Song Liu
2018-06-27 14:02 ` [PATCH bpf 3/4] samples/bpf: deal with EBUSY return code from sendmsg in xdpsock sample Magnus Karlsson
2018-06-27 18:21   ` Song Liu
2018-06-27 14:02 ` [PATCH bpf 4/4] xsk: fix potential race in SKB TX completion code Magnus Karlsson
2018-06-27 15:55   ` Eric Dumazet
2018-06-27 21:00     ` Daniel Borkmann
2018-06-28  8:31     ` Magnus Karlsson

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=1530108136-4984-3-git-send-email-magnus.karlsson@intel.com \
    --to=magnus.karlsson@intel.com \
    --cc=ast@fb.com \
    --cc=bjorn.topel@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@fastnetmon.com \
    --cc=qi.z.zhang@intel.com \
    /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