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 <yanglong.wu@intel.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
parent
33310b592f
commit
014a48de60
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user