Skip to contentSkip to conversation

net/i40e: fix max frame size checking

PATCH Superseded Yanglong Wu 3 participants 10 messages Jul 26, 2018 – Jul 30, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix max frame size checking

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +1 -2
index 3be87fe6a..baad433a7 100644
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
Signature · 1 line
2.11.0
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 3 lines

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I remember. For TSO the limit is 256KB - yes, it is bibber, but still there is a limit. Might be we need to change that check, but I think we still need to keep it. Konstantin

Quoted 24 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +1 -3
index 3be87fe6a..baad433a7 100644
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--

2.11.0

#2 lore raw
Quoted 21 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 5:17 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 7 lines
Quoted 3 lines

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I remember. For TSO the limit is 256KB - yes, it is bibber, but still there is a limit.

I think we can't support more than 8 segment for TSO, right? so if the limit is 256KB, seems it is a redundant.

Quoted 29 lines

Might be we need to change that check, but I think we still need to keep it. Konstantin

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue,

Quoted 13 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..baad433a7 100644

drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 11 lines
drivers/net/i40e/i40e_rxtx.c +1 -3
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--

2.11.0

#3 lore raw
Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, July 26, 2018 8:14 PM
To: Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 24 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 5:17 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 12 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Quoted 6 lines
Quoted 3 lines

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I remember. For TSO the limit is 256KB - yes, it is bibber, but still there is a limit.

I think we can't support more than 8 segment for TSO, right? so if the limit is 256KB, seems it is a redundant.

I mean buffer size limit is 16kb according to datasheet.

Quoted 30 lines
Quoted 30 lines

Might be we need to change that check, but I think we still need to keep it. Konstantin

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue,

Quoted 13 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..baad433a7 100644

drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 11 lines
drivers/net/i40e/i40e_rxtx.c +1 -3
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--

2.11.0

#4 lore raw
Quoted 53 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 26, 2018 1:26 PM
To: Zhang, Qi Z <[email protected]>; Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 41 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, July 26, 2018 8:14 PM
To: Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 20 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 5:17 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 7 lines
Quoted 3 lines

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I remember. For TSO the limit is 256KB - yes, it is bibber, but still there is a limit.

I think we can't support more than 8 segment for TSO, right? so if the limit is 256KB, seems it is a redundant.

As I remember there is no limit for number of segs for TSO. For non-TSO - yes, max 8 segments per packet.

Quoted 33 lines

I mean buffer size limit is 16kb according to datasheet.

Quoted 30 lines
Quoted 30 lines

Might be we need to change that check, but I think we still need to keep it. Konstantin

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue,

Quoted 13 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..baad433a7 100644

drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 11 lines
drivers/net/i40e/i40e_rxtx.c +1 -3
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--

2.11.0

#5 lore raw
Quoted 65 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 8:33 PM
To: Zhang, Qi Z <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 52 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 26, 2018 1:26 PM
To: Zhang, Qi Z <[email protected]>; Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 40 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, July 26, 2018 8:14 PM
To: Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 28 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 5:17 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 3 lines

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I

Quoted 8 lines

remember.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

For TSO the limit is 256KB - yes, it is bibber, but still there is a limit.

I think we can't support more than 8 segment for TSO, right? so if the limit is 256KB, seems it is a redundant.

As I remember there is no limit for number of segs for TSO. For non-TSO - yes, max 8 segments per packet.

Oh, yes, it's only for non-TSO case, for TSO case,
So I agree the correct fix is we check the 256KB boundary for TSO case And still need to check the 9.5k boundary for non-TSO case.

Quoted 36 lines
Quoted 6 lines

I mean buffer size limit is 16kb according to datasheet.

Quoted 2 lines
Quoted 2 lines

Might be we need to change that check, but I think we still need to keep

it.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Konstantin

Quoted 13 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..baad433a7 100644

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void · line 1459

Quoted 1 line
drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void
 *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 11 lines
drivers/net/i40e/i40e_rxtx.c +1 -2
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;

}
--
2.11.0

#6 lore raw
Quoted 80 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 26, 2018 1:48 PM
To: Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 69 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 8:33 PM
To: Zhang, Qi Z <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 52 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 26, 2018 1:26 PM
To: Zhang, Qi Z <[email protected]>; Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 40 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Qi Z
Sent: Thursday, July 26, 2018 8:14 PM
To: Ananyev, Konstantin <[email protected]>; Wu, Yanglong <[email protected]>; [email protected]
Cc: Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 28 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, July 26, 2018 5:17 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Yanglong Wu
Sent: Thursday, July 26, 2018 7:46 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Bie, Tiwei <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH] net/i40e: fix max frame size checking

Quoted 3 lines

