Skip to content

Commit

Permalink
virtio_net: fix rx_drops stat for small pkts
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jason Wang <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wwlliangliang authored and davem330 committed Dec 16, 2021
1 parent e08cdf6 commit 053c9e1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand All @@ -839,13 +837,12 @@ static struct sk_buff *receive_small(struct net_device *dev,
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:
Expand Down

0 comments on commit 053c9e1

Please sign in to comment.