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 <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
Igor Romanov 2019-04-02 10:28:41 +01:00 committed by Ferruh Yigit
parent f7a66f9365
commit 9b70500cf2
3 changed files with 14 additions and 1 deletions

View File

@ -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;
}
}
/*

View File

@ -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;

View File

@ -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;