No need to check max frame size in TX, the checking should be done in up layer protocal. This checking will lead to fail for TSO or other application cases.

Not sure why is that?
i40e doesn't support single packet bigger then 9.5KB (or so), as I

remember.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

For TSO the limit is 256KB - yes, it is bibber, but still there is a limit.

I think we can't support more than 8 segment for TSO, right? so if the limit is 256KB, seems it is a redundant.

Quoted 6 lines
Quoted 2 lines

As I remember there is no limit for number of segs for TSO. For non-TSO - yes, max 8 segments per packet.

Oh, yes, it's only for non-TSO case, for TSO case,
So I agree the correct fix is we check the 256KB boundary for TSO case And still need to check the 9.5k boundary for non-TSO case.

Yep, sounds good.

Quoted 37 lines
Quoted 37 lines
Quoted 7 lines

I mean buffer size limit is 16kb according to datasheet.

Quoted 2 lines
Quoted 2 lines

Might be we need to change that check, but I think we still need to keep

it.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Konstantin

Quoted 13 lines
Fixes bfeed0262b0c ("net/i40e: check illegal packets")
---
 drivers/net/i40e/i40e_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..baad433a7 100644

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void · line 1459

Quoted 1 line
drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1459,8 +1459,7 @@ i40e_prep_pkts(__rte_unused void
 *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 11 lines
drivers/net/i40e/i40e_rxtx.c +1 -2
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;

}
--
2.11.0

#7 lore raw

PATCH v2 1/1 net/i40e: fix max frame size checking

In reply to Yanglong Wu

Check patcket size according to TSO or no-TSO.

Fixes bfeed0262b0c ("net/i40e: check illegal packets")

---
v2:
change as comments.

---
 drivers/net/i40e/i40e_ethdev.h | 1 +
 drivers/net/i40e/i40e_rxtx.c   | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/i40e/i40e_ethdev.h +1 -0
index cb5e5b5d8..3fffe5a55 100644
@@ -28,6 +28,7 @@
 #define I40E_NUM_DESC_ALIGN       32
 #define I40E_BUF_SIZE_MIN         1024
 #define I40E_FRAME_SIZE_MAX       9728
+#define I40E_TSO_FRAME_SIZE_MAX   262144
 #define I40E_QUEUE_BASE_ADDR_UNIT 128
 /* number of VSIs and queue default setting */
 #define I40E_MAX_QP_NUM_PER_VF    16
