• Jesper Dangaard Brouer's avatar
    virtio_net: fix XDP code path in receive_small() · 95dbe9e7
    Jesper Dangaard Brouer authored
    When configuring virtio_net to use the code path 'receive_small()',
    in-order to get correct XDP_REDIRECT support, I discovered TCP packets
    would get silently dropped when loading an XDP program action XDP_PASS.
    
    The bug seems to be that receive_small() when XDP is loaded check that
    hdr->hdr.flags is zero, which seems wrong as hdr.flags contains the
    flags VIRTIO_NET_HDR_F_* :
     #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
     #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
    
    TCP got dropped as it had the VIRTIO_NET_HDR_F_DATA_VALID flag set.
    
    The flags that are relevant here are the VIRTIO_NET_HDR_GSO_* flags
    stored in hdr->hdr.gso_type. Thus, the fix is just check that none of
    the gso_type flags have been set.
    
    Fixes: bb91accf ("virtio-net: XDP support for small buffers")
    Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    95dbe9e7
virtio_net.c 75.9 KB