From: Yanglong Wu Date: Fri, 27 Jul 2018 04:40:00 +0000 (+0800) Subject: net/i40e: fix maximum frame size check X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=014a48de609f33c0ab58c796272e62f0f518d9ea;p=dpdk.git net/i40e: fix maximum frame size check Check packet size according to TSO or no-TSO. Fixes: bfeed0262b0c ("net/i40e: check illegal packets") Signed-off-by: Yanglong Wu Acked-by: Konstantin Ananyev --- diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index cb5e5b5d89..3fffe5a555 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -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 diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 59a6a8adb0..2a28ee348c 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -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; }