net/ice: fix scalar Tx path segment

The scalar Tx path would send empty buffer that causes the Tx queue to
overflow.

This patch adds the last buffer length judgment in tx_prepare to fix this
issue, rte_errno will be set to EINVAL and returned if the last buffer is
empty.

Fixes: 17c7d0f9d6 ("net/ice: support basic Rx/Tx")
Fixes: ccf33dccf7 ("net/ice: check illegal packet sizes")
Cc: stable@dpdk.org

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
This commit is contained in:
Mingjin Ye 2022-11-11 16:12:41 +00:00 committed by Qi Zhang
parent 51097d9d77
commit 688cb2f2c6

View File

@ -3645,6 +3645,22 @@ ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
#define ICE_MIN_TSO_MSS 64
#define ICE_MAX_TSO_MSS 9728
#define ICE_MAX_TSO_FRAME_SIZE 262144
/*Check for empty mbuf*/
static inline uint16_t
ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
{
struct rte_mbuf *txd = tx_pkt;
while (txd != NULL) {
if (txd->data_len == 0)
return -1;
txd = txd->next;
}
return 0;
}
uint16_t
ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
@ -3691,6 +3707,12 @@ ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
rte_errno = -ret;
return i;
}
if (ice_check_empty_mbuf(m) != 0) {
rte_errno = EINVAL;
PMD_DRV_LOG(ERR, "INVALID mbuf: last mbuf data_len=[0]");
return i;
}
}
return i;
}