From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Igor Romanov <igor.romanov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 09/12] net/sfc: add TSO header length check to Tx prepare
Date: Tue, 2 Apr 2019 10:28:41 +0100 [thread overview]
Message-ID: <1554197324-32391-10-git-send-email-arybchenko@solarflare.com> (raw)
Message-ID: <20190402092841.CDpW5BnG2ftPq6c4lJEPbE201noK2Qjat21dGMcdEvs@z> (raw)
In-Reply-To: <1554197324-32391-1-git-send-email-arybchenko@solarflare.com>
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(-)
diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index ebc941857..ae5524f24 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 e7ab993dd..959408449 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 f46c0e912..a882e64dd 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;
--
2.17.1
next prev parent reply other threads:[~2019-04-02 9:30 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 9:28 [dpdk-dev] [PATCH 00/12] net/sfc: add Tx prepare and encapsulated TSO Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 01/12] net/sfc: improve TSO header length check in EFX datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 02/12] net/sfc: improve TSO header length check in EF10 datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 03/12] net/sfc: make TSO descriptor numbers EF10-specific Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 04/12] net/sfc: support Tx preparation in EFX datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 05/12] net/sfc: support Tx preparation in EF10 datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 06/12] net/sfc: support Tx preparation in EF10 simple datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 07/12] net/sfc: move TSO header checks from Tx burst to Tx prepare Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 08/12] net/sfc: introduce descriptor space check in " Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko [this message]
2019-04-02 9:28 ` [dpdk-dev] [PATCH 09/12] net/sfc: add TSO header length check to " Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 10/12] net/sfc: factor out function to get IPv4 packet ID for TSO Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 11/12] net/sfc: improve log message about missing HW TSO support Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-02 9:28 ` [dpdk-dev] [PATCH 12/12] net/sfc: support tunnel TSO on EF10 native Tx datapath Andrew Rybchenko
2019-04-02 9:28 ` Andrew Rybchenko
2019-04-03 18:03 ` [dpdk-dev] [PATCH 00/12] net/sfc: add Tx prepare and encapsulated TSO Ferruh Yigit
2019-04-03 18:03 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1554197324-32391-10-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
--cc=igor.romanov@oktetlabs.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).