All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Fixes for devlink rate objects API
@ 2021-06-23 13:43 dlinkin
  2021-06-23 13:43 ` [PATCH net-next 1/3] devlink: Decrease refcnt of parent rate object on leaf destroy dlinkin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dlinkin @ 2021-06-23 13:43 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, parav, vladbu, Dmytro Linkin

From: Dmytro Linkin <dlinkin@nvidia.com>

Patch #1 fixes not decreased refcount of parent node for destroyed leaf
object.

Patch #2 fixes incorect eswitch mode check.

Patch #3 protects list traversing with a lock.

Dmytro Linkin (3):
  devlink: Decrease refcnt of parent rate object on leaf destroy
  devlink: Remove eswitch mode check for mode set call
  devlink: Protect rate list with lock while switching modes

 net/core/devlink.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

-- 
1.8.3.1


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

* [PATCH net-next 1/3] devlink: Decrease refcnt of parent rate object on leaf destroy
  2021-06-23 13:43 [PATCH net-next 0/3] Fixes for devlink rate objects API dlinkin
@ 2021-06-23 13:43 ` dlinkin
  2021-06-23 13:43 ` [PATCH net-next 2/3] devlink: Remove eswitch mode check for mode set call dlinkin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dlinkin @ 2021-06-23 13:43 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, parav, vladbu, Dmytro Linkin

From: Dmytro Linkin <dlinkin@nvidia.com>

Port functions, like SFs, can be deleted by the user when its leaf rate
object has parent node. In such case node refcnt won't be decreased
which blocks the node from deletion later.
Do simple refcnt decrease, since driver in cleanup stage. This:
1) assumes that driver took proper internal parent unset action;
2) allows to avoid nested callbacks call and deadlock.

Fixes: d75559845078 ("devlink: Allow setting parent node of rate objects")
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 net/core/devlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 566ddd1..ba27395 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -9275,6 +9275,8 @@ void devlink_rate_leaf_destroy(struct devlink_port *devlink_port)
 
 	mutex_lock(&devlink->lock);
 	devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_DEL);
+	if (devlink_rate->parent)
+		refcount_dec(&devlink_rate->parent->refcnt);
 	list_del(&devlink_rate->list);
 	devlink_port->devlink_rate = NULL;
 	mutex_unlock(&devlink->lock);
-- 
1.8.3.1


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

* [PATCH net-next 2/3] devlink: Remove eswitch mode check for mode set call
  2021-06-23 13:43 [PATCH net-next 0/3] Fixes for devlink rate objects API dlinkin
  2021-06-23 13:43 ` [PATCH net-next 1/3] devlink: Decrease refcnt of parent rate object on leaf destroy dlinkin
