patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix use of indirect action after port close
@ 2022-03-07 16:48 Dmitry Kozlyuk
  2022-03-30 14:23 ` Singh, Aman Deep
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Kozlyuk @ 2022-03-07 16:48 UTC (permalink / raw)
  To: dev; +Cc: stable, Matan Azrad, Xiaoyun Li, Aman Singh, Yuying Zhang

When a port was closed, indirect actions could remain
with their handles no longer valid.
If a newly attached device was assigned the same ID as the closed port,
those indirect actions became accessible again.
Any attempt to use them resulted in an undefined behavior.
Automatically flush indirect actions when a port is closed.

Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 app/test-pmd/config.c  | 31 +++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  1 +
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 33 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cc8e7aa138..04baa319e0 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1844,6 +1844,37 @@ port_action_handle_destroy(portid_t port_id,
 	return ret;
 }
 
+int
+port_action_handle_flush(portid_t port_id)
+{
+	struct rte_port *port;
+	struct port_indirect_action **tmp;
+	int ret = 0;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+	    port_id == (portid_t)RTE_PORT_ALL)
+		return -EINVAL;
+	port = &ports[port_id];
+	tmp = &port->actions_list;
+	while (*tmp != NULL) {
+		struct rte_flow_error error;
+		struct port_indirect_action *pia = *tmp;
+
+		/* Poisoning to make sure PMDs update it in case of error. */
+		memset(&error, 0x44, sizeof(error));
+		if (pia->handle != NULL &&
+		    rte_flow_action_handle_destroy
+					(port_id, pia->handle, &error) != 0) {
+			printf("Indirect action #%u not destroyed\n", pia->id);
+			ret = port_flow_complain(&error);
+			tmp = &pia->next;
+		} else {
+			*tmp = pia->next;
+			free(pia);
+		}
+	}
+	return ret;
+}
 
 /** Get indirect action by port + id */
 struct rte_flow_action_handle *
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..f07f76f8f5 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3139,6 +3139,7 @@ close_port(portid_t pid)
 		if (is_proc_primary()) {
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
+			port_action_handle_flush(pi);
 			rte_eth_dev_close(pi);
 		}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 31f766c965..e25663e5b3 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -907,6 +907,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id,
 			      const struct rte_flow_action *action);
 int port_action_handle_destroy(portid_t port_id,
 			       uint32_t n, const uint32_t *action);
+int port_action_handle_flush(portid_t port_id);
 struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
 							    uint32_t id);
 int port_action_handle_update(portid_t port_id, uint32_t id,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] app/testpmd: fix use of indirect action after port close
  2022-03-07 16:48 [PATCH] app/testpmd: fix use of indirect action after port close Dmitry Kozlyuk
@ 2022-03-30 14:23 ` Singh, Aman Deep
  2022-03-30 22:56   ` Dmitry Kozlyuk
  0 siblings, 1 reply; 6+ messages in thread
From: Singh, Aman Deep @ 2022-03-30 14:23 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev; +Cc: stable, Matan Azrad, Xiaoyun Li, Yuying Zhang

Hi Dmitry,

On 3/7/2022 10:18 PM, Dmitry Kozlyuk wrote:
> When a port was closed, indirect actions could remain
> with their handles no longer valid.
> If a newly attached device was assigned the same ID as the closed port,
> those indirect actions became accessible again.
> Any attempt to use them resulted in an undefined behavior.
> Automatically flush indirect actions when a port is closed.
>
> Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
> ---
From: guides/prog_guide/rte_flow.rst
/"If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,//
//this means that the PMD can keep at least some indirect actions//
//across device stop and start.

/Please check, if we are inline with the guidelines given in the section.
/
/
>   app/test-pmd/config.c  | 31 +++++++++++++++++++++++++++++++
>   app/test-pmd/testpmd.c |  1 +
>   app/test-pmd/testpmd.h |  1 +
>   3 files changed, 33 insertions(+)
>
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index cc8e7aa138..04baa319e0 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1844,6 +1844,37 @@ port_action_handle_destroy(portid_t port_id,
>   	return ret;
>   }
>   
> +int
> +port_action_handle_flush(portid_t port_id)
> +{
> +	struct rte_port *port;
> +	struct port_indirect_action **tmp;
> +	int ret = 0;
> +
> +	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
> +	    port_id == (portid_t)RTE_PORT_ALL)
> +		return -EINVAL;
> +	port = &ports[port_id];
> +	tmp = &port->actions_list;
> +	while (*tmp != NULL) {
> +		struct rte_flow_error error;
> +		struct port_indirect_action *pia = *tmp;
> +
> +		/* Poisoning to make sure PMDs update it in case of error. */
> +		memset(&error, 0x44, sizeof(error));
> +		if (pia->handle != NULL &&
> +		    rte_flow_action_handle_destroy
> +					(port_id, pia->handle, &error) != 0) {
> +			printf("Indirect action #%u not destroyed\n", pia->id);
> +			ret = port_flow_complain(&error);
> +			tmp = &pia->next;
> +		} else {
> +			*tmp = pia->next;
> +			free(pia);
> +		}
> +	}
> +	return ret;
> +}
>   
>   /** Get indirect action by port + id */
>   struct rte_flow_action_handle *
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index fe2ce19f99..f07f76f8f5 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3139,6 +3139,7 @@ close_port(portid_t pid)
>   		if (is_proc_primary()) {
>   			port_flow_flush(pi);
>   			port_flex_item_flush(pi);
> +			port_action_handle_flush(pi);
>   			rte_eth_dev_close(pi);
>   		}
>   
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 31f766c965..e25663e5b3 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -907,6 +907,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id,
>   			      const struct rte_flow_action *action);
>   int port_action_handle_destroy(portid_t port_id,
>   			       uint32_t n, const uint32_t *action);
> +int port_action_handle_flush(portid_t port_id);
>   struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
>   							    uint32_t id);
>   int port_action_handle_update(portid_t port_id, uint32_t id,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] app/testpmd: fix use of indirect action after port close
  2022-03-30 14:23 ` Singh, Aman Deep
