All of lore.kernel.org
 help / color / mirror / Atom feed
From: wangyunjian <wangyunjian@huawei.com>
To: <netdev@vger.kernel.org>, <mst@redhat.com>, <jasowang@redhat.com>,
	<willemdebruijn.kernel@gmail.com>
Cc: <virtualization@lists.linux-foundation.org>,
	<jerry.lilijun@huawei.com>, <chenchanghu@huawei.com>,
	<xudingke@huawei.com>, <brian.huangbin@huawei.com>,
	Yunjian Wang <wangyunjian@huawei.com>
Subject: [PATCH net v2] tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS
Date: Fri, 25 Dec 2020 10:52:16 +0800	[thread overview]
Message-ID: <1608864736-24332-1-git-send-email-wangyunjian@huawei.com> (raw)

From: Yunjian Wang <wangyunjian@huawei.com>

Currently the tun_napi_alloc_frags() function returns -ENOMEM when the
number of iovs exceeds MAX_SKB_FRAGS + 1. However this is inappropriate,
we should use -EMSGSIZE instead of -ENOMEM.

The following distinctions are matters:
1. the caller need to drop the bad packet when -EMSGSIZE is returned,
   which means meeting a persistent failure.
2. the caller can try again when -ENOMEM is returned, which means
   meeting a transient failure.

Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Willem de Bruijn <willemb@google.com>
---
v2:
  * update commit log suggested by Willem de Bruijn
---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 2dc1988a8973..15c6dd7fb04c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1365,7 +1365,7 @@ static struct sk_buff *tun_napi_alloc_frags(struct tun_file *tfile,
 	int i;
 
 	if (it->nr_segs > MAX_SKB_FRAGS + 1)
-		return ERR_PTR(-ENOMEM);
+		return ERR_PTR(-EMSGSIZE);
 
 	local_bh_disable();
 	skb = napi_get_frags(&tfile->napi);
-- 
2.23.0


             reply	other threads:[~2020-12-25  2:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-25  2:52 wangyunjian [this message]
2020-12-25  6:18 ` [PATCH net v2] tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS Jason Wang
2020-12-25  6:18   ` Jason Wang
2020-12-27  9:40 ` Michael S. Tsirkin
2020-12-27  9:40   ` Michael S. Tsirkin
2020-12-28 21:43 ` Jakub Kicinski

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=1608864736-24332-1-git-send-email-wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=brian.huangbin@huawei.com \
    --cc=chenchanghu@huawei.com \
    --cc=jasowang@redhat.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xudingke@huawei.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 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.