@ 2021-06-23 13:43 ` dlinkin
  2021-06-23 13:43 ` [PATCH net-next 3/3] devlink: Protect rate list with lock while switching modes dlinkin
  2021-06-23 22:50 ` [PATCH net-next 0/3] Fixes for devlink rate objects API patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: dlinkin @ 2021-06-23 13:43 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, parav, vladbu, Dmytro Linkin

From: Dmytro Linkin <dlinkin@nvidia.com>

When eswitch is disabled, querying its current mode results in error.
Due to this when trying to set the eswitch mode for mlx5 devices, it
fails to set the eswitch switchdev mode.
Hence remove such check.

Fixes: a8ecb93ef03d ("devlink: Introduce rate nodes")
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 net/core/devlink.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index ba27395..153d432 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2709,17 +2709,6 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 				    struct netlink_ext_ack *extack)
 {
 	struct devlink_rate *devlink_rate;
-	u16 old_mode;
-	int err;
-
-	if (!devlink->ops->eswitch_mode_get)
-		return -EOPNOTSUPP;
-	err = devlink->ops->eswitch_mode_get(devlink, &old_mode);
-	if (err)
-		return err;
-
-	if (old_mode == mode)
-		return 0;
 
 	list_for_each_entry(devlink_rate, &devlink->rate_list, list)
 		if (devlink_rate_is_node(devlink_rate)) {
-- 
1.8.3.1


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

* [PATCH net-next 3/3] devlink: Protect rate list with lock while switching modes
  2021-06-23 13:43 [PATCH net-next 0/3] Fixes for devlink rate objects API dlinkin
  2021-06-23 13:43 ` [PATCH net-next 1/3] devlink: Decrease refcnt of parent rate object on leaf destroy dlinkin
  2021-06-23 13:43 ` [PATCH net-next 2/3] devlink: Remove eswitch mode check for mode set call dlinkin
@ 2021-06-23 13:43 ` dlinkin
  2021-06-23 22:50 ` [PATCH net-next 0/3] Fixes for devlink rate objects API patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: dlinkin @ 2021-06-23 13:43 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, parav, vladbu, Dmytro Linkin

From: Dmytro Linkin <dlinkin@nvidia.com>

Devlink eswitch set command doesn't hold devlink->lock, which makes
possible race condition between rate list traversing and others devlink
rate KAPI calls, like devlink_rate_nodes_destroy().
Hold devlink lock while traversing the list.

Fixes: a8ecb93ef03d ("devlink: Introduce rate nodes")
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 net/core/devlink.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 153d432..8fdd04f 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2710,11 +2710,15 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 {
 	struct devlink_rate *devlink_rate;
 
+	/* Take the lock to sync with devlink_rate_nodes_destroy() */
+	mutex_lock(&devlink->lock);
 	list_for_each_entry(devlink_rate, &devlink->rate_list, list)
 		if (devlink_rate_is_node(devlink_rate)) {
+			mutex_unlock(&devlink->lock);
 			NL_SET_ERR_MSG_MOD(extack, "Rate node(s) exists.");
 			return -EBUSY;
 		}
+	mutex_unlock(&devlink->lock);
 	return 0;
 }
 
-- 
1.8.3.1


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

* Re: [PATCH net-next 0/3] Fixes for devlink rate objects API
  2021-06-23 13:43 [PATCH net-next 0/3] Fixes for devlink rate objects API dlinkin
                   ` (2 preceding siblings ...)
  2021-06-23 13:43 ` [PATCH net-next 3/3] devlink: Protect rate list with lock while switching modes dlinkin
@ 2021-06-23 22:50 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-23 22:50 UTC (permalink / raw)
  To: Dmytro Linkin; +Cc: netdev, davem, kuba, jiri, parav, vladbu

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Wed, 23 Jun 2021 16:43:12 +0300 you wrote:
> From: Dmytro Linkin <dlinkin@nvidia.com>
> 
> Patch #1 fixes not decreased refcount of parent node for destroyed leaf
> object.
> 
> Patch #2 fixes incorect eswitch mode check.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] devlink: Decrease refcnt of parent rate object on leaf destroy
    https://git.kernel.org/netdev/net-next/c/1321ed5e7648
  - [net-next,2/3] devlink: Remove eswitch mode check for mode set call
    https://git.kernel.org/netdev/net-next/c/ff99324ded01
  - [net-next,3/3] devlink: Protect rate list with lock while switching modes
    https://git.kernel.org/netdev/net-next/c/a3e5e5797faa

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-06-23 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 13:43 [PATCH net-next 0/3] Fixes for devlink rate objects API dlinkin
2021-06-23 13:43 ` [PATCH net-next 1/3] devlink: Decrease refcnt of parent rate object on leaf destroy dlinkin
2021-06-23 13:43 ` [PATCH net-next 2/3] devlink: Remove eswitch mode check for mode set call dlinkin
2021-06-23 13:43 ` [PATCH net-next 3/3] devlink: Protect rate list with lock while switching modes dlinkin
2021-06-23 22:50 ` [PATCH net-next 0/3] Fixes for devlink rate objects API patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.