@ 2022-03-30 22:56   ` Dmitry Kozlyuk
  2022-04-10 20:31     ` Dmitry Kozlyuk
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Kozlyuk @ 2022-03-30 22:56 UTC (permalink / raw)
  To: Singh, Aman Deep, dev; +Cc: stable, Matan Azrad, Xiaoyun Li, Yuying Zhang

Hi Aman,

> From: Singh, Aman Deep <aman.deep.singh@intel.com>
> Sent: Wednesday, March 30, 2022 5:24 PM
> [...]
> On 3/7/2022 10:18 PM, Dmitry Kozlyuk wrote:
> > When a port was closed, indirect actions could remain
> > with their handles no longer valid.
> > If a newly attached device was assigned the same ID as the closed port,
> > those indirect actions became accessible again.
> > Any attempt to use them resulted in an undefined behavior.
> > Automatically flush indirect actions when a port is closed.
> >
> > Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> > Acked-by: Matan Azrad <matan@nvidia.com>
> > ---
> From: guides/prog_guide/rte_flow.rst
> /"If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,//
> //this means that the PMD can keep at least some indirect actions//
> //across device stop and start.
> 
> /Please check, if we are inline with the guidelines given in the section.

This patch is related to port closing, not port stopping.
Flow API resources are owned by the port,
so they cannot be valid when the port is closed and its ethdev removed.
TestPMD was keeping indirect action handles contrary to this.

As for RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP,
there is already "flow indirect_action destroy"
to erase indirect actions before stopping the port if this is desired.
I had another patch in mind to add "flow indirect_action flush"
for convenience, but it is independent of this fix.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] app/testpmd: fix use of indirect action after port close
  2022-03-30 22:56   ` Dmitry Kozlyuk
@ 2022-04-10 20:31     ` Dmitry Kozlyuk
  2022-04-12  5:41       ` Singh, Aman Deep
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Kozlyuk @ 2022-04-10 20:31 UTC (permalink / raw)
  To: Dmitry Kozlyuk, Singh, Aman Deep, dev
  Cc: stable, Matan Azrad, Xiaoyun Li, Yuying Zhang

Hi Aman,

> From: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Sent: Thursday, March 31, 2022 1:57 AM
> [...]
> > From: Singh, Aman Deep <aman.deep.singh@intel.com>
> > Sent: Wednesday, March 30, 2022 5:24 PM
> > [...]
> > On 3/7/2022 10:18 PM, Dmitry Kozlyuk wrote:
> > > When a port was closed, indirect actions could remain
> > > with their handles no longer valid.
> > > If a newly attached device was assigned the same ID as the closed
> port,
> > > those indirect actions became accessible again.
> > > Any attempt to use them resulted in an undefined behavior.
> > > Automatically flush indirect actions when a port is closed.
> > >
> > > Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> > > Acked-by: Matan Azrad <matan@nvidia.com>
> > > ---
> > From: guides/prog_guide/rte_flow.rst
> > /"If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,//
> > //this means that the PMD can keep at least some indirect actions//
> > //across device stop and start.
> >
> > /Please check, if we are inline with the guidelines given in the
> section.
> 
> This patch is related to port closing, not port stopping.
> Flow API resources are owned by the port,
> so they cannot be valid when the port is closed and its ethdev removed.
> TestPMD was keeping indirect action handles contrary to this.
> 
> As for RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP,
> there is already "flow indirect_action destroy"
> to erase indirect actions before stopping the port if this is desired.
> I had another patch in mind to add "flow indirect_action flush"
> for convenience, but it is independent of this fix.

Did my response clear up your concern?
In short: this patch is aligned with the defined flow resource behavior.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] app/testpmd: fix use of indirect action after port close
  2022-04-10 20:31     ` Dmitry Kozlyuk
