DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Liu, KevinX" <kevinx.liu@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Yang, Qiming" <qiming.yang@intel.com>,
	"Yang, SteveX" <stevex.yang@intel.com>,
	"Xing, Beilei" <beilei.xing@intel.com>,
	"Wu, Jingjing" <jingjing.wu@intel.com>
Subject: RE: [PATCH 1/2] net/iavf: check illegal packets
Date: Fri, 23 Sep 2022 00:46:13 +0000	[thread overview]
Message-ID: <DM4PR11MB5994E2668D51371707AE8BC1D7519@DM4PR11MB5994.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220922070426.788643-2-kevinx.liu@intel.com>



> -----Original Message-----
> From: Liu, KevinX <kevinx.liu@intel.com>
> Sent: Thursday, September 22, 2022 3:04 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Liu, KevinX
> <kevinx.liu@intel.com>
> Subject: [PATCH 1/2] net/iavf: check illegal packets
> 
> Some illegal packets will lead to TX/RX hang and can't recover automatically.
> This patch check those illegal packets and protect TX/RX from hanging.

Better to describe precisely what kind of illegal packets you are going to prevent.

> 
> Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx")
> Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
> ---
>  drivers/net/iavf/iavf_rxtx.c | 10 +++++++++-  drivers/net/iavf/iavf_rxtx.h |  2
> ++
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index
> 3deabe1d7e..8ddd809f94 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -2877,7 +2877,8 @@ iavf_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
> 
>  		/* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG.
> */
>  		if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
> -			if (m->nb_segs > IAVF_TX_MAX_MTU_SEG) {
> +			if (m->nb_segs > IAVF_TX_MAX_MTU_SEG ||
> +				m->pkt_len > IAVF_FRAME_SIZE_MAX) {
>  				rte_errno = EINVAL;
>  				return i;
>  			}
> @@ -2893,6 +2894,13 @@ iavf_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
>  			return i;
>  		}
> 
> +		/* check the size of packet */
> +		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
> +			rte_errno = EINVAL;
> +			PMD_DRV_LOG(ERR, "INVALID mbuf: bad
> pkt_len=[%hu]", m->pkt_len);
> +			return i;
> +		}
> +
>  #ifdef RTE_ETHDEV_DEBUG_TX
>  		ret = rte_validate_tx_offload(m);
>  		if (ret != 0) {
> diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index
> 1695e43cd5..bb9083c699 100644
> --- a/drivers/net/iavf/iavf_rxtx.h
> +++ b/drivers/net/iavf/iavf_rxtx.h
> @@ -53,6 +53,8 @@
>  #define IAVF_TSO_MAX_SEG          UINT8_MAX
>  #define IAVF_TX_MAX_MTU_SEG       8
> 
> +#define IAVF_TX_MIN_PKT_LEN 17
> +
>  #define IAVF_TX_CKSUM_OFFLOAD_MASK (		 \
>  		RTE_MBUF_F_TX_IP_CKSUM |		 \
>  		RTE_MBUF_F_TX_L4_MASK |		 \
> --
> 2.25.1


  reply	other threads:[~2022-09-23  0:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22  7:04 [PATCH 0/2] " Kevin Liu
2022-09-22  7:04 ` [PATCH 1/2] net/iavf: " Kevin Liu
2022-09-23  0:46   ` Zhang, Qi Z [this message]
2022-09-22  7:04 ` [PATCH 2/2] net/ice: " Kevin Liu
2022-09-27  7:15 ` [PATCH v2 0/2] " Kevin Liu
2022-09-27  7:15   ` [PATCH v2 1/2] net/iavf: " Kevin Liu
2022-09-27  7:15   ` [PATCH v2 2/2] net/ice: " Kevin Liu
2022-09-30  0:21   ` [PATCH v2 0/2] " Zhang, Qi Z
2023-09-18 14:42   ` David Marchand
2023-09-18 14:51     ` Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM4PR11MB5994E2668D51371707AE8BC1D7519@DM4PR11MB5994.namprd11.prod.outlook.com \
    --to=qi.z.zhang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=kevinx.liu@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stevex.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).