]> git.baikalelectronics.ru Git - kernel.git/commit
macvtap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS
authorJason Wang <jasowang@redhat.com>
Thu, 18 Jul 2013 02:55:16 +0000 (10:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Jul 2013 20:04:25 +0000 (13:04 -0700)
commitc82249917b28b3873435145e8536b9abc6f86ed7
tree82348926544697293154d9870ce166c06fb6919f
parent40571dceae8b604e52849150a9372a4c10a60aec
macvtap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS

We try to linearize part of the skb when the number of iov is greater than
MAX_SKB_FRAGS. This is not enough since each single vector may occupy more than
one pages, so zerocopy_sg_fromiovec() may still fail and may break the guest
network.

Solve this problem by calculate the pages needed for iov before trying to do
zerocopy and switch to use copy instead of zerocopy if it needs more than
MAX_SKB_FRAGS.

This is done through introducing a new helper to count the pages for iov, and
call uarg->callback() manually when switching from zerocopy to copy to notify
vhost.

We can do further optimization on top.

This bug were introduced from 7ce6152b7e1fa9c7b6a78d5d9df5e0d540e3e134
(macvtap: zerocopy: validate vectors before building skb).

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvtap.c