DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal: fix device unregister for event registered with device_name NULL
@ 2024-07-18 19:37 longli
  2024-09-24 15:50 ` Stephen Hemminger
  2024-10-10 10:00 ` David Marchand
  0 siblings, 2 replies; 3+ messages in thread
From: longli @ 2024-07-18 19:37 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Malcolm Bumgardner, stable, Long Li

From: Malcolm Bumgardner <mbumgard@cisco.com>

In the device event unregister code, it unconditionally remove all
callbacks which are registered with device_name set to NULL. This results
in many callbacks uncorrectly removed.

Fix this by only removing callbacks with matching cb_fn and cb_arg.

Signed-off-by: Malcolm Bumgardner <mbumgard@cisco.com>

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
 lib/eal/common/eal_common_dev.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index a99252b02f..70aa04dcd9 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -550,16 +550,17 @@ rte_dev_event_callback_unregister(const char *device_name,
 		next = TAILQ_NEXT(event_cb, next);
 
 		if (device_name != NULL && event_cb->dev_name != NULL) {
-			if (!strcmp(event_cb->dev_name, device_name)) {
-				if (event_cb->cb_fn != cb_fn ||
-				    (cb_arg != (void *)-1 &&
-				    event_cb->cb_arg != cb_arg))
-					continue;
-			}
+			if (strcmp(event_cb->dev_name, device_name))
+				continue;
 		} else if (device_name != NULL) {
 			continue;
 		}
 
+		/* Remove only matching callback with arg */
+		if (event_cb->cb_fn != cb_fn ||
+		    (cb_arg != (void *)-1 && event_cb->cb_arg != cb_arg))
+			continue;
+
 		/*
 		 * if this callback is not executing right now,
 		 * then remove it.
-- 
2.43.0


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

* Re: [PATCH] eal: fix device unregister for event registered with device_name NULL
  2024-07-18 19:37 [PATCH] eal: fix device unregister for event registered with device_name NULL longli
@ 2024-09-24 15:50 ` Stephen Hemminger
  2024-10-10 10:00 ` David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2024-09-24 15:50 UTC (permalink / raw)
  To: longli; +Cc: Tyler Retzlaff, dev, Malcolm Bumgardner, stable, Long Li

On Thu, 18 Jul 2024 12:37:28 -0700
longli@linuxonhyperv.com wrote:

> From: Malcolm Bumgardner <mbumgard@cisco.com>
> 
> In the device event unregister code, it unconditionally remove all
> callbacks which are registered with device_name set to NULL. This results
> in many callbacks uncorrectly removed.
> 
> Fix this by only removing callbacks with matching cb_fn and cb_arg.
> 
> Signed-off-by: Malcolm Bumgardner <mbumgard@cisco.com>
> 
> Fixes: a753e53d517b ("eal: add device event monitor framework")
> Cc: stable@dpdk.org
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>  lib/eal/common/eal_common_dev.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

This patch solves the problem in the netvsc driver.
The netvsc driver registers a device event callback to discover when the VF
is added/removed. When the netvsc driver is stoppped, it unregisters this callback.
The bug is that the rte_dev code would end up removing all callbacks, including
the callback for other netvsc devices.

Perhaps a bugzilla entry or more direct example would have gotten more attention
on this.

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

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

* Re: [PATCH] eal: fix device unregister for event registered with device_name NULL
  2024-07-18 19:37 [PATCH] eal: fix device unregister for event registered with device_name NULL longli
  2024-09-24 15:50 ` Stephen Hemminger
@ 2024-10-10 10:00 ` David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: David Marchand @ 2024-10-10 10:00 UTC (permalink / raw)
  To: longli
  Cc: Tyler Retzlaff, dev, Malcolm Bumgardner, stable, Long Li,
	Stephen Hemminger

On Thu, Jul 18, 2024 at 9:37 PM <longli@linuxonhyperv.com> wrote:
>
> From: Malcolm Bumgardner <mbumgard@cisco.com>
>
> In the device event unregister code, it unconditionally remove all
> callbacks which are registered with device_name set to NULL. This results
> in many callbacks uncorrectly removed.
>
> Fix this by only removing callbacks with matching cb_fn and cb_arg.
>
> Fixes: a753e53d517b ("eal: add device event monitor framework")
> Cc: stable@dpdk.org
>
> Signed-off-by: Malcolm Bumgardner <mbumgard@cisco.com>
> Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.


-- 
David Marchand


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

end of thread, other threads:[~2024-10-10 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18 19:37 [PATCH] eal: fix device unregister for event registered with device_name NULL longli
2024-09-24 15:50 ` Stephen Hemminger
2024-10-10 10:00 ` David Marchand

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).