drivers/net/i40e/i40e_rxtx.c +5 -4
index 3be87fe6a..1bbc0340b 100644
@@ -1439,13 +1439,15 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 
 		/* Check for m->nb_segs to not exceed the limits. */
 		if (!(ol_flags & PKT_TX_TCP_SEG)) {
-			if (m->nb_segs > I40E_TX_MAX_MTU_SEG) {
+			if (m->nb_segs > I40E_TX_MAX_MTU_SEG ||
+			    m->pkt_len > I40E_FRAME_SIZE_MAX) {
 				rte_errno = -EINVAL;
 				return i;
 			}
 		} else if (m->nb_segs > I40E_TX_MAX_SEG ||
 			   m->tso_segsz < I40E_MIN_TSO_MSS ||
-			   m->tso_segsz > I40E_MAX_TSO_MSS) {
+			   m->tso_segsz > I40E_MAX_TSO_MSS ||
+			   m->pkt_len > I40E_TSO_FRAME_SIZE_MAX) {
 			/* MSS outside the range (256B - 9674B) are considered
 			 * malicious
 			 */
@@ -1459,8 +1461,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
Signature · 1 line
2.11.0
Acked-by on v2 1/1
#8 lore raw
Quoted 58 lines

-----Original Message-----
From: Wu, Yanglong
Sent: Friday, July 27, 2018 5:40 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Ananyev, Konstantin <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [PATCH v2] net/i40e: fix max frame size checking

Check patcket size according to TSO or no-TSO.

Fixes bfeed0262b0c ("net/i40e: check illegal packets")

---
v2:
change as comments.

---
 drivers/net/i40e/i40e_ethdev.h | 1 +
 drivers/net/i40e/i40e_rxtx.c   | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/i40e/i40e_ethdev.h +1 -0
index cb5e5b5d8..3fffe5a55 100644
@@ -28,6 +28,7 @@
 #define I40E_NUM_DESC_ALIGN       32
 #define I40E_BUF_SIZE_MIN         1024
 #define I40E_FRAME_SIZE_MAX       9728
+#define I40E_TSO_FRAME_SIZE_MAX   262144
 #define I40E_QUEUE_BASE_ADDR_UNIT 128
 /* number of VSIs and queue default setting */
 #define I40E_MAX_QP_NUM_PER_VF    16
drivers/net/i40e/i40e_rxtx.c +4 -2
index 3be87fe6a..1bbc0340b 100644
@@ -1439,13 +1439,15 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 
 		/* Check for m->nb_segs to not exceed the limits. */
 		if (!(ol_flags & PKT_TX_TCP_SEG)) {
-			if (m->nb_segs > I40E_TX_MAX_MTU_SEG) {
+			if (m->nb_segs > I40E_TX_MAX_MTU_SEG ||
+			    m->pkt_len > I40E_FRAME_SIZE_MAX) {
 				rte_errno = -EINVAL;
 				return i;
 			}
 		} else if (m->nb_segs > I40E_TX_MAX_SEG ||
 			   m->tso_segsz < I40E_MIN_TSO_MSS ||
-			   m->tso_segsz > I40E_MAX_TSO_MSS) {
+			   m->tso_segsz > I40E_MAX_TSO_MSS ||
+			   m->pkt_len > I40E_TSO_FRAME_SIZE_MAX) {
 			/* MSS outside the range (256B - 9674B) are considered
 			 * malicious
 			 */

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,

Quoted 10 lines
drivers/net/i40e/i40e_rxtx.c +1 -3
@@ -1459,8 +1461,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		}
 
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--
Quoted 1 line

2.11.0

Applied
#9 lore raw
Quoted 72 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, July 27, 2018 4:13 PM
To: Wu, Yanglong <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yao, Lei A <[email protected]>
Subject: RE: [PATCH v2] net/i40e: fix max frame size checking

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue,

Quoted 58 lines

-----Original Message-----
From: Wu, Yanglong
Sent: Friday, July 27, 2018 5:40 AM
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Ananyev, Konstantin <[email protected]>; Yao, Lei A <[email protected]>; Wu, Yanglong <[email protected]>
Subject: [PATCH v2] net/i40e: fix max frame size checking

Check patcket size according to TSO or no-TSO.

Fixes bfeed0262b0c ("net/i40e: check illegal packets")

---
v2:
change as comments.

---
 drivers/net/i40e/i40e_ethdev.h | 1 +
 drivers/net/i40e/i40e_rxtx.c   | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_ethdev.h index cb5e5b5d8..3fffe5a55 100644

drivers/net/i40e/i40e_ethdev.h +1 -0
@@ -28,6 +28,7 @@
 #define I40E_NUM_DESC_ALIGN       32
 #define I40E_BUF_SIZE_MIN         1024
 #define I40E_FRAME_SIZE_MAX       9728
+#define I40E_TSO_FRAME_SIZE_MAX   262144
 #define I40E_QUEUE_BASE_ADDR_UNIT 128
 /* number of VSIs and queue default setting */
 #define I40E_MAX_QP_NUM_PER_VF    16
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index 3be87fe6a..1bbc0340b 100644

drivers/net/i40e/i40e_rxtx.c +4 -2
@@ -1439,13 +1439,15 @@ i40e_prep_pkts(__rte_unused void *tx_queue,
 struct rte_mbuf **tx_pkts,
 
 		/* Check for m->nb_segs to not exceed the limits. */
 		if (!(ol_flags & PKT_TX_TCP_SEG)) {
-			if (m->nb_segs > I40E_TX_MAX_MTU_SEG) {
+			if (m->nb_segs > I40E_TX_MAX_MTU_SEG ||
+			    m->pkt_len > I40E_FRAME_SIZE_MAX) {
 				rte_errno = -EINVAL;
 				return i;
 			}
 		} else if (m->nb_segs > I40E_TX_MAX_SEG ||
 			   m->tso_segsz < I40E_MIN_TSO_MSS ||
-			   m->tso_segsz > I40E_MAX_TSO_MSS) {
+			   m->tso_segsz > I40E_MAX_TSO_MSS ||
+			   m->pkt_len > I40E_TSO_FRAME_SIZE_MAX) {
 			/* MSS outside the range (256B - 9674B) are considered
 			 * malicious
drivers/net/i40e/i40e_rxtx.c +0 -0
 			 */
@@ -1459,8 +1461,7 @@ i40e_prep_pkts(__rte_unused void *tx_queue,

struct rte_mbuf **tx_pkts,

Quoted 2 lines
drivers/net/i40e/i40e_rxtx.c +0 -0
 		}
 
Quoted 10 lines

drivers/net/i40e/i40e_rxtx.c i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,

Quoted 8 lines
drivers/net/i40e/i40e_rxtx.c +1 -3
 		/* check the size of packet */
-		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
-		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+		if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
 			rte_errno = -EINVAL;
 			return i;
 		}
--

Applied to dpdk-next-net-intel.

Thanks!
Qi

Quoted 2 lines
Quoted 2 lines

2.11.0