Skip to content

Commit

Permalink
net/tap: fix check for mbuf number of segment
Browse files Browse the repository at this point in the history
[ upstream commit cc6cf04 ]

Now the rxq->pool is mbuf concatenation, but its nb_segs is 1. When
conducting some sanity checks on the mbuf with debug enabled, it fails.

Fixes: 0781f57 ("net/tap: support segmented mbufs")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
wyjwang authored and kevintraynor committed May 27, 2020
1 parent 19bab2b commit 782d542
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions drivers/net/tap/rte_eth_tap.c
Expand Up @@ -340,6 +340,23 @@ tap_rx_offload_get_queue_capa(void)
DEV_RX_OFFLOAD_TCP_CKSUM;
}

static void
tap_rxq_pool_free(struct rte_mbuf *pool)
{
struct rte_mbuf *mbuf = pool;
uint16_t nb_segs = 1;

if (mbuf == NULL)
return;

while (mbuf->next) {
mbuf = mbuf->next;
nb_segs++;
}
pool->nb_segs = nb_segs;
rte_pktmbuf_free(pool);
}

/* Callback to handle the rx burst of packets to the correct interface and
* file descriptor(s) in a multi-queue setup.
*/
Expand Down Expand Up @@ -390,7 +407,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
goto end;

seg->next = NULL;
rte_pktmbuf_free(mbuf);
tap_rxq_pool_free(mbuf);

goto end;
}
Expand Down Expand Up @@ -1022,7 +1039,7 @@ tap_dev_close(struct rte_eth_dev *dev)
rxq = &internals->rxq[i];
close(process_private->rxq_fds[i]);
process_private->rxq_fds[i] = -1;
rte_pktmbuf_free(rxq->pool);
tap_rxq_pool_free(rxq->pool);
rte_free(rxq->iovecs);
rxq->pool = NULL;
rxq->iovecs = NULL;
Expand Down Expand Up @@ -1061,7 +1078,7 @@ tap_rx_queue_release(void *queue)
if (process_private->rxq_fds[rxq->queue_id] > 0) {
close(process_private->rxq_fds[rxq->queue_id]);
process_private->rxq_fds[rxq->queue_id] = -1;
rte_pktmbuf_free(rxq->pool);
tap_rxq_pool_free(rxq->pool);
rte_free(rxq->iovecs);
rxq->pool = NULL;
rxq->iovecs = NULL;
Expand Down Expand Up @@ -1405,7 +1422,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
return 0;

error:
rte_pktmbuf_free(rxq->pool);
tap_rxq_pool_free(rxq->pool);
rxq->pool = NULL;
rte_free(rxq->iovecs);
rxq->iovecs = NULL;
Expand Down

0 comments on commit 782d542

Please sign in to comment.