• Jason Wang's avatar
    macvtap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS · 7d9e6dd8
    Jason Wang authored
    [ Upstream commit ece793fc ]
    
    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 b92946e2
    (macvtap: zerocopy: validate vectors before building skb).
    
    Cc: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    7d9e6dd8
macvtap.c 27.7 KB