[dpdk-dev] [PATCH v2 3/4] net/virtio: allocate fake mbuf in Rx queue
David Marchand
david.marchand at redhat.com
Mon Mar 15 16:50:24 CET 2021
On Mon, Mar 15, 2021 at 4:20 PM Maxime Coquelin
<maxime.coquelin at redhat.com> wrote:
> @@ -550,10 +551,18 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
> goto free_hdr_mz;
> }
>
> + fake_mbuf = malloc(sizeof(*fake_mbuf));
> + if (!fake_mbuf) {
> + PMD_INIT_LOG(ERR, "can not allocate fake mbuf");
> + ret = -ENOMEM;
> + goto free_sw_ring;
> + }
> +
> vq->sw_ring = sw_ring;
> rxvq = &vq->rxq;
> rxvq->port_id = dev->data->port_id;
> rxvq->mz = mz;
> + rxvq->fake_mbuf = fake_mbuf;
IIRC, vq is allocated as dpdk memory (rte_malloc).
Generally speaking, storing a local pointer inside such an object is
dangerous if other processes start to look at this part.
> } else if (queue_type == VTNET_TQ) {
> txvq = &vq->txq;
> txvq->port_id = dev->data->port_id;
> @@ -613,6 +622,9 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
> clean_vq:
> hw->cvq = NULL;
>
> + if (fake_mbuf)
> + free(fake_mbuf);
No need for if().
--
David Marchand
More information about the dev
mailing list