DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ruifeng Wang <Ruifeng.Wang@arm.com>
To: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, nd <nd@arm.com>,
	Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
	Phil Yang <Phil.Yang@arm.com>, nd <nd@arm.com>
Subject: Re: [dpdk-dev] [PATCH] lpm: fix unchecked return value
Date: Thu, 16 Jul 2020 14:43:45 +0000
Message-ID: <HE1PR0801MB202518A45D380CD38456D9D89E7F0@HE1PR0801MB2025.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <95c0390e-b746-c519-09c6-6ab02c70887a@intel.com>


> -----Original Message-----
> From: Medvedkin, Vladimir <vladimir.medvedkin@intel.com>
> Sent: Thursday, July 16, 2020 7:00 PM
> To: Ruifeng Wang <Ruifeng.Wang@arm.com>; Bruce Richardson
> <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; nd <nd@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Phil Yang <Phil.Yang@arm.com>
> Subject: Re: [PATCH] lpm: fix unchecked return value
> 
> Hi Ruifeng,
> 
> On 16/07/2020 06:19, Ruifeng Wang wrote:
> > Coverity complains about unchecked return value of
> rte_rcu_qsbr_dq_enqueue.
> > By default, defer queue size is big enough to hold all tbl8 groups.
> > When enqueue fails, return error to the user to indicate system issue.
> >
> > Coverity issue: 360832
> > Fixes: 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
> >
> > Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> >   lib/librte_lpm/rte_lpm.c | 16 +++++++++++-----
> >   1 file changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index
> > 2db9e16a2..a6d3a7894 100644
> > --- a/lib/librte_lpm/rte_lpm.c
> > +++ b/lib/librte_lpm/rte_lpm.c
> > @@ -532,11 +532,12 @@ tbl8_alloc(struct rte_lpm *lpm)
> >   	return group_idx;
> >   }
> >
> > -static void
> > +static int
> >   tbl8_free(struct rte_lpm *lpm, uint32_t tbl8_group_start)
> >   {
> >   	struct rte_lpm_tbl_entry zero_tbl8_entry = {0};
> >   	struct __rte_lpm *internal_lpm;
> > +	int rc = 0;
> >
> >   	internal_lpm = container_of(lpm, struct __rte_lpm, lpm);
> >   	if (internal_lpm->v == NULL) {
> > @@ -552,9 +553,13 @@ tbl8_free(struct rte_lpm *lpm, uint32_t
> tbl8_group_start)
> >   				__ATOMIC_RELAXED);
> >   	} else if (internal_lpm->rcu_mode == RTE_LPM_QSBR_MODE_DQ) {
> >   		/* Push into QSBR defer queue. */
> > -		rte_rcu_qsbr_dq_enqueue(internal_lpm->dq,
> > +		rc = rte_rcu_qsbr_dq_enqueue(internal_lpm->dq,
> >   				(void *)&tbl8_group_start);
> 
> On failure rte_rcu_qsbr_dq_enqueue() returns 1 and sets rte_errno.
> Consequently, rc value is propagated to delete_depth_big() ->
> rte_lpm_delete(), and on failure the latter returns "1" value, which conflicts
> with the LPM API:
> "0 on success, negative value otherwise"
> I would suggest here to return -rte_errno if rc is equal to 1.
> 
Yes, the return value is a little different from LPM APIs.
Will change it in next version to keep consistent with other LPM APIs.

Thanks.
/Ruifeng
> 
> > +		if (rc != 0)
> > +			RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n");
> >   	}
> > +
> > +	return rc;
> >   }
> >
> >   static __rte_noinline int32_t
> > @@ -1041,6 +1046,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t
> ip_masked,
> >   	uint32_t tbl24_index, tbl8_group_index, tbl8_group_start,
> tbl8_index,
> >   			tbl8_range, i;
> >   	int32_t tbl8_recycle_index;
> > +	int rc = 0;
> >
> >   	/*
> >   	 * Calculate the index into tbl24 and range. Note: All depths
> > larger @@ -1097,7 +1103,7 @@ delete_depth_big(struct rte_lpm *lpm,
> uint32_t ip_masked,
> >   		 */
> >   		lpm->tbl24[tbl24_index].valid = 0;
> >   		__atomic_thread_fence(__ATOMIC_RELEASE);
> > -		tbl8_free(lpm, tbl8_group_start);
> > +		rc = tbl8_free(lpm, tbl8_group_start);
> >   	} else if (tbl8_recycle_index > -1) {
> >   		/* Update tbl24 entry. */
> >   		struct rte_lpm_tbl_entry new_tbl24_entry = { @@ -1113,10
> +1119,10
> > @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
> >   		__atomic_store(&lpm->tbl24[tbl24_index],
> &new_tbl24_entry,
> >   				__ATOMIC_RELAXED);
> >   		__atomic_thread_fence(__ATOMIC_RELEASE);
> > -		tbl8_free(lpm, tbl8_group_start);
> > +		rc = tbl8_free(lpm, tbl8_group_start);
> >   	}
> >   #undef group_idx
> > -	return 0;
> > +	return (int32_t)rc;
> >   }
> >
> >   /*
> >
> 
> --
> Regards,
> Vladimir

  reply	other threads:[~2020-07-16 14:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16  5:19 Ruifeng Wang
2020-07-16 10:59 ` Medvedkin, Vladimir
2020-07-16 14:43   ` Ruifeng Wang [this message]
2020-07-16 15:49 ` [dpdk-dev] [PATCH v2] " Ruifeng Wang
2020-07-17 17:12   ` Medvedkin, Vladimir
2020-07-18  9:22     ` Ruifeng Wang
2020-07-21 16:23       ` Medvedkin, Vladimir
2020-07-21 17:10         ` Bruce Richardson
2020-07-21 17:33           ` David Marchand
2020-07-21 18:49   ` David Marchand

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=HE1PR0801MB202518A45D380CD38456D9D89E7F0@HE1PR0801MB2025.eurprd08.prod.outlook.com \
    --to=ruifeng.wang@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Phil.Yang@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=nd@arm.com \
    --cc=vladimir.medvedkin@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git