A mbuf may be pointing at external buffer like when forwarding a TSO
packet coming from a vhost-user port in OVS (see
RTE_VHOST_USER_EXTBUF_SUPPORT).

Checking the mbuf mempool to trigger the zero copy optimisation is
broken: the driver will (at best) read 0s or (at worse) crash when
reading more data than what the direct buffer can contain.

Fixes: d8a210774e1d ("net/af_xdp: support unaligned umem chunks")
Cc: [email protected]

Signed-off-by: David Marchand <[email protected]>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c 
b/drivers/net/af_xdp/rte_eth_af_xdp.c
index f2a8fb95d1..10dbcf1333 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -608,7 +608,7 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t 
nb_pkts)
        for (i = 0; i < nb_pkts; i++) {
                mbuf = bufs[i];
 
-               if (mbuf->pool == umem->mb_pool) {
+               if (RTE_MBUF_DIRECT(mbuf) && mbuf->pool == umem->mb_pool) {
                        desc = reserve_and_fill(txq, mbuf, umem, NULL);
                        if (!desc) {
                                kick_tx(txq, cq);
-- 
2.52.0

Reply via email to