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>
#include "sfc_dp.h"
#include "sfc_debug.h"
+#include "sfc_tso.h"
#ifdef __cplusplus
extern "C" {
* 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;
+ }
}
/*
/*
* 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;
/*
* 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;