Skip to content

Commit 950271d

Browse files
wyjwangkuba-moo
authored andcommitted
tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS
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: 90e33d4 ("tun: enable napi_gro_frags() for TUN/TAP driver") Signed-off-by: Yunjian Wang <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Acked-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4614792 commit 950271d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ static struct sk_buff *tun_napi_alloc_frags(struct tun_file *tfile,
13651365
int i;
13661366

13671367
if (it->nr_segs > MAX_SKB_FRAGS + 1)
1368-
return ERR_PTR(-ENOMEM);
1368+
return ERR_PTR(-EMSGSIZE);
13691369

13701370
local_bh_disable();
13711371
skb = napi_get_frags(&tfile->napi);

0 commit comments

Comments
 (0)