DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Jayatheerthan, Jay" <jay.jayatheerthan@intel.com>
To: "Kundapura, Ganapati" <ganapati.kundapura@intel.com>,
	"jerinjacobk@gmail.com" <jerinjacobk@gmail.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
Date: Tue, 5 Oct 2021 08:19:36 +0000	[thread overview]
Message-ID: <BN6SPR00MB2395BE62C3AFC290D8B11F8FDAF9@BN6SPR00MB239.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CO1PR11MB48824F42018CCE4ECF60B45187AE9@CO1PR11MB4882.namprd11.prod.outlook.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Monday, October 4, 2021 11:55 PM
> To: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; jerinjacobk@gmail.com; dev@dpdk.org
> Subject: RE: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
> 
> Hi Jay,
> 
> > -----Original Message-----
> > From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > Sent: 04 October 2021 22:49
> > To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> > jerinjacobk@gmail.com; dev@dpdk.org
> > Subject: RE: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
> >
> > > -----Original Message-----
> > > From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > > Sent: Friday, October 1, 2021 11:00 AM
> > > To: jerinjacobk@gmail.com; dev@dpdk.org
> > > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > > Subject: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf
> > > get
> > >
> > > rte_event_eth_rx_adapter_queue_conf_get() segfaults if called without
> > > queue added to the Rx adapter.
> > >
> > > Added check to no queues in Rx adapter and error out on being called
> > > with no queue in Rx adapter.
> > >
> > > Added test case to call queue conf get without queues in Rx adapter.
> > >
> > > Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config
> > > get")
> > > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > >
> > > ---
> > > v4:
> > > * Fixed checkpatch warning
> > >
> > > v3:
> > > * Added fixes line
> > >
> > > v2:
> > > * Corrected typo in the comment
> > > ---
> > >
> > > diff --git a/app/test/test_event_eth_rx_adapter.c
> > > b/app/test/test_event_eth_rx_adapter.c
> > > index 13664a3..d0dc552 100644
> > > --- a/app/test/test_event_eth_rx_adapter.c
> > > +++ b/app/test/test_event_eth_rx_adapter.c
> > > @@ -751,20 +751,48 @@ static int
> > >  adapter_queue_conf(void)
> > >  {
> > >  	int err;
> > > -	struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> > > +	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> > >
> > > -	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > +	/* Case 1: queue conf get without any queues in Rx adapter */
> > > +	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > > +						      TEST_ETHDEV_ID,
> > > +						      0, &queue_conf);
> > > +	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > > +
> > > +	/* Add queue to Rx adapter */
> > > +	queue_conf.ev.queue_id = 0;
> > > +	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
> > > +	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
> > > +
> > > +	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
> > > +						 TEST_ETHDEV_ID,
> > > +						 0, &queue_conf);
> > > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > > +
> > > +	/* Case 2: queue conf get with queue added to Rx adapter */
> > > +	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > > +						      TEST_ETHDEV_ID,
> > >  						      0, &queue_conf);
> > >  	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > >
> > > -	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > +	/* Case 3: queue conf get with invalid rx queue id */
> > > +	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > > +						      TEST_ETHDEV_ID,
> > >  						      -1, &queue_conf);
> >
> > rx_queue_id param is uint16_t. Would using non-configured queue id (for
> > e.g. rx_queue_id = 2) suffice instead of using -1 ?
> >
> When -1 is promoted/demoted to uint16_t, it'll be converted to large value i.e UINT_MAX and guaranteed
> to be invalid rx queue id and it's future proof.
> In case, some queues are added in that test case in future, this invalid rx_queue_id also needs to be updated.
> 
> Yes, for this case rx_queue_id=2 can be used, but it's not future proof.

Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>

> 
> > >  	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > >
> > > -	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > +	/* Case 4: queue conf get with NULL queue conf struct */
> > > +	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > > +						      TEST_ETHDEV_ID,
> > >  						      0, NULL);
> > >  	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > >
> > > +	/* Delete queue from the Rx adapter */
> > > +	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
> > > +						 TEST_ETHDEV_ID,
> > > +						 0);
> > > +	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
> > > +
> > >  	return TEST_SUCCESS;
> > >  }
> > >
> > > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > index 10491ca..2a84490 100644
> > > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > @@ -2844,12 +2844,13 @@
> > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> > >  		return -EINVAL;
> > >
> > >  	dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > > -	queue_info = &dev_info->rx_queue[rx_queue_id];
> > > -	if (!queue_info->queue_enabled) {
> > > +	if (dev_info->rx_queue == NULL ||
> > > +	    !dev_info->rx_queue[rx_queue_id].queue_enabled) {
> > >  		RTE_EDEV_LOG_ERR("Rx queue %u not added",
> > rx_queue_id);
> > >  		return -EINVAL;
> > >  	}
> > >
> > > +	queue_info = &dev_info->rx_queue[rx_queue_id];
> > >  	qi_ev = (struct rte_event *)&queue_info->event;
> > >
> > >  	memset(queue_conf, 0, sizeof(*queue_conf));
> > > --
> > > 2.6.4


  reply	other threads:[~2021-10-05  8:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30 12:47 [dpdk-dev] [PATCH v1] eventdev/rx-adapter: " Ganapati Kundapura
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
2021-10-01  4:42   ` Naga Harish K, S V
2021-10-01  5:21     ` Kundapura, Ganapati
2021-10-01  5:19   ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
2021-10-01  5:30     ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
2021-10-04 17:19       ` Jayatheerthan, Jay
2021-10-04 18:25         ` Kundapura, Ganapati
2021-10-05  8:19           ` Jayatheerthan, Jay [this message]
2021-10-06 17:32       ` Jerin Jacob

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=BN6SPR00MB2395BE62C3AFC290D8B11F8FDAF9@BN6SPR00MB239.namprd11.prod.outlook.com \
    --to=jay.jayatheerthan@intel.com \
    --cc=dev@dpdk.org \
    --cc=ganapati.kundapura@intel.com \
    --cc=jerinjacobk@gmail.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).