net/sfc: add TSO header length check to Tx prepare
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Tue, 2 Apr 2019 09:28:41 +0000 (10:28 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 5 Apr 2019 15:45:22 +0000 (17:45 +0200)
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
drivers/net/sfc/sfc_ef10_tx.c
drivers/net/sfc/sfc_tso.c

index ebc9418..ae5524f 100644 (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;
+               }
        }
 
        /*
index e7ab993..9594084 100644 (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;
index f46c0e9..a882e64 100644 (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;