net/memif: fix chained mbuf determination
authorJunxiao Shi <git@mail1.yoursunny.com>
Thu, 9 Sep 2021 14:42:06 +0000 (14:42 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 27 Sep 2021 15:25:21 +0000 (17:25 +0200)
commit3e3f736e50fba910d1d484b9c763d884dff6688f
tree5d4dbb7e60089939e6b617dc83ac290db3da5b65
parent0ce56b057b5ceba9fc4f31d837aa2cd788e468cf
net/memif: fix chained mbuf determination

Previously, TX functions call rte_pktmbuf_is_contiguous to determine
whether an mbuf is chained. However, rte_pktmbuf_is_contiguous is
designed to work on the first mbuf of a packet only. In case a packet
contains three or more segment mbufs in a chain, it may cause truncated
packets or rte_mbuf_sanity_check panics.

This patch updates TX functions to determine chained mbufs using
mbuf_head->nb_segs field, which works in all cases. Moreover, it
maintains that the second cacheline is only accessed when chained mbuf
is actually present.

Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Fixes: 43b815d88188 ("net/memif: support zero-copy slave")
Cc: stable@dpdk.org
Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
Reviewed-by: Jakub Grajciar <jgrajcia@cisco.com>
drivers/net/memif/rte_eth_memif.c