]> git.baikalelectronics.ru Git - kernel.git/commitdiff
virtio_net: fix rx_drops stat for small pkts
authorWenliang Wang <wangwenliang.1995@bytedance.com>
Thu, 16 Dec 2021 03:11:35 +0000 (11:11 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 16 Dec 2021 11:07:19 +0000 (11:07 +0000)
We found the stat of rx drops for small pkts does not increment when
build_skb fail, it's not coherent with other mode's rx drops stat.

Signed-off-by: Wenliang Wang <wangwenliang.1995@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index 55db6a336f7ead862ab98ab99e4518a7d2b3b87f..b107835242ade6c2f7411b2a019e44a9b0c85748 100644 (file)
@@ -733,7 +733,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
                pr_debug("%s: rx error: len %u exceeds max size %d\n",
                         dev->name, len, GOOD_PACKET_LEN);
                dev->stats.rx_length_errors++;
-               goto err_len;
+               goto err;
        }
 
        if (likely(!vi->xdp_enabled)) {
@@ -825,10 +825,8 @@ static struct sk_buff *receive_small(struct net_device *dev,
 
 skip_xdp:
        skb = build_skb(buf, buflen);
-       if (!skb) {
-               put_page(page);
+       if (!skb)
                goto err;
-       }
        skb_reserve(skb, headroom - delta);
        skb_put(skb, len);
        if (!xdp_prog) {
@@ -839,13 +837,12 @@ skip_xdp:
        if (metasize)
                skb_metadata_set(skb, metasize);
 
-err:
        return skb;
 
 err_xdp:
        rcu_read_unlock();
        stats->xdp_drops++;
-err_len:
+err:
        stats->drops++;
        put_page(page);
 xdp_xmit: