• H
    macvtap: Limit packet queue length · 8a35747a
    Herbert Xu 提交于
    Mark Wagner reported OOM symptoms when sending UDP traffic over
    a macvtap link to a kvm receiver.
    
    This appears to be caused by the fact that macvtap packet queues
    are unlimited in length.  This means that if the receiver can't
    keep up with the rate of flow, then we will hit OOM. Of course
    it gets worse if the OOM killer then decides to kill the receiver.
    
    This patch imposes a cap on the packet queue length, in the same
    way as the tuntap driver, using the device TX queue length.
    
    Please note that macvtap currently has no way of giving congestion
    notification, that means the software device TX queue cannot be
    used and packets will always be dropped once the macvtap driver
    queue fills up.
    
    This shouldn't be a great problem for the scenario where macvtap
    is used to feed a kvm receiver, as the traffic is most likely
    external in origin so congestion notification can't be applied
    anyway.
    
    Of course, if anybody decides to complain about guest-to-guest
    UDP packet loss down the track, then we may have to revisit this.
    
    Incidentally, this patch also fixes a real memory leak when
    macvtap_get_queue fails.
    
    Chris Wright noticed that for this patch to work, we need a
    non-zero TX queue length.  This patch includes his work to change
    the default macvtap TX queue length to 500.
    Reported-by: NMark Wagner <mwagner@redhat.com>
    Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
    Acked-by: NChris Wright <chrisw@sous-sol.org>
    Acked-by: NArnd Bergmann <arnd@arndb.de>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    8a35747a
macvlan.c 20.0 KB