From: Yi Yang <yangy...@inspur.com> New free_cb interface can help fix original external mbuf free issue in GSO case, it still can be compatible with normal non-GSO case. dpdkvhostuser port can work both in GSO case and in non-GSO case by this fix.
Signed-off-by: Yi Yang <yangy...@inspur.com> --- lib/librte_vhost/virtio_net.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index e663fd4..3b69cbb 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -2136,10 +2136,20 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id, return NULL; } +struct shinfo_arg { + void *buf; + struct rte_mbuf *mbuf; +}; + static void -virtio_dev_extbuf_free(struct rte_mbuf * caller_m __rte_unused, void *opaque) +virtio_dev_extbuf_free(struct rte_mbuf *caller_m, void *opaque) { - rte_free(opaque); + struct shinfo_arg *arg = (struct shinfo_arg *)opaque; + + rte_free(arg->buf); + if (caller_m != arg->mbuf) + rte_pktmbuf_free(arg->mbuf); + rte_free(arg); } static int @@ -2172,8 +2182,14 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id, /* Initialize shinfo */ if (shinfo) { + struct shinfo_arg *arg = (struct shinfo_arg *) + rte_malloc(NULL, sizeof(struct shinfo_arg), + RTE_CACHE_LINE_SIZE); + + arg->buf = buf; + arg->mbuf = pkt; shinfo->free_cb = virtio_dev_extbuf_free; - shinfo->fcb_opaque = buf; + shinfo->fcb_opaque = arg; rte_mbuf_ext_refcnt_set(shinfo, 1); } else { shinfo = rte_pktmbuf_ext_shinfo_init_helper(buf, &buf_len, -- 1.8.3.1