From: Igor Romanov Date: Tue, 2 Apr 2019 09:28:41 +0000 (+0100) Subject: net/sfc: add TSO header length check to Tx prepare X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9b70500cf2233b3aecea149f5bb37790464ff6c9;p=dpdk.git net/sfc: add TSO header length check to Tx prepare Make Tx prepare function able to detect packets with invalid header size when header linearization is required. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index ebc941857b..ae5524f24f 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -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; + } } /* diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index e7ab993ddf..9594084490 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -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; diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index f46c0e912f..a882e64dd2 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -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;