summaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2021-10-09 16:52:50 +0200
committerMichael S. Tsirkin <mst@redhat.com>2021-11-01 09:29:47 +0100
commitfc02e8cb0300c0146e1d4668a75663eb225d8182 (patch)
tree98b7cbd44e9b62924ff9b74f4935daa2e543674e /drivers/net/virtio_net.c
parentLinux 5.15 (diff)
downloadlinux-fc02e8cb0300c0146e1d4668a75663eb225d8182.tar.xz
linux-fc02e8cb0300c0146e1d4668a75663eb225d8182.zip
virtio_net: clarify tailroom logic
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>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4ad25a8b0870..6d8c8745bf24 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -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));