]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
virtio-net: remove redundant truesize check with PAGE_SIZE
authorBui Quang Minh <minhquangbui99@gmail.com>
Mon, 30 Jun 2025 14:42:11 +0000 (21:42 +0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 3 Jul 2025 08:56:55 +0000 (10:56 +0200)
The truesize is guaranteed not to exceed PAGE_SIZE in
get_mergeable_buf_len(). It is saved in mergeable context, which is not
changeable by the host side, so the check in receive path is quite
redundant.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://patch.msgid.link/20250630144212.48471-3-minhquangbui99@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/virtio_net.c

index 31661bcb393231ccf3c29ed4959e8e28db526988..535a4534c27f1d5da5af47ecbbff793df296ac29 100644 (file)
@@ -2157,9 +2157,9 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
 {
        struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
        unsigned int headroom, tailroom, room;
-       unsigned int truesize, cur_frag_size;
        struct skb_shared_info *shinfo;
        unsigned int xdp_frags_truesz = 0;
+       unsigned int truesize;
        struct page *page;
        skb_frag_t *frag;
        int offset;
@@ -2207,9 +2207,8 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
                tailroom = headroom ? sizeof(struct skb_shared_info) : 0;
                room = SKB_DATA_ALIGN(headroom + tailroom);
 
-               cur_frag_size = truesize;
-               xdp_frags_truesz += cur_frag_size;
-               if (unlikely(len > truesize - room || cur_frag_size > PAGE_SIZE)) {
+               xdp_frags_truesz += truesize;
+               if (unlikely(len > truesize - room)) {
                        put_page(page);
                        pr_debug("%s: rx error: len %u exceeds truesize %lu\n",
                                 dev->name, len, (unsigned long)(truesize - room));