Message ID | 20230508061417.65297-8-xuanzhuo@linux.alibaba.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 4cb00b13c064088352a4f2ca4a8279010ad218a8 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio_net: refactor xdp codes | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 8 this patch: 8 |
netdev/cc_maintainers | success | CCed 14 of 14 maintainers |
netdev/build_clang | success | Errors and warnings before: 8 this patch: 8 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 8 this patch: 8 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 34 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Mon, May 8, 2023 at 2:14 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote: > > virtnet_build_xdp_buff_mrg() auto release xdp shinfo then the caller no > need to careful the xdp shinfo. > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Thanks > --- > drivers/net/virtio_net.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index b26e95c96141..2d1329c32751 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1194,7 +1194,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, > dev->name, *num_buf, > virtio16_to_cpu(vi->vdev, hdr->num_buffers)); > dev->stats.rx_length_errors++; > - return -EINVAL; > + goto err; > } > > stats->bytes += len; > @@ -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", > dev->name, len, (unsigned long)(truesize - room)); > dev->stats.rx_length_errors++; > - return -EINVAL; > + goto err; > } > > frag = &shinfo->frags[shinfo->nr_frags++]; > @@ -1228,6 +1228,10 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, > > *xdp_frags_truesize = xdp_frags_truesz; > return 0; > + > +err: > + put_xdp_frags(xdp); > + return -EINVAL; > } > > static void *mergeable_xdp_get_buf(struct virtnet_info *vi, > @@ -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, > &num_buf, &xdp_frags_truesz, stats); > if (unlikely(err)) > - goto err_xdp_frags; > + goto err_xdp; > > act = virtnet_xdp_handler(xdp_prog, &xdp, dev, xdp_xmit, stats); > > -- > 2.32.0.3.g01195cf9f >
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b26e95c96141..2d1329c32751 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1194,7 +1194,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, dev->name, *num_buf, virtio16_to_cpu(vi->vdev, hdr->num_buffers)); dev->stats.rx_length_errors++; - return -EINVAL; + goto err; } stats->bytes += len; @@ -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", dev->name, len, (unsigned long)(truesize - room)); dev->stats.rx_length_errors++; - return -EINVAL; + goto err; } frag = &shinfo->frags[shinfo->nr_frags++]; @@ -1228,6 +1228,10 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev, *xdp_frags_truesize = xdp_frags_truesz; return 0; + +err: + put_xdp_frags(xdp); + return -EINVAL; } static void *mergeable_xdp_get_buf(struct virtnet_info *vi, @@ -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, &num_buf, &xdp_frags_truesz, stats); if (unlikely(err)) - goto err_xdp_frags; + goto err_xdp; act = virtnet_xdp_handler(xdp_prog, &xdp, dev, xdp_xmit, stats);
virtnet_build_xdp_buff_mrg() auto release xdp shinfo then the caller no need to careful the xdp shinfo. Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/net/virtio_net.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)