• Jason Wang's avatar
    macvtap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS · ece793fc
    Jason Wang authored
    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>
    ece793fc
macvtap.c 31.3 KB