• M
    tun: Fix/rewrite packet filtering logic · f271b2cc
    Max Krasnyansky 提交于
    Please see the following thread to get some context on this
    	http://marc.info/?l=linux-netdev&m=121564433018903&w=2
    
    Basically the issue is that current multi-cast filtering stuff in
    the TUN/TAP driver is seriously broken.
    Original patch went in without proper review and ACK. It was broken and
    confusing to start with and subsequent patches broke it completely.
    To give you an idea of what's broken here are some of the issues:
    
    - Very confusing comments throughout the code that imply that the
    character device is a network interface in its own right, and that packets
    are passed between the two nics. Which is completely wrong.
    
    - Wrong set of ioctls is used for setting up filters. They look like
    shortcuts for manipulating state of the tun/tap network interface but
    in reality manipulate the state of the TX filter.
    
    - ioctls that were originally used for setting address of the the TX filter
    got "fixed" and now set the address of the network interface itself. Which
    made filter totaly useless.
    
    - Filtering is done too late. Instead of filtering early on, to avoid
    unnecessary wakeups, filtering is done in the read() call.
    
    The list goes on and on :)
    
    So the patch cleans all that up. It introduces simple and clean interface for
    setting up TX filters (TUNSETTXFILTER + tun_filter spec) and does filtering
    before enqueuing the packets.
    
    TX filtering is useful in the scenarios where TAP is part of a bridge, in
    which case it gets all broadcast, multicast and potentially other packets when
    the bridge is learning. So for example Ethernet tunnelling app may want to
    setup TX filters to avoid tunnelling multicast traffic. QEMU and other
    hypervisors can push RX filtering that is currently done in the guest into the
    host context therefore saving wakeups and unnecessary data transfer.
    Signed-off-by: NMax Krasnyansky <maxk@qualcomm.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    f271b2cc
if_tun.h 2.6 KB