Skip to content

Commit

Permalink
net/ice: fix scalar Tx path segment
Browse files Browse the repository at this point in the history
[ upstream commit 688cb2f ]

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: 17c7d0f ("net/ice: support basic Rx/Tx")
Fixes: ccf33dc ("net/ice: check illegal packet sizes")

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
  • Loading branch information
yemj-odc authored and kevintraynor committed Nov 23, 2022
1 parent da678c3 commit 1f77635
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/net/ice/ice_rxtx.c
Expand Up @@ -3459,6 +3459,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)
Expand Down Expand Up @@ -3505,6 +3521,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;
}
Expand Down

0 comments on commit 1f77635

Please sign in to comment.