virtio_net: Keep vnet header zeroed if XDP is loaded for small buffer
authorYuya Kusakabe <yuya.kusakabe@gmail.com>
Tue, 25 Feb 2020 03:32:11 +0000 (12:32 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 25 Feb 2020 21:50:55 +0000 (22:50 +0100)
We do not want to care about the vnet header in receive_small() if XDP
is loaded, since we can not know whether or not the packet is modified
by XDP.

Fixes: f6b10209b90d ("virtio-net: switch to use build_skb() for small buffer")
Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/bpf/20200225033212.437563-1-yuya.kusakabe@gmail.com
drivers/net/virtio_net.c

index 2fe7a3188282cd368be3dd6e2573afe39abf05e2..f39d0218bdaa1ef94956d45a437c5998336b5537 100644 (file)
@@ -735,10 +735,10 @@ static struct sk_buff *receive_small(struct net_device *dev,
        }
        skb_reserve(skb, headroom - delta);
        skb_put(skb, len);
-       if (!delta) {
+       if (!xdp_prog) {
                buf += header_offset;
                memcpy(skb_vnet_hdr(skb), buf, vi->hdr_len);
-       } /* keep zeroed vnet hdr since packet was changed by bpf */
+       } /* keep zeroed vnet hdr since XDP is loaded */
 
 err:
        return skb;