@ 2022-04-12  5:41       ` Singh, Aman Deep
  2022-05-25 10:52         ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Singh, Aman Deep @ 2022-04-12  5:41 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev; +Cc: stable, Matan Azrad, Xiaoyun Li, Yuying Zhang


On 4/11/2022 2:01 AM, Dmitry Kozlyuk wrote:
> Hi Aman,
>
>> From: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
>> Sent: Thursday, March 31, 2022 1:57 AM
>> [...]
>>> From: Singh, Aman Deep <aman.deep.singh@intel.com>
>>> Sent: Wednesday, March 30, 2022 5:24 PM
>>> [...]
>>> On 3/7/2022 10:18 PM, Dmitry Kozlyuk wrote:
>>>> When a port was closed, indirect actions could remain
>>>> with their handles no longer valid.
>>>> If a newly attached device was assigned the same ID as the closed
>> port,
>>>> those indirect actions became accessible again.
>>>> Any attempt to use them resulted in an undefined behavior.
>>>> Automatically flush indirect actions when a port is closed.
>>>>
>>>> Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
>>>> Cc: stable@dpdk.org
>>>>
>>>> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
>>>> Acked-by: Matan Azrad <matan@nvidia.com>
>>>> ---
>>> From: guides/prog_guide/rte_flow.rst
>>> /"If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,//
>>> //this means that the PMD can keep at least some indirect actions//
>>> //across device stop and start.
>>>
>>> /Please check, if we are inline with the guidelines given in the
>> section.
>>
>> This patch is related to port closing, not port stopping.
>> Flow API resources are owned by the port,
>> so they cannot be valid when the port is closed and its ethdev removed.
>> TestPMD was keeping indirect action handles contrary to this.
Agreed, at port close these should be flushed. LGTM

Acked-by: Aman Singh <aman.deep.singh@intel.com>
>>
>> As for RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP,
>> there is already "flow indirect_action destroy"
>> to erase indirect actions before stopping the port if this is desired.
>> I had another patch in mind to add "flow indirect_action flush"
>> for convenience, but it is independent of this fix.
> Did my response clear up your concern?
> In short: this patch is aligned with the defined flow resource behavior.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] app/testpmd: fix use of indirect action after port close
  2022-04-12  5:41       ` Singh, Aman Deep
@ 2022-05-25 10:52         ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2022-05-25 10:52 UTC (permalink / raw)
  To: Dmitry Kozlyuk
  Cc: dev, stable, Matan Azrad, Xiaoyun Li, Yuying Zhang, Singh, Aman Deep

12/04/2022 07:41, Singh, Aman Deep:
> On 4/11/2022 2:01 AM, Dmitry Kozlyuk wrote:
> >> From: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> >> Sent: Thursday, March 31, 2022 1:57 AM
> >> [...]
> >>> From: Singh, Aman Deep <aman.deep.singh@intel.com>
> >>> Sent: Wednesday, March 30, 2022 5:24 PM
> >>> [...]
> >>> On 3/7/2022 10:18 PM, Dmitry Kozlyuk wrote:
> >>>> When a port was closed, indirect actions could remain
> >>>> with their handles no longer valid.
> >>>> If a newly attached device was assigned the same ID as the closed
> >> port,
> >>>> those indirect actions became accessible again.
> >>>> Any attempt to use them resulted in an undefined behavior.
> >>>> Automatically flush indirect actions when a port is closed.
> >>>>
> >>>> Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")
> >>>> Cc: stable@dpdk.org
> >>>>
> >>>> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> >>>> Acked-by: Matan Azrad <matan@nvidia.com>
> >>>> ---
> >>> From: guides/prog_guide/rte_flow.rst
> >>> /"If ``RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP`` is advertised,//
> >>> //this means that the PMD can keep at least some indirect actions//
> >>> //across device stop and start.
> >>>
> >>> /Please check, if we are inline with the guidelines given in the
> >> section.
> >>
> >> This patch is related to port closing, not port stopping.
> >> Flow API resources are owned by the port,
> >> so they cannot be valid when the port is closed and its ethdev removed.
> >> TestPMD was keeping indirect action handles contrary to this.
> Agreed, at port close these should be flushed. LGTM
> 
> Acked-by: Aman Singh <aman.deep.singh@intel.com>

Applied in next-net, thanks.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-25 10:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 16:48 [PATCH] app/testpmd: fix use of indirect action after port close Dmitry Kozlyuk
2022-03-30 14:23 ` Singh, Aman Deep
2022-03-30 22:56   ` Dmitry Kozlyuk
2022-04-10 20:31     ` Dmitry Kozlyuk
2022-04-12  5:41       ` Singh, Aman Deep
2022-05-25 10:52         ` Thomas Monjalon

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/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 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

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


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