Commit 4cb00b13 authored by Xuan Zhuo's avatar Xuan Zhuo Committed by Jakub Kicinski

virtio_net: virtnet_build_xdp_buff_mrg() auto release xdp shinfo

virtnet_build_xdp_buff_mrg() auto release xdp shinfo then the caller no
need to careful the xdp shinfo.
Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 80f50f91
...@@ -1194,7 +1194,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, ...@@ -1194,7 +1194,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
dev->name, *num_buf, dev->name, *num_buf,
virtio16_to_cpu(vi->vdev, hdr->num_buffers)); virtio16_to_cpu(vi->vdev, hdr->num_buffers));
dev->stats.rx_length_errors++; dev->stats.rx_length_errors++;
return -EINVAL; goto err;
} }
stats->bytes += len; stats->bytes += len;
...@@ -1213,7 +1213,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, ...@@ -1213,7 +1213,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
pr_debug("%s: rx error: len %u exceeds truesize %lu\n", pr_debug("%s: rx error: len %u exceeds truesize %lu\n",
dev->name, len, (unsigned long)(truesize - room)); dev->name, len, (unsigned long)(truesize - room));
dev->stats.rx_length_errors++; dev->stats.rx_length_errors++;
return -EINVAL; goto err;
} }
frag = &shinfo->frags[shinfo->nr_frags++]; frag = &shinfo->frags[shinfo->nr_frags++];
...@@ -1228,6 +1228,10 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, ...@@ -1228,6 +1228,10 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
*xdp_frags_truesize = xdp_frags_truesz; *xdp_frags_truesize = xdp_frags_truesz;
return 0; return 0;
err:
put_xdp_frags(xdp);
return -EINVAL;
} }
static void *mergeable_xdp_get_buf(struct virtnet_info *vi, static void *mergeable_xdp_get_buf(struct virtnet_info *vi,
...@@ -1357,7 +1361,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, ...@@ -1357,7 +1361,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
err = virtnet_build_xdp_buff_mrg(dev, vi, rq, &xdp, data, len, frame_sz, err = virtnet_build_xdp_buff_mrg(dev, vi, rq, &xdp, data, len, frame_sz,
&num_buf, &xdp_frags_truesz, stats); &num_buf, &xdp_frags_truesz, stats);
if (unlikely(err)) if (unlikely(err))
goto err_xdp_frags; goto err_xdp;
act = virtnet_xdp_handler(xdp_prog, &xdp, dev, xdp_xmit, stats); act = virtnet_xdp_handler(xdp_prog, &xdp, dev, xdp_xmit, stats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment