[dpdk-dev] [PATCH v2] net/i40e: illagel pactket checking

Ananyev, Konstantin konstantin.ananyev at intel.com
Fri Jun 8 16:04:53 CEST 2018



> -----Original Message-----
> From: Wu, Yanglong
> Sent: Friday, June 8, 2018 4:54 AM
> To: dev at dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang at intel.com>; Ananyev, Konstantin <konstantin.ananyev at intel.com>; Wu, Yanglong
> <yanglong.wu at intel.com>
> Subject: [PATCH v2] net/i40e: illagel pactket checking
> 
> Some illegal packets will lead to TX/RX hang and
> can't recover automatically. This pacth check those
> illegal packets and protect TX/RX from hanging.
> 
> Signed-off-by: Yanglong Wu <yanglong.wu at intel.com>
> ---
> v2:
> fix coding style issue and error
> ---
>  drivers/net/i40e/i40e_rxtx.c | 11 +++++++++++
>  drivers/net/i40e/i40e_rxtx.h |  2 ++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index 6032d5541..05cf3956c 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -1458,6 +1458,17 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
>  			return i;
>  		}
> 
> +		/*check the size of pkt len*/
> +		if (m->pkt_len > I40E_FRAME_SIZE_MAX ||
> +		    m->pkt_len < I40E_TX_MIN_PKT_LEN) {
> +			rte_errno = -EINVAL;
> +			return i; }

Please follow DPDK coding style: 
If (...) {
	...
}

> +
> +		/*check the number of mbuf segments*/
> +		if (m->nb_segs > I40E_TX_MAX_MTU_SEG) {
> +			rte_errno = -EINVAL;
> +			return i; }


I'll just repeat comment from my previous mail:
We already checking that in that function:

	/* Check for m->nb_segs to not exceed the limits. */
                if (!(ol_flags & PKT_TX_TCP_SEG)) {
                        if (m->nb_segs > I40E_TX_MAX_SEG ||
                            m->nb_segs > I40E_TX_MAX_MTU_SEG) {
                                rte_errno = -EINVAL;
                                return i;
                        }
                } else if ((m->tso_segsz < I40E_MIN_TSO_MSS) ||
                                (m->tso_segsz > I40E_MAX_TSO_MSS)) {
                        /* MSS outside the range (256B - 9674B) are considered
                         * malicious
                         */
                        rte_errno = -EINVAL;
                        return i;
                }

Though it seems it is not totally correct, should probably be:

if (!(ol_flags & PKT_TX_TCP_SEG)) {
	if (m->nb_segs > I40E_TX_MAX_SEG) {
		...
}
} else if (m->nb_segs > I40E_TX_MAX_MTU_SEG ||
		m->tso_segsz < I40E_MIN_TSO_MSS ||
		m->tso_segsz > I40E_MAX_TSO_MSS) {
	...
}


Konstantin


More information about the dev mailing list