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@fb.com,
	daniel@iogearbox.net, netdev@vger.kernel.org,
	eric.dumazet@gmail.com
Cc: qi.z.zhang@intel.com, pavel@fastnetmon.com
Subject: [PATCH bpf 3/4] xsk: always return ENOBUFS from sendmsg if there is no TX queue
Date: Wed, 11 Jul 2018 10:12:51 +0200	[thread overview]
Message-ID: <1531296772-28850-4-git-send-email-magnus.karlsson@intel.com> (raw)
In-Reply-To: <1531296772-28850-1-git-send-email-magnus.karlsson@intel.com>

This patch makes sure ENOBUFS is always returned from sendmsg if there
is no TX queue configured. This was not the case for zero-copy
mode. With this patch this error reporting is consistent between copy
mode and zero-copy mode.

Fixes: ac98d8aab61b ("xsk: wire upp Tx zero-copy functions")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 net/xdp/xsk.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 87567232d0f8..9c784307f7b0 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -218,9 +218,6 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
 	struct sk_buff *skb;
 	int err = 0;
 
-	if (unlikely(!xs->tx))
-		return -ENOBUFS;
-
 	mutex_lock(&xs->mutex);
 
 	while (xskq_peek_desc(xs->tx, &desc)) {
@@ -296,6 +293,8 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
 		return -ENXIO;
 	if (unlikely(!(xs->dev->flags & IFF_UP)))
 		return -ENETDOWN;
+	if (unlikely(!xs->tx))
+		return -ENOBUFS;
 	if (need_wait)
 		return -EOPNOTSUPP;
 
-- 
2.7.4

  parent reply	other threads:[~2018-07-11  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11  8:12 [PATCH bpf 0/4] Consistent sendmsg error reporting in AF_XDP Magnus Karlsson
2018-07-11  8:12 ` [PATCH bpf 1/4] xsk: do not return ENXIO from TX copy mode Magnus Karlsson
2018-07-11  8:12 ` [PATCH bpf 2/4] xsk: do not return EAGAIN from sendmsg when completion queue is full Magnus Karlsson
2018-07-11  8:12 ` Magnus Karlsson [this message]
2018-07-11  8:12 ` [PATCH bpf 4/4] xsk: do not return EMSGSIZE in copy mode for packets larger than MTU Magnus Karlsson
2018-07-11 23:48 ` [PATCH bpf 0/4] Consistent sendmsg error reporting in AF_XDP Alexei Starovoitov
2018-07-13 13:38 ` Daniel Borkmann

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=1531296772-28850-4-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=eric.dumazet@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).