]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
virtio_net: clarify tailroom logic
authorMichael S. Tsirkin <mst@redhat.com>
Sat, 9 Oct 2021 14:52:50 +0000 (10:52 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Nov 2021 08:29:47 +0000 (04:29 -0400)
Make tailroom math follow same logic as everything else, subtracing
values in the order in which things are laid out in the buffer.

Tested-by: Corentin Noël <corentin.noel@collabora.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/net/virtio_net.c

index 4ad25a8b0870c67f40c2cc8a6a0f6eddaded09dd..6d8c8745bf24228bfeb8665b837e4a6e0d8ef918 100644 (file)
@@ -406,12 +406,13 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
         * add_recvbuf_mergeable() + get_mergeable_buf_len()
         */
        truesize = headroom ? PAGE_SIZE : truesize;
-       tailroom = truesize - len - headroom - (hdr_padded_len - hdr_len);
+       tailroom = truesize - headroom;
        buf = p - headroom;
 
        len -= hdr_len;
        offset += hdr_padded_len;
        p += hdr_padded_len;
+       tailroom -= hdr_padded_len + len;
 
        shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));