[09/12] net/sfc: add TSO header length check to Tx prepare
Checks
Commit Message
From: Igor Romanov <igor.romanov@oktetlabs.ru>
Make Tx prepare function able to detect packets with invalid header
size when header linearization is required.
Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/sfc_dp_tx.h | 11 ++++++++++-
drivers/net/sfc/sfc_ef10_tx.c | 2 ++
drivers/net/sfc/sfc_tso.c | 2 ++
3 files changed, 14 insertions(+), 1 deletion(-)
@@ -14,6 +14,7 @@
#include "sfc_dp.h"
#include "sfc_debug.h"
+#include "sfc_tso.h"
#ifdef __cplusplus
extern "C" {
@@ -230,8 +231,16 @@ sfc_dp_tx_prepare_pkt(struct rte_mbuf *m,
* Extra descriptor that is required when a packet header
* is separated from remaining content of the first segment.
*/
- if (rte_pktmbuf_data_len(m) > header_len)
+ if (rte_pktmbuf_data_len(m) > header_len) {
descs_required++;
+ } else if (rte_pktmbuf_data_len(m) < header_len &&
+ unlikely(header_len > SFC_TSOH_STD_LEN)) {
+ /*
+ * Header linearization is required and
+ * the header is too big to be linearized
+ */
+ return EINVAL;
+ }
}
/*
@@ -447,6 +447,8 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg,
/*
* Discard a packet if header linearization is needed but
* the header is too big.
+ * Duplicate Tx prepare check here to avoid spoil of
+ * memory if Tx prepare is skipped.
*/
if (unlikely(header_len > SFC_TSOH_STD_LEN))
return EMSGSIZE;
@@ -119,6 +119,8 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
/*
* Discard a packet if header linearization is needed but
* the header is too big.
+ * Duplicate Tx prepare check here to avoid spoil of
+ * memory if Tx prepare is skipped.
*/
if (unlikely(header_len > SFC_TSOH_STD_LEN))
return EMSGSIZE;