From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [PATCH 03/13] net/bnxt: add check to validate TSO segment size
Date: Fri, 25 Oct 2024 10:57:28 -0700 [thread overview]
Message-ID: <20241025175738.99564-4-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20241025175738.99564-1-ajit.khaparde@broadcom.com>
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Currently driver has a check to validate TSO seg_size for 0 which
is to detect corrupted packet. But user can set any value as the
TSO seg_size. Adding a check to validate the minimum TSO seg_size
in the driver.
Driver will drop a packet with TSO seg_size less than 4 when
TSO is requested in the MBUF flags.
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
drivers/net/bnxt/bnxt_txr.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index c82b11e733..6d7e9962ce 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -129,23 +129,26 @@ bnxt_xmit_need_long_bd(struct rte_mbuf *tx_pkt, struct bnxt_tx_queue *txq)
* segments or fragments in those cases.
*/
static bool
-bnxt_zero_data_len_tso_segsz(struct rte_mbuf *tx_pkt, uint8_t data_len_chk)
+bnxt_zero_data_len_tso_segsz(struct rte_mbuf *tx_pkt, bool data_len_chk, bool tso_segsz_check)
{
- const char *type_str = "Data len";
- uint16_t len_to_check = tx_pkt->data_len;
+ const char *type_str;
- if (data_len_chk == 0) {
- type_str = "TSO Seg size";
- len_to_check = tx_pkt->tso_segsz;
+ /* Minimum TSO seg_size should be 4 */
+ if (tso_segsz_check && tx_pkt->tso_segsz < 4) {
+ type_str = "Unsupported TSO Seg size";
+ goto dump_pkt;
}
- if (len_to_check == 0) {
- PMD_DRV_LOG_LINE(ERR, "Error! Tx pkt %s == 0", type_str);
- rte_pktmbuf_dump(stdout, tx_pkt, 64);
- rte_dump_stack();
- return true;
+ if (data_len_chk && tx_pkt->data_len == 0) {
+ type_str = "Data len == 0";
+ goto dump_pkt;
}
return false;
+dump_pkt:
+ PMD_DRV_LOG_LINE(ERR, "Error! Tx pkt %s == 0", type_str);
+ rte_pktmbuf_dump(stdout, tx_pkt, 64);
+ rte_dump_stack();
+ return true;
}
static bool
@@ -248,7 +251,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
}
/* Check non zero data_len */
- if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, 1)))
+ if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, true, false)))
return -EIO;
if (unlikely(txq->bp->ptp_cfg != NULL && txq->bp->ptp_all_rx_tstamp == 1))
@@ -338,7 +341,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
*/
txbd1->kid_or_ts_low_hdr_size = hdr_size >> 1;
txbd1->kid_or_ts_high_mss = tx_pkt->tso_segsz;
- if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, 0)))
+ if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, false, true)))
return -EIO;
} else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) ==
@@ -413,7 +416,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
m_seg = tx_pkt->next;
while (m_seg) {
/* Check non zero data_len */
- if (unlikely(bnxt_zero_data_len_tso_segsz(m_seg, 1)))
+ if (unlikely(bnxt_zero_data_len_tso_segsz(m_seg, true, false)))
return -EIO;
txr->tx_raw_prod = RING_NEXT(txr->tx_raw_prod);
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2024-10-25 17:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 17:57 [PATCH 00/13] patchset for bnxt PMD Ajit Khaparde
2024-10-25 17:57 ` [PATCH 01/13] net/bnxt: fix TCP and UDP checksum flags Ajit Khaparde
2024-10-25 17:57 ` [PATCH 02/13] net/bnxt: fix bad action offset in Tx bd Ajit Khaparde
2024-10-25 17:57 ` Ajit Khaparde [this message]
2024-10-25 17:57 ` [PATCH 04/13] net/bnxt: add check for number of segs Ajit Khaparde
2024-10-25 17:57 ` [PATCH 05/13] net/bnxt: add check for invalid mbuf passed by application Ajit Khaparde
2024-10-25 17:57 ` [PATCH 06/13] net/bnxt: free and account a bad Tx mbuf Ajit Khaparde
2024-10-25 17:57 ` [PATCH 07/13] net/bnxt: register for and handle RSS change event Ajit Khaparde
2024-10-25 17:57 ` [PATCH 08/13] net/bnxt: fix LRO offload capability Ajit Khaparde
2024-10-25 17:57 ` [PATCH 09/13] net/bnxt: disable VLAN filter when TF is enabled Ajit Khaparde
2024-10-25 17:57 ` [PATCH 10/13] net/bnxt: remove the VNIC async event handler Ajit Khaparde
2024-10-25 17:57 ` [PATCH 11/13] net/bnxt: remove some unnecessary logs Ajit Khaparde
2024-10-25 17:57 ` [PATCH 12/13] net/bnxt: add support for buffer split Rx offload Ajit Khaparde
2024-10-25 17:57 ` [PATCH 13/13] net/bnxt: remove unnecessary ifdef Ajit Khaparde
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=20241025175738.99564-4-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=somnath.kotur@broadcom.com \
/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).