Skip to contentSkip to conversation

net/iavf: add segment-length check to Tx prep

PATCH In review Bruce Richardson 3 participants 5 messages Nov 11, 2024 – Nov 19, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: add segment-length check to Tx prep

In the Tx prep function, the metadata checks were only checking the packet length and ignoring the data length. For single-buffer packets we can quickly check that the data length is the packet length.

Fixes 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
---
 drivers/net/iavf/iavf_rxtx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx.c +5 -1
index 4850b9e381..6a093c6746 100644
@@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			return i;
 		}
 
-		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
+		/* valid packets are greater than min size, and single-buffer pkts
+		 * must have data_len == pkt_len
+		 */
+		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
+				(m->nb_segs == 1 && m->data_len != m->pkt_len)) {
 			rte_errno = EINVAL;
 			return i;
 		}
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · Bruce Richardson

In the Tx prep function, the metadata checks were only checking the packet length and ignoring the data length. For single-buffer packets we can quickly check that the data length is the packet length.

Fixes 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
---
  drivers/net/iavf/iavf_rxtx.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx.c +5 -1
index 4850b9e381..6a093c6746 100644
@@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
  			return i;
  		}
 
-		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
+		/* valid packets are greater than min size, and single-buffer pkts
+		 * must have data_len == pkt_len
+		 */
+		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
+				(m->nb_segs == 1 && m->data_len != m->pkt_len)) {
  			rte_errno = EINVAL;
  			return i;
  		}
Signature · 2 lines
Regards,
Vladimir
Acked-by Vladimir Medvedkin Tested-by
#2 lore raw

________________________________
From: Medvedkin, Vladimir <[email protected]>
Sent: Monday 11 November 2024 5:46 pm
To: Richardson, Bruce <[email protected]>; [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Connolly, Padraig J <[email protected]>; Stokes, Ian <[email protected]>; Zhang, Qi Z <[email protected]>; Kevin Liu <[email protected]>
Subject: Re: [PATCH] net/iavf: add segment-length check to Tx prep

Quoted 20 lines · Bruce Richardson

In the Tx prep function, the metadata checks were only checking the packet length and ignoring the data length. For single-buffer packets we can quickly check that the data length is the packet length.

Fixes 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
---
  drivers/net/iavf/iavf_rxtx.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx.c +0 -0
index 4850b9e381..6a093c6746 100644
@@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
                       return i;
               }

drivers/net/iavf/iavf_rxtx.c iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, · line 3687

Quoted 10 lines
drivers/net/iavf/iavf_rxtx.c +5 -1
 
-             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
+             /* valid packets are greater than min size, and single-buffer pkts
+              * must have data_len == pkt_len
+              */
+             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
+                             (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
                       rte_errno = EINVAL;
                       return i;
               }

--
Regards,
Vladimir

Tested-by Tested-by
#3 lore raw
Quoted 24 lines
Quoted 21 lines · Bruce Richardson

In the Tx prep function, the metadata checks were only checking the packet length and ignoring the data length. For single-buffer packets we can quickly check that the data length is the packet length.

Fixes 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
---
  drivers/net/iavf/iavf_rxtx.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx.c +0 -0
index 4850b9e381..6a093c6746 100644
@@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
                       return i;
               }
 
Quoted 9 lines

drivers/net/iavf/iavf_rxtx.c iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, · line 3687

Quoted 9 lines
drivers/net/iavf/iavf_rxtx.c +5 -1
-             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
+             /* valid packets are greater than min size, and single-buffer pkts
+              * must have data_len == pkt_len
+              */
+             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
+                             (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
                       rte_errno = EINVAL;
                       return i;
               }

--
Regards,
Vladimir

author Applied
#4 lore raw
In reply to Connolly, Padraig J
Quoted 17 lines · Padraig J
     __________________________________________________________________

From: Medvedkin, Vladimir <[email protected]>
Sent: Monday 11 November 2024 5:46 pm
To: Richardson, Bruce <[email protected]>; [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Connolly, Padraig J <[email protected]>; Stokes, Ian <[email protected]>; Zhang, Qi Z <[email protected]>; Kevin Liu <[email protected]>
Subject: Re: [PATCH] net/iavf: add segment-length check to Tx prep

Quoted 2 lines · Bruce Richardson

In the Tx prep function, the metadata checks were only checking the packet length and ignoring the data length. For single-buffer packets

we

Quoted 2 lines

can quickly check that the data length is the packet length.

Quoted 7 lines
Quoted 5 lines
Fixes 19ee91c6bd9a ("net/iavf: check illegal packet sizes")

Applied to dpdk-next-net-intel

